微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我们可以将nginx用于wordpress和drupal吗?

我有一台debian机器,我为我的web服务器工作进程安装了Nginx.但是我们只需要在认的Nginx配置中更改一下wordpress,它位于/ etc / Nginx / sites-enabled /!

/etc/Nginx/sites-enabled/wordpress.com
/etc/Nginx/sites-enabled/drupal.com

我可以在单个debian机器下知道这两个网站的样本Nginx配置.

解决方法:

您可以使用Nginx运行多个站点,类似于apache vhost.

在/ etc / Nginx / sites-enabled中,您可以添加两个vhost

wordpress.example.com

server {
       listen 80;
       server_name wordpress.example.com;
       root /var/www/wordpress;
#      if ($http_host != "www.example.com") {
#                rewrite ^ http://www.example.com$request_uri permanent;
#      }
       index index.PHP index.html;
       location = /favicon.ico {
                log_not_found off;
                access_log off;
       }
       location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
       }
       # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
       location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
       }
       location / {
                try_files $uri $uri/ /index.PHP?$args;
       }
       # Add trailing slash to */wp-admin requests.
       rewrite /wp-admin$$scheme://$host$uri/ permanent;
       location ~*  \.(jpg|jpeg|png|gif|css|js|ico)${
                expires max;
                log_not_found off;
       }
       location ~ \.PHP${
                try_files $uri =404;
                include /etc/Nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       }
}

drupal.example.com

server {
       listen 80;
       server_name drupal.example.com;
       root /var/www/drupal;
#      if ($http_host != "www.example.com") {
#                rewrite ^ http://www.example.com$request_uri permanent;
#      }
       index index.PHP index.html;
       location = /favicon.ico {
                log_not_found off;
                access_log off;
       }
       location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
       }
       # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
       location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
       }
       location / {
                try_files $uri $uri/ /index.PHP?$args;
       }
       # Add trailing slash to */wp-admin requests.
       rewrite /wp-admin$$scheme://$host$uri/ permanent;
       location ~*  \.(jpg|jpeg|png|gif|css|js|ico)${
                expires max;
                log_not_found off;
       }
       location ~ \.PHP${
                try_files $uri =404;
                include /etc/Nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9001;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐