我正在尝试设置一个新的本地开发服务器,而不是Apache,我决定使用nginx。
我想做的是让每个WordPress站点位于其自己的目录中/usr/share/nginx/www
. 这些网站只能在我们的本地网络上使用。例如:
/usr/share/nginx/www/ourcompanywebsite
-> http://192.168.2.250/ourcompanywebsite
/usr/share/nginx/www/firstclientwebsite
-> http://192.168.2.250/firstclientwebsite
/usr/share/nginx/www/secondclientwebsite
-> http://192.168.2.250/secondclientwebsite
/usr/share/nginx/www/sitefortestingthings
-> http://192.168.2.250/sitefortestingthings
获取该设置相当简单。事实上,我的工作很好。问题是,漂亮的永久链接不起作用。不幸的是,我对nginx了解不够,无法实现这一点。
这是我当前启用/默认的nginx站点。conf文件。请原谅任何明显的业余错误;我真的不能强调我对设置nginx知之甚少。
server {
listen 80;
listen [::]:80 default ipv6only=on;
root /usr/share/nginx/www;
index index.php index.html index.htm;
location / {
auth_basic "You shall not pass!";
auth_basic_user_file /home/mojo/src/config/nginx/htpasswd;
try_files $uri $uri/ /index.html;
}
location /doc {
root /usr/share;
autoindex on;
allow 127.0.0.1;
deny all;
}
location /images {
root /usr/share;
autoindex off;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
location ~ \\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\\.ht {
deny all;
}
}
我看过关于如何使用nginx设置永久链接的指南,但它们似乎都假设您只有一个站点,或者您的单独站点位于不同的域上。那么,我想要的设置是否可行?如果是这样的话,我需要做什么来实现它?如果不是,或者如果这是一个非常糟糕的主意,那么什么是一个类似的设置,让我有多个WordPress安装和相当长的链接?如果您有任何其他有用的建议可以改进我的配置,我们将不胜感激。
最坏的情况下,我可以回到Apache(在那里我有我想要的设置工作),但我宁愿解决这个问题。