标签:l数据库 查看 服务器 注释 end pre latest ted linu
首先,说一说这款开源软件的原理,主要核心是PHP,网页的代码也全部都是PHP的。getenforce
systemctl status firewalld
二、安装nginx
yum -y install nginx
三、安装php7.1
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum search php71w
yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath php-dom
四、检测是否安装成功
#nginx -v
nginx version: nginx/1.12.2
#php -v
PHP 7.1.29 (cli) (built: May 13 2019 18:32:21) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
五、使用 vim 编辑默认的 php7-fpm 配置文件。
vim /etc/php-fpm.d/www.conf
在第 8 行和第 10行,user 和 group 赋值为 nginx。
user = nginx
group = nginx
在第 22 行,确保 php-fpm 运行在指定端口。
listen = 127.0.0.1:9000
取消第 366-370 行的注释,启用 php-fpm 的系统环境变量。
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
六、就是在 /var/lib/ 目录下创建一个新的文件夹 session,并将其拥有者变更为 nginx 用户。
mkdir -p /var/lib/php/session
chown nginx:nginx -R /var/lib/php/session/
然后启动 php-fpm 和 Nginx,并且将它们设置为随开机启动的服务。
systemctl start php-fpm
systemctl start nginx
systemctl enable php-fpm
systemctl enable nginx
七、安装mysql
我这里使用 MariaDB 作为 Nextcloud 的数据库。可以直接使用 yum 命令从 CentOS 默认远程仓库中安装 mariadb-server包。
yum -y install mariadb mariadb-server
启动 MariaDB,并将其添加到随系统启动的服务中去。
systemctl start mariadb
systemctl enable mariadb
mysql数据库搭建完成是没有密码的自己可以设置,我在这里没有设置密码直接登陆
直接进入数据库创建名为 nextcloud_db 的数据库以及名为 nextclouduser 的用户,用户密码为 nextclouduser。当然自己也可以随意设置密码。
create database nextcloud_db;
create user nextclouduser@localhost identified by ‘nextclouduser‘;
grant all privileges on nextcloud_db.* to nextclouduser@localhost identified by ‘nextclouduser‘;
flush privileges;
八、为nextcloud 生成自签名ssl证书
为 SSL 文件创建新目录:
mkdir -p /etc/nginx/cert/
使用 openssl 生成一个新的 SSL 证书。
openssl req -new -x509 -days 365 -nodes -out /etc/nginx/cert/nextcloud.crt -keyout /etc/nginx/cert/nextcloud.key
会出现一下信息,可以随便填写
Country Name (2 letter code) [XX]:cn //国家
State or Province Name (full name) []:guangdong //省份
Locality Name (eg, city) [Default City]:guangzhou //地区名字
Organization Name (eg, company) [Default Company Ltd]:Amos //公司名
Organizational Unit Name (eg, section) []:Technology //部门
Common Name (eg, your name or your server‘s hostname) []:Amos //CA主机名
Email Address []:Amos@Amos.com //Email地址
修改文件夹权限
chmod 600 /etc/nginx/cert/*
chmod 700 /etc/nginx/cert
九、下载Nextcloud
wget https://download.nextcloud.com/server/releases/nextcloud-13.0.1.zip
解压
unzip nextcloud-13.0.1.zip
移动到nginx站点目录
mv nextcloud/ /usr/share/nginx/html/
创建nextcloud的存储目录并设置权限
cd /usr/share/nginx/html/
mkdir -p nextcloud/data/
chown nginx:nginx -R nextcloud/
十、编辑nginx配置文件
cd /etc/nginx/conf.d/
vim nextcloud.conf
upstream php-handler {
server 127.0.0.1:9000;
}server {
listen 80;
server_name wangpan.zkzd.cn;
return 301 https://$server_name$request_uri;
}server {
listen 443 ssl;
server_name cloud.nextcloud.co;ssl_certificate /etc/nginx/cert/nextcloud.crt; ssl_certificate_key /etc/nginx/cert/nextcloud.key; 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; add_header X-Download-Options noopen; add_header X-Permitted-Cross-Domain-Policies none; root /usr/share/nginx/html/nextcloud/; location = /robots.txt { allow all; log_not_found off; access_log off; } location = /.well-known/carddav { return 301 $scheme://$host/remote.php/dav; } location = /.well-known/caldav { return 301 $scheme://$host/remote.php/dav; } client_max_body_size 512M; fastcgi_buffers 64 4K; gzip off; error_page 403 /core/templates/403.php; error_page 404 /core/templates/404.php; location / { rewrite ^ /index.php$uri; } location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ { deny all; } location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { deny all; } location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) { include fastcgi_params; fastcgi_split_path_info ^(.+\.php)(/.*)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param HTTPS on; #Avoid sending the security headers twice fastcgi_param modHeadersAvailable true; fastcgi_param front_controller_active true; fastcgi_pass php-handler; fastcgi_intercept_errors on; fastcgi_request_buffering off; } location ~ ^/(?:updater|ocs-provider)(?:$|/) { try_files $uri/ =404; index index.php; } location ~* \.(?:css|js)$ { try_files $uri /index.php$uri$is_args$args; add_header Cache-Control "public, max-age=7200"; 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; add_header X-Download-Options noopen; add_header X-Permitted-Cross-Domain-Policies none; access_log off; } location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ { try_files $uri /index.php$uri$is_args$args; access_log off; }
}
检查nginx语法正确重启nginx
nginx -t
systemctl restart nginx
注意:中间可能有php模块没有安装,自己yum安装一下缺少的模块不一一阐述了!
yum install php-dom
yum install php-xml --skip-broken
十一、登陆外面页面看是否搭建成功,一般是用域名也可以是IP访问,如果报错500 看下nginx配置文件 是否正确 百分之99是配置文件错误,希望对大家有所帮助。
Nextcloud私有网盘搭建完成有问题可以随时联系我
QQ:1349371880
Centos7系统安装nextcloud13.0.1,详细教程
标签:l数据库 查看 服务器 注释 end pre latest ted linu
原文地址:https://blog.51cto.com/12226796/2405388