我有一台 debian 机器,我在其上为我的 Web 服务器工作进程安装了 nginx。但是我们只需要在默认的 nginx 配置中对 wordpress 进行一些更改即可/etc/nginx/sites-enabled/
!
/etc/nginx/sites-enabled/wordpress.com
/etc/nginx/sites-enabled/drupal.com
我可以知道这两个网站在单个 debian 机器下的示例 nginx 配置吗?
我有一台 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
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;
}
}
和
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;
}
}