由于前段时间挂载一个新的硬盘出错,自己吧vps重新安装了一下 当时一时间大脑发热就安装了wdcp面板, 因为wdcp搭建的环境支持Nginx+Apache双web 存在一定的不兼容性问题,同时wdcp3.3存在的BUG问题也是非常之多. 我的页面错误提示如下:
重定向过多,无法打开网页,重定向循环…….当然不同浏览器下是有不同报错的。
我当时以为是浏览器的问题,重启清空了cookies也还是不行。 产生错误的原因主要是因为: 1、wdcp3.3,在使用Nginx+Apache模式下,默认的php版本是5.53,这个时候提示重定向过多,网页无法打开。 2、因为不知道到底是Apache出了问题,还是Nginx出了问题。 所以这个时候我切换到了Nginx,依然报错。 切换到了Apache,提示PHP版本为5.53,owncloud10.0.10需要php7.0以上支持。 后来我又切到了Nginx+Apache模式下,把cloud.xxx.com的php设为7.0,依然报错。 基本可以确定为Nginx的问题。 3、在百度上和wdcp上走了很多弯路,原本准备放弃,或者换宝塔面板重新安装的。后来睡觉起来就换了个思维 重新安装了一遍不行,换了个环境OK了,看来确实是VPS的环境问题。 靠人不如靠自己,把网站错误日志打开,查到了Nginx.conf配置不正确 自己在owncloud官方上找到了配置办法。 需要手动对Nginx配置(按照owncloud) 4、解决过程如下: 大致过程:1、修改conf配置文件,保存,不要加载。2、将conf配置文件设置为只读。3、重启web 具体过程: 打开wdcp面板—文件管理—Nginx配置—XXX.XXX.COM.CONF 也可以在SSH里面直接打开使用VIM命令修改,比较麻烦。 将原代码全部删除,英文备注是官方的,写入以下代码:
upstream php-handler {
server unix:/tmp/php-70-cgi.sock;
#php服务,如果你用的是7.1,就更换成php-71,请参考wdcp原xxx.com.conf文件里面参数,和你指定的php版本有关;
}
server {
listen 80;
server_name cloud.xxxx.com;
#服务名称,修改为自己的名称
Path to the root of your installation
root /www/web/cloud/public_html;
#替换成自己的owncloud安装根目录
set max upload size
client_max_body_size 10G;
fastcgi_buffers 64 4K;
rewrite ^/caldav(.)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
index index.php;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ ^/(?:.htaccess|data|config|db_structure.xml|README){
deny all;
}
location / {
The following 2 rules are only needed with webfinger
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
try_files $uri $uri/ /index.php;
}
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_pass php-handler;
}
Optional: set long EXPIRES header on static assets
location ~* .(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
Optional: Don’t log access to assets
access_log off;
}
}
如果使用ssl,请看这里,亲测可用
upstream php-handler { server 127.0.0.1:9000; # Depending on your used PHP version #server unix:/var/run/php5-fpm.sock; #server unix:/var/run/php7-fpm.sock; } server { listen 80; server_name cloud.example.com; # For Lets Encrypt, this needs to be served via HTTP location /.well-known/acme-challenge/ { root /var/www/owncloud; # Specify here where the challenge file is placed } # enforce https location / { return 301 https://$server_name$request_uri; } } server { listen 443 ssl http2; server_name cloud.example.com; ssl_certificate /etc/ssl/nginx/cloud.example.com.crt; ssl_certificate_key /etc/ssl/nginx/cloud.example.com.key; # Example SSL/TLS configuration. Please read into the manual of NGINX before applying these. ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers "-ALL:EECDH+AES256:EDH+AES256:AES256-SHA:EECDH+AES:EDH+AES:!ADH:!NULL:!aNULL:!eNULL:!EXPORT:!LOW:!MD5:!3DES:!PSK:!SRP:!DSS:!AESGCM:!RC4"; ssl_dhparam /etc/nginx/dh4096.pem; ssl_prefer_server_ciphers on; keepalive_timeout 70; ssl_stapling on; ssl_stapling_verify on; # Add headers to serve security related headers # Before enabling Strict-Transport-Security headers please read into this topic first. #add_header Strict-Transport-Security "max-age=15552000; includeSubDomains"; 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; # Path to the root of your installation root /var/www/owncloud/; location = /robots.txt { allow all; log_not_found off; access_log off; } # 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 = /.well-known/carddav { return 301 $scheme://$host/remote.php/dav; } location = /.well-known/caldav { return 301 $scheme://$host/remote.php/dav; } # set max upload size client_max_body_size 512M; fastcgi_buffers 8 4K; # Please see note 1 fastcgi_ignore_headers X-Accel-Buffering; # Please see note 2 # Disable gzip to avoid the removal of the ETag header # Enabling gzip would also make your server vulnerable to BREACH # if no additional measures are done. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=773332 gzip off; # Uncomment if your server is build with the ngx_pagespeed module # This module is currently not supported. #pagespeed 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)/ { return 404; } location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; } location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) { fastcgi_split_path_info ^(.+\.php)(/.*)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; # necessary for owncloud to detect the contextroot https://github.com/owncloud/core/blob/v10.0.0/lib/private/AppFramework/Http/Request.php#L603 fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param HTTPS on; fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice fastcgi_param front_controller_active true; fastcgi_read_timeout 180; # increase default timeout e.g. for long running carddav/ caldav syncs with 1000+ entries fastcgi_pass php-handler; fastcgi_intercept_errors on; fastcgi_request_buffering off; #Available since NGINX 1.7.11 } location ~ ^/(?:updater|ocs-provider)(?:$|/) { try_files $uri $uri/ =404; index index.php; } # Adding the cache control header for js and css files # Make sure it is BELOW the PHP block location ~ \.(?:css|js)$ { try_files $uri /index.php$uri$is_args$args; add_header Cache-Control "max-age=15778463"; # Add headers to serve security related headers (It is intended to have those duplicated to the ones above) # Before enabling Strict-Transport-Security headers please read into this topic first. #add_header Strict-Transport-Security "max-age=15552000; includeSubDomains"; 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; # Optional: Don't log access to assets access_log off; } location ~ \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg|map)$ { add_header Cache-Control "public, max-age=7200"; try_files $uri /index.php$uri$is_args$args; # Optional: Don't log access to other assets access_log off; } }
以上文档参考官方文档:https://doc.owncloud.org/server/10.0/admin_manual/installation/nginx_configuration.html 很重要的一点:这个时候先保存,但不要立刻加载。由于wdcp的问题,你保存之后重新加载,文件又会变回以前。 因为wdcp每一次修改该站点配置就会重新回到wdcp自己的.conf配置文件 所以需要将xxx.com.conf文件设为只读不可修改。 可以参考以下命令: cd /www/wdlinux/nginx/conf/vhost #打开你的wdcp安装目录,我是安装在www文件下面的,有的vps可能为一块硬盘,看你个人 chattr +i xxx.com.conf #给.conf 加上一个i属性,可读不可修改。 lsattr xxx.com.conf #查看下文件权限配置属性,如果里面多了个i证明已经修改成功 #----i--------e- xxxx.com.conf #如果你一次没有配置正确,可以用 chattr -i xxx.com.conf #先去掉只读属性,之后在重新操作。下次需要修改的时候,一定要先去掉i属性。 重启web服务器,问题解决。