• 在Debian上使用Nginx、MariaDB和PHP7安装自己的Cloud 9服务器

    在本教程中,我将向您展示如何使用Nginx、MariaDB和PHP7在Debian 8 VPS上设置ownCloud个人云存储。安装过程与在Debian 8上安装WordPress非常相似。本教程在一个只有128MB内存的VPS上演示,它可以毫无问题地运行自己的云。我假设您已经在Debian 8上配置了一个LEMP堆栈。如果您还没有这样做,请查看下面的简易指南,了解如何做到这一点。 如何在Debian 8 Jessie(Nginx、MariaDB、PHP7)上安装LEMP堆栈 步骤1:在Debian 8 VPS上安装ownCloud 9服务器 首先,使用wget在Debian 8 VPS上获取自己的云签名密钥-nv代表不冗长。 wget -nv https://download.owncloud.org/download/repositories/stable/Debian_8.0/Release.key -O Release.key 然后使用apt密钥将该签名密钥添加到Debian 8。 sudo apt-key add - < Release.key 接下来,运行此命令添加官方云存储库。 sudo sh -c "echo 'deb http://download.owncloud.org/download/repositories/stable/Debian_8.0/ /' >> /etc/apt/sources.list.d/owncloud.list" 之后,更新本地包索引并安装owncloud文件。 sudo apt-get update;sudo apt-get install owncloud-files 有两个软件包可以安装:owncloud和owncloud文件。区别在于,如果你安装了owncloud,那么它会自动安装apache2、mysql和php5。因为我们已经在Debian 8 VPS上配置了Nginx、MariaDB和PHP7堆栈,所以我们只需要安装独立的owncloud文件。 OwnCloud文件存储在/var/www/OwnCloud目录中。 步骤2:为ownCloud创建数据库和用户 登录MariaDB数据库服务器: mysql -u root -p 然后为owncloud创建一个数据库。 create database owncloud; 在本地主机上创建数据库用户。 create user [email protected] identified by 'password'; 授予此用户在owncloud数据库上的所有权限。 grant all privileges on owncloud.* to [email protected] identified by 'password'; 刷新权限并退出。 flush privileges; exit; 步骤3:在MariaDB中启用二进制日志记录 打开我的门。cnf文件。你的我的。cnf文件可能位于/etc/mysql/my。cnf。 sudo nano /etc/my.cnf 在[mysqld]部分添加以下三行。 log-bin = /var/log/mysql/mariadb-bin log-bin-index = /var/log/mysql/mariadb-bin.index binlog_format = mixed 二进制日志的格式必须是混合的。保存并关闭文件。然后重新加载服务。 sudo service mysql reload         or      sudo systemctl reload mysql 第4步:从Let's Encrypt获得免费SSL证书 首先安装,让我们从Github加密客户端。 sudo apt-get install git git clone 现在将cd放入letsencypt目录。 cd letsencrypt/ 停止Nginx进程。 sudo service nginx stop       or         sudo systemctl stop nginx 使用以下命令为您的域名获取SSL证书: ./letsencrypt-auto certonly --standalone --email <your-email-address> --agree-tos -d owncloud.your-domain.com 注意:我假设你使用的是像owncloud这样的域名。你的领域。com访问自己的云网络界面。在运行上述命令之前,您还需要将域名指向DNS中的服务器IP。 certonly表示客户端获得SSL证书,但不会安装它。因为Let's Encrypt仍处于测试阶段,不支持Nginx的自动SSL配置,所以我们必须手动配置(安装)SSL。 您的SSL证书将保存在/etc/letsencrypt/live/&lt;你的领域。com&gt;目录 步骤5:为owncloud创建Nginx配置文件 sudo nano /etc/nginx/conf.d/owncloud.conf 将以下文本放入文件中。 upstream php-handler { #server 127.0.0.1:9000; server unix:/run/php/php7.0-fpm.sock; } server { listen 80; server_name owncloud.your-domain.com; # enforce https return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name owncloud.your-domain.com; ssl_certificate /etc/letsencrypt/live/owncloud.your-domain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/owncloud.your-domain.com/privkey.pem; # Add headers to serve security related headers add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; add_header X-Content-Type-Options nosniff; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Robots-Tag none; # Path to the root of your installation root /var/www/owncloud/; # set max upload size client_max_body_size 10G; fastcgi_buffers 64 4K; # Disable gzip to avoid the removal of the ETag header gzip off; # Uncomment if your server is build with the ngx_pagespeed module # This module is currently not supported. #pagespeed off; index index.php; error_page 403 /core/templates/403.php; error_page 404 /core/templates/404.php; rewrite ^/.well-known/carddav /remote.php/carddav/ permanent; rewrite ^/.well-known/caldav /remote.php/caldav/ permanent; # The following 2 rules are only needed for the user_webfinger app. # Uncomment it if you're planning to use this app. #rewrite ^/.well-known/host-meta /public.php?service=host-meta last; #rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last; location = /robots.txt { allow all; log_not_found off; access_log off; } location ~ ^/(build|tests|config|lib|3rdparty|templates|data)/ { deny all; } location ~ ^/(?:/.|autotest|occ|issue|indie|db_|console) { deny all; } location / { rewrite ^/remote/(.*) /remote.php last; rewrite ^(/core/doc/[^//]+/)$ $1/index.html; try_files $uri $uri/ =404; } location ~ /.php(?:$|/) { fastcgi_split_path_info ^(.+/.php)(/.+)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param HTTPS on; fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice fastcgi_pass php-handler; fastcgi_intercept_errors on; } # Adding the cache control header for js and css files # Make sure it is BELOW the location ~ /.php(?:$|/) { block location ~* /.(?:css|js)$ { add_header Cache-Control "public, max-age=7200"; # Add headers to serve security related headers add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; add_header X-Content-Type-Options nosniff; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Robots-Tag none; # Optional: Don't log access to assets access_log off; } # Optional: Don't log access to other assets location ~* /.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ { access_log off; } } 用实际数据替换红色文本。此配置文件假定php fpm进程监听Unix套接字。如果您的php fpm监听127.0.0.1:9000,则需要更改上游部分。您还可以在此配置中为SSL启用http2。请注意,Nginx在1.9.5版之前不支持http2。查看以下教程,了解如何在Debian 8服务器上使用最新的Nginx版本启用HTTP2。 如何在Debian 8服务器上使用最新的Nginx版本启用HTTP2 保存此配置文件后,安装所需的php7扩展名。 sudo apt install php7.0-common php7.0-gd php7.0-json php7.0-curl  php7.0-zip php7.0-xml php7.0-mbstring 现在重新启动Nginx进程。 sudo service nginx restart      or       sudo systemctl restart nginx 第6步:设置Web界面 在浏览器地址栏中,键入 owncloud.your-domain.com 您需要创建一个管理帐户,并将ownCloud服务与MariaDB数据库连接起来。 完成后,您将进入owncloud的Web界面。恭喜!您现在可以开始使用owncloud作为您的私有云存储。 正如您所见,安装ownCloud的过程与安装WordPress和Drupal的过程非常相似。 欢迎提出意见、问题或建议。如果你觉得这篇文章有用?请在社交媒体上与朋友分享!请继续关注更多Linux教程。

    2022.03.24 浏览:414