Question
Nginx: multiple sites (including Wordpress) in multiple folders with droplet_ip/site_name as URL
Hello,
I have a LEMP droplet on which I want to host few sites. For now I have two applications: PhpMyAdmin and a Wordpress site. But my Wordpress site is stored in “/srv/www/mysite/mysite/src” and I want to access to this site via the URL “x.x.x.x/mysite” (x.x.x.x is my droplet IP of course) because I can’t use a domain name for the moment. So I tried a lot of things (with locations, aliases, root…) but none has worked. My last config file (works for PhpMyAdmin but not for “mysite”):
server {
listen 80;
listen [::]:80;
root /srv/www;
index index.php index.html;
# Hosts
server_name localhost x.x.x.x;
location / {
try_files $uri $uri/ /index.php?$args;
}
location /mysite/ {
alias /srv/www/mysite/mysite/src;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
As I said I’ve made a lot of tests and none of them has worked (there are always errors 404 and 500)… So thanks in advance for your help! :-)
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×