I'm trying to set up a new local development server and instead of Apache I've decided to go with nginx.
What I'd like to do is have each WordPress site live within its own directory inside /usr/share/nginx/www
. The sites are only going to available on our local network. So for example:
/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
Getting that setup is fairly trivial. In fact, I've got it working just fine. The problem is that pretty permalinks do not work. Unfortunately I don't know enough about nginx to make this happen.
Here's my current nginx sites-enabled/default.conf file. Please excuse any obvious amateur mistakes; I really cannot stress how little I know about setting up 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;
}
}
I've seen guides on how to setup pretty permalinks with nginx but they all seem to assume that you'll just have one site or that your separate sites are on separate domains.
So, is the setup I want possible? If so, what do I need to do to make it happen? If not, or if it's a really bad idea, then what is a similar setup that lets me have multiple WordPress installs with pretty permalinks? Any other useful tips that might improve my configuration are appreciated.
Worst case scenario I can go back to Apache (where I had my desired setup working), but I'd rather figure this out.
try_files $uri $uri/ /index.html;
should betry_files $uri $uri/ /index.php;
for any traditional WordPress setups.