设为首页 收藏本站
查看: 1130|回复: 0

[经验分享] aliyun 主机Nginx 上配置Drupal 伪静态

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-8-13 09:10:12 | 显示全部楼层 |阅读模式
网上找了好久没有正确的,后面直接在http://wiki.nginx.org/Drupal

上找到原文,但原文中复制过来会出现个 'root' rewrite directive is duplicate 错误和 server 第一列的错误。

对比aliyun上的预先设定的rewrite 发现它们都没有server {} 这个名,并且这个位置也在nginx -t 时报错了。

注释了报错的位置,删除了不适用于drupal 7下面的配置。

    /alidata/server/nginx/sbin/nginx -t

设置的时候用这个测试。

最后把conf 文件也设置好,重启下。

    /alidata/server/nginx/sbin/nginx -s reload


带上原文配置:


            server_name domain.tld;  
           #root /var/www/drupal7; ## <-- Your only path reference.  
      
            # Enable compression, this will help if you have for instance advagg? module  
            # by serving Gzip versions of the files.  
            gzip_static on;  
      
            location = /favicon.ico {  
                    log_not_found off;  
                    access_log off;  
            }  
      
            location = /robots.txt {  
                    allow all;  
                    log_not_found off;  
                    access_log off;  
            }  
      
            # This matters if you use drush prior to 5.x  
            # After 5.x backups are stored outside the Drupal install.  
            #location = /backup {  
            #        deny all;  
            #}  
      
            # Very rarely should these ever be accessed outside of your lan  
            location ~* \.(txt|log)$ {  
                    allow 192.168.0.0/16;  
                    deny all;  
            }  
      
            location ~ \..*/.*\.php$ {  
                    return 403;  
            }  
      
            # No no for private  
            location ~ ^/sites/.*/private/ {  
                    return 403;  
            }  
      
            # Block access to "hidden" files and directories whose names begin with a  
            # period. This includes directories used by version control systems such  
            # as Subversion or Git to store control files.  
            location ~ (^|/)\. {  
                    return 403;  
            }  
      
            location / {  
                    # This is cool because no php is touched for static content  
                    try_files $uri @rewrite;  
            }  
      
            location @rewrite {  
                    # You have 2 options here  
                    # For D7 and above:  
                    # Clean URLs are handled in drupal_environment_initialize().  
                    rewrite ^ /index.php;  
                    # For Drupal 6 and bwlow:  
                    # Some modules enforce no slash (/) at the end of the URL  
                    # Else this rewrite block wouldn't be needed (GlobalRedirect)  
                    #rewrite ^/(.*)$ /index.php?q=$1;  
            }  
      
            location ~ \.php$ {  
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;  
                    #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini  
                    include fastcgi_params;  
                    fastcgi_param SCRIPT_FILENAME $request_filename;  
                    fastcgi_intercept_errors on;  
                    fastcgi_pass unix:/tmp/phpfpm.sock;  
            }  
      
            # Fighting with Styles? This little gem is amazing.  
            # This is for D6  
            #location ~ ^/sites/.*/files/imagecache/ {  
            # This is for D7 and D8  
            location ~ ^/sites/.*/files/styles/ {  
                    try_files $uri @rewrite;  
            }  
      
            location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {  
                    expires max;  
                    log_not_found off;  
            }  
    }  


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-23621-1-1.html 上篇帖子: PHP+FastCGI+Nginx配置PHP运行环境方法 下篇帖子: Nginx+Tomcat7+Mencached负载均衡集群部署笔记 主机
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表