WordPress is the most popular CMS (content management system) used on the internet today. WordPress sites can be served using a HTTP server such as Apache or NGINX, while Apache is a great option to serve websites, many sites have moved to NGINX because of it’s scalable event-driven architecture, low resources and better delivery of statics files. In this tutorial you will learn how to configure NGINX for various types of WordPress installations, including multisite configurations, rewrite rules and the use of .conf files to apply repeated configurations.
In this guide, you will need sudo to install and edit files. I assume that you have gone through the initial server setup.
You will need to install MySQL, PHP & NGINX. You can follow these guides to install LEMP on Ubuntu or Debian.
Note that our server blocks will be different & that in this tutorial we are making PHP-FPM use a UNIX Socket.
It is often recommended to set the number of NGINX workers equal the number of processors, you can determine the number of processors using:
cat /proc/cpuinfo | grep processor
Open up the main NGINX configuration file:
sudo nano /etc/nginx/nginx.conf
Increase or decrease the number of workers depending on your system’s specs:
worker_processes 1;
NGINX limits the number of connections that a worker can maintain at one time, if your websites have many visitors you might want to increase the limit of connections. In theory the maximum number of connections = workers * limit.
worker_connections 768;
Files can be compressed using Gzip to accelerate WordPress, the smaller the data size requested by the user, the faster the response. Think about CSS files & HTML files, they have many similar strings, repeated text and white spaces. Gzip uses an algorithm called DEFLATE that removes duplicate strings by linking to the previous location of that identical string and creates a much smaller file. Find the Gzip section and enable it:
gzip on;
gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
Save & exit.
Since you might be hosting more than one WordPress website, we are going to create a few .conf files that can be loaded from the server blocks instead of writing the same configuration many times on each server block.
In the next steps we will create 3 files that will hold our configurations:
We are going to create all the files in a directory called “global” but first we will need to create the mentioned directory:
sudo mkdir /etc/nginx/global
I am going to set /etc/nginx/global as the current directory just to make things easier.
cd /etc/nginx/global
Let’s create our first .conf file applicable to any kind of websites.
sudo nano common.conf
This will open an empty file, copy the following configurations:
# Global configuration file.
# ESSENTIAL : Configure Nginx Listening Port
listen 80;
# ESSENTIAL : Default file to serve. If the first file isn't found,
index index.php index.html index.htm;
# ESSENTIAL : no favicon logs
location = /favicon.ico {
log_not_found off;
access_log off;
}
# ESSENTIAL : robots.txt
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# ESSENTIAL : Configure 404 Pages
error_page 404 /404.html;
# ESSENTIAL : Configure 50x Pages
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
# SECURITY : Deny all attempts to access hidden files .abcde
location ~ /\. {
deny all;
}
# PERFORMANCE : Set expires headers for static files and turn off logging.
location ~* ^.+\.(js|css|swf|xml|txt|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires 30d;
}
listen 80;
specifies the listening port of the server.
index index.php...
specifies the default file to serve (WordPress index.php). If the first file isn’t found, the second will be used and so on. You might have HTML sites that’s why we are including index.html & index.htm;.
location = /robots.txt {allow all;}
allows the access to robots.txt, if you want to specify another directory for the robots.txt you can add an alias:
location /robots.txt {
alias /var/www/example.com/public/sample_robots.txt;
}
location ~ /\. {deny all;}
in the Linux operating system a hidden file begins with a “.”, access to some hidden files, such as .htaccess, should be blocked for security reasons.
location ~* ^.+\.(js|css|swf...
expires headers tell the browser whether they should request a specific file from the server or whether they should grab it from the browser’s cache. With expires 30d we are telling the browser to store static files such as pictures for 30 days.
Save and exit.
Let’s create a .conf file applicable to all WordPress sites:
sudo nano wordpress.conf
This will open an empty file, copy the following configurations:
# WORDPRESS : Rewrite rules, sends everything through index.php and keeps the appended query string intact
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
# SECURITY : Deny all attempts to access PHP Files in the uploads directory
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
# REQUIREMENTS : Enable PHP Support
location ~ \.php$ {
# SECURITY : Zero day Exploit Protection
try_files $uri =404;
# ENABLE : Enable PHP, listen fpm sock
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# PLUGINS : Enable Rewrite Rules for Yoast SEO SiteMap
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
#Yeah! you did it.
try_files $uri $uri/ /index.php?q=$uri&$args
rewrite rule required to allow you to choose your custom permalink structure on WordPress.
location ~* /(?:uploads|files)/.*\.php$ {deny all;}
this will prevent malicious code from being uploaded and executed from the WordPress media directory.
location ~ \.php$ {...}
since WordPress is a php site, we need to tell NGINX how to a pass our php scripts to PHP5.
try_files $uri =404;
this is a security rule, you only want to either serve a determined php file or go to a 404 error.
More Rules: You might want to add more NGINX rules, for example, if you use the same WP Plugins that require custom rules on all your installations as I do, you can add more rules in this .conf file, e.g. I use Yoast SEO on all my websites therefore I am adding the rewrite rules required here, in this way I do not have to copy the same rewrite rules for each server block.
Unlike single site WordPress, which can work with “ugly” permalinks and thus does not need any URL rewrite, a MultiSite installation requires custom rewrite rules to format URLs for your subsites. Let’s create a .conf file applicable to multisite WordPress installations:
sudo nano multisite.conf
This will open an empty file, copy the required rewrite rules:
# Rewrite rules for WordPress Multi-site.
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
Save & exit.
Our current working directory is /etc/nginx/global, if you want to change it you can type:
cd /desired_directory
It is time to create our first server block. Since we already have everything configured in our .conf files there is no need to duplicate the default server block file. Let’s disable the default server block:
sudo rm /etc/nginx/sites-enabled/default
And create a server block file:
sudo nano /etc/nginx/sites-available/demo
This will open an empty file, copy the following configurations depending on what you want to achieve:
Imagine that you want to configure a WordPress site with this domain www.demo.com. First we will have to create a server block server {...}
where we will put our rules. We have to specify which server block is used for a given URL, include common.conf & wordpress.conf and finally we will tell NGINX the location of the WordPress installation in our server.
server {
# URL: Correct way to redirect URL's
server_name demo.com;
rewrite ^/(.*)$ http://www.demo.com/$1 permanent;
}
server {
server_name www.demo.com;
root /home/demouser/sitedir;
access_log /var/log/nginx/www.demo.com.access.log;
error_log /var/log/nginx/www.demo.com.error.log;
include global/common.conf;
include global/wordpress.conf;
}
Remember to change the following data to fit your needs:
You can see that there are two server blocks, that’s because www.demo.com & demo.com are different URLs. You probably want to make sure that Google, Bing, users…etc pick the URL that you want, in this case I want my website to be www.demo.com so I have configured a permanent redirect from demo.com to www.demo.com. It is also possible to specify multiple domains:
server {
# URL: Correct way to redirect URL's
server_name demo.com sub.demo.com example.com;
If you want a multisite installation with subdirectories you will need to include the rewrite rules stored in multisite.conf:
# URL: add a permanent redirect if required.
server {
server_name www.demo1.com;
root /home/demouser/sitedir1;
access_log /var/log/nginx/www.demo1.com.access.log;
error_log /var/log/nginx/www.demo1.com.error.log;
include global/common.conf;
include global/wordpress.conf;
include global/multisite.conf;
}
If you want a multisite installation with subdomains you will need to configure this server block to listen to a domain with a wildcard:
server {
server_name *.demo2.com;
root /home/demouser/sitedir2;
access_log /var/log/nginx/demo2.com.access.log;
error_log /var/log/nginx/demo2.com.error.log;
include global/common.conf;
include global/wordpress.conf;
}
If you want to host simple html websites or other webapps you might need to specify custom rules or create more .conf files and include them in the server block:
# URL: add a permanent redirect if required.
server {
server_name www.demo3.com;
root /home/demouser/sitedir3;
access_log /var/log/nginx/demo3.com.access.log;
error_log /var/log/nginx/demo3.com.error.log;
# custom rules
}
Remember to save & exit.
The last step is to activate the host by creating a symbolic link between the sites-available directory and the sites-enabled directory:
sudo ln -s /etc/nginx/sites-available/demo /etc/nginx/sites-enabled/demo
We’ve made a lot of the changes to the configuration. Reload NGINX and make the changes visible.
sudo service nginx reload;
To create additional virtual hosts, you can just repeat the process above, being careful to set up a new document root with the appropriate new domain name each time. It is also possible to combine multiple server blocks in just one file:
server {
server_name demo.com;
rewrite ^/(.*)$ http://www.demo.com/$1 permanent;
}
server {
server_name www.demo.com;
root /home/demouser/sitedir;
access_log /var/log/nginx/www.demo.com.access.log;
error_log /var/log/nginx/www.demo.com.error.log;
include global/common.conf;
include global/wordpress.conf;
}
server {
server_name www.demo1.com;
root /home/demouser/sitedir1;
access_log /var/log/nginx/www.demo1.com.access.log;
error_log /var/log/nginx/www.demo1.com.error.log;
include global/common.conf;
include global/wordpress.conf;
include global/multisite.conf;
}
# More server blocks....
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Nice write up. I suggest though instead of:
rewrite ^/(.*)$ http://www.demo.com/$1 permanent;
you use:
return 301 $scheme://www.demo.com$request_uri;
A return is quicker than a rewrite, and $scheme is protocol-independent.
Thank you for your review.
Yes, you are right, I did not consider a return (which seems to be regarded as being faster)
Does this assume that Wordpress is already installed? I’m having trouble understanding the order in which to follow the tutorials. I think I should follow:
Correct?
Remember to configure your DNS to fit your subdomains or with a wildcard (*)
Thanks! I got it running!
Thanks for the excellent write-up! I did everything as you described and it went smoothly but now im wondering if i need an unique ip for each simple wordpress installation. I want to have 5 separated wordpress blogs, each with its own database and wordpress installation files but i dont know if for each server_name i should use a different ip and then use domain mapping. Thats the only thing im not fully understanding. Any help appreciated!
@stk.walshy: server_name should be the blog’s domain name. You don’t need one ip per blog :]
@stk.walshy
You can have multiple domains pointing to an unique IP (your server’s IP) NGINX can serve different “folders (root)” depending on the “domain (server_name)” :
For example,
let’s say that we have domain1.com domain2.com domain3.com domain4.com & domain5.com
Suppose that you want to host them in one of your digitalocean servers
You will need to create 5 Databases
Extract WordPress (Five times since you have 5 blogs) & add the required permissions: a.) /home/demouser/sitedir1;
b.) /home/demouser/sitedir2; c.) /home/demouser/sitedir3; d.) /home/demouser/sitedir4; e.) /home/demouser/sitedir5;
Remember to edit wp-config.php
Configure NGINX so that it knows which folders to serve depending on the domain. You will need to create 5 server blocks and edit server_name & root: server { … server_name domain1.com; root /home/demouser/sitedir1; … } server { … server_name domain2.com; root /home/demouser/sitedir2; … }
Remember to configure your DNS If you have any questions, please feel free to ask.
I followed your steps to install two wordpress sites and a static html website. But its not working.
So I initiated a question for the same and followed the steps as discussed here I failed also.
Again I followed the steps mentioned in another tutorial but failed again. Please help me out of this situation.
hi @santiagotic, I’m having a hard time figuring out this with 2 wordpress with 2 different domains. example1.com, example2.com. I don’t know what might be wrong with my databases, I get a database error when I enter the website to configure the wordpress. Is there a more detailed tutorial?
I must have transposed something and am getting a ‘this page is not redirecting properly’. Any clue where I can start troubleshooting?
I managed to find an error message but cannot see in any of the modified files where I’ve snafu’d: 2014/01/14 12:55:19 [warn] 3456#0: conflicting server name “162.243.236.35” on 0.0.0.0:80, ignored
Any help is appreciated.
@bristond: <strong>conflicting server name</strong> means that there is more than one virtualhost with its server_name set to 162.243.236.35. <pre>grep -r ‘162.243.236.35’ /etc/nginx</pre> That should tell you which files have “162.243.236.35” in them.
Can anybody help me to setup phpmyadmin in a secure way using this method. I love this tutorial very much. It is great. I have searched lot of tutorials on Internet but this seems perfect for wordpress installation. Now I hhave only one doubt. I want to install phpmyadmin in a secure way as mentioned in http://deanbarrow.co.uk/the-quick-and-easy-way-to-secure-phpmyadmin/ I love to use phpmyadmin throug ssh tunnel. I fountd the tutorial by deanbarrow very helpful but unable to setup server block. Plese help me with required setup.
I screwed up. I was putting two different WordPress websites on one server. After I successfully installed the first WP site, I went on to the second one. I copied the first server-block file to use as a template for the second website. I edited the server-block but forgot to change the non-www to www 301 redirect line before saving the file and testing the domain in Chrome. So now when I go to the second domain redirects to my first. I’ve tried deleting browser cache but that doesn’t work. It redirects in all browsers and devices. Has my ISP cached the redirect? Any advice?
Finally got it working. I just removed both /sites-enabled files and created them again. I honestly felt like I had done this multiple times, but this time it worked.
@alikkalfizal: Check out <a href=“https://www.digitalocean.com/community/articles/how-to-install-phpmyadmin-on-a-lemp-server/”>https://www.digitalocean.com/community/articles/how-to-install-phpmyadmin-on-a-lemp-server/</a>.
Good! But i have one doubt. Can i have multiple installations in subdirectories?
Example:
server_name should be what?
Santigo, Great tutorial sir!! I have been an Apache user for so long now that I feared taking the leap into the Nginx world. This mainly had to do with having a solid workflow and so many habits. This tutorial made that leap so smooth and I was able to get the test server and production both up and running without a hitch.
These steps in the comments were nice as well -->
Remember to configure your DNS to fit your subdomains or with a wildcard (*)
Thank You!!! NateL
I have quite similar question / setup to do like Rodrigo
but i need
1 wordpress installation for servername/
1 wordpress installation for
servername/blog
they should be seperate / no multisite
As soon as I add the required multisite lines to wp-config.php, I get a redirect loop.
I wonder if anyone has this working with Wordpress 3.9. Anyone? If yes, did you do it following this tutorial?
@Rick upload your nginx settings to somewhere like pastebin so that I can take a look. Also, upload the multisite lines (DO NOT UPLOAD YOUR PASSWORDS)
Thanks so much for this tutorial! I’m using Ubuntu 14.04 (64), and I followed all of this, but Nginx keeps failing when I try to reload it. Here is my /etc/nginx/sites-available/demo file for a WordPress Multisite with subdomains site:
server { # URL: Correct way to redirect URL’s server_name mydomain.com; rewrite ^/(.*)$ http://www.mydomain.com/$1 permanent; } server { server_name www.mydomain.com; root /usr/share/nginx/html; access_log /var/log/nginx/www.mydomain.com.access.log; error_log /var/log/nginx/www.mydomain.com.error.log; include global/common.conf; include global/wordpress.conf; } server { server_name *.mydomain.com; root /usr/share/nginx/html; access_log /var/log/nginx/www.mydomain.com.access.log; error_log /var/log/nginx/www.mydomain.com.error.log; include global/common.conf; include global/wordpress.conf; }
When I try to sudo service nginx reload, I get this:
Any thoughts? Thanks so much in advance!
@jacobgerber: Could you post the error message from the log files? Check: /var/log/nginx/error.log
@Andrew SB: Thanks so much for the tip! The error log told me exactly what was wrong, and I was able to get everything to work. For other people, here was the error message:
2014/05/14 11:32:47 [emerg] 22529#0: could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
I just went into my /etc/nginx/nginx.conf and uncommented the server_names_hash_bucket_size setting.
I have it at 64 now, and Nginx reloads. Do you think it ought to be higher for any reason, or is really the only thing to make sure that Nginx works?
Just FYI for the community:
I was trying to use a domain mapping plugin to map individual domain names to the subsites of my multisite installation, and the mapped domain names were 301 redirecting to the main domain of my multisite.
I got some help from WPMU DEV (I was using their plugin), and they pointed out that I needed a wildcard for my server_name setting to get it to work correctly.
So, instead of this:
server { listen 127.0.0.1:8080; server_name mydomain.com; # This is the problematic line for domain mapping root /var/www; access_log /var/log/nginx/mydomain.com.access.log; error_log /var/log/nginx/mydomain.com.error.log; include global/common.conf; include global/wordpress.conf; }
I needed this:
server { listen 127.0.0.1:8080; server_name $uri /$uri /index.php; # Updated, wildcard line root /var/www; access_log /var/log/nginx/mydomain.com.access.log; error_log /var/log/nginx/mydomain.com.error.log; include global/common.conf; include global/wordpress.conf; }
That fixed the problem.
Here’s a note on this issue from Stack Overflow:
http://stackoverflow.com/questions/9454764/nginx-server-name-wildcard-or-catch-all/9454825#9454825
@jacobgerber: That doesn’t look right. server_name should be set to _, <code>$uri /$uri /index.php</code> is for the <code>try_files</code> directive.
Please advise, I have following this tutorial;
i have two wordpress site, I can open first site, but when i access second site its opening same content with first site. even i access my_IP/phpmyadmin wil redirect to fist site.
Server block here :
server { server_name www.solusihotspot.com; root /home/nada/solusihotspot; access_log /var/log/nginx/www.solusihotspot.com.access.log; error_log /var/log/nginx/www.solusihotspot.com.error.log; include global/common.conf; include global/wordpress.conf; include global/multisite.conf; }
server { server_name www.airfreightsolution.com; root /home/nada/airfreight; access_log /var/log/nginx/www.airfreightsolution.com.access.log; error_log /var/log/nginx/www.airfreightsolution.com.error.log; include global/common.conf; include global/wordpress.conf; include global/multisite.conf; }
My droplet IP 128.199.229.209, fist site www.solusihotspot.com, second site www.airfreightsolution.com
i have try to separate each server block but the result are same. can you help me solving this problem ???
thx
@nada.sumbang: Did you remember to remove <code>/etc/nginx/sites-enabled/default</code> ?
@Andrew SB
Yes, it was removed. I just using my own server block. Is it possible that DNS setting caused this problem ?
airfreightsolution.com : A record @ 128.199.229.209 solusihotspot.com : A record @ 128.199.229.209
Thx
@nada.sumbang: Try replacing <pre>server_name www.solusihotspot.com;</pre>with<pre>server_name www.solusihotspot.com solusihotspot.com;</pre>and<pre>server_name www.airfreightsolution.com;</pre>with<pre>server_name www.airfreightsolution.com airfreightsolution.com;</pre>
@kamal Nasser
Great… its works. Problem solved. Thank You Kamal.
Does anybody know how to set something like this up, but instead of different blocks for websites, there would be different blocks for rtmp configurations and profiles?
I had a LEMP stack configured and phpmyadmin installed and configured. Then I configured the server blocks to create a virtual server to host multiple sites on the server. This is when I lost access to phpmyadmin via the url (domain.com/phpmyadmin). Now all that it returns is a 404 error. What is the best way to overcome this and gain access again?
I had originally setup phpmyadmin using this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-with-nginx-on-an-ubuntu-14-04-server
Hi,
Great tutorial. Everything works fine on the Debian distro. I must only add:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
in global/wordpress file in the location
~\.php$ {
section.Maybe is there a little difference in the Linux distro i use.
Thanks
Berto van Oorsptonk
Hello Santiago, Please where do I put details of my SSL? Do I need another server block inside the /global directory or another directory?
In the server block “Multisite with Subdomains” why i don’t need this line “include global/multisite.conf;” ??
Isn’t necessary to multisite?
I am having a Blank page when i visit my IP with nginx 1.6.2
Here’s what is in my log
How did you install NGINX? repo or compiled?
Initially i installed the LEMP stack with ubuntu via DO, then try to upgrade nginx server from 1.4 to 1.6, it keeps giving me problem. Seems i will have to try with 1.4 and hopefully this https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-with-nginx-on-an-ubuntu-14-04-server might work
There are many points of failures that might arise if you are compiling it by yourself or getting it from a third party repo. Without knowing your environment it’s impossible to diagnose the problem.
Regards, Santiago
Alright, let me try again with the default
Hello Santiago, thanks for the great post!
I am setting up a WP multisite (with subdomain) using another digital ocean tutorial at https://www.digitalocean.com/community/tutorials/how-to-set-up-wordpress-multisite-with-nginx-on-ubuntu-14-04, and adapted your configuration file.
Now I’d like to add and force SSL for my primary domain (example.com), and for other multiple sites too.
How to configure the SSL redirections for other sites then?
I am using “WordPress MU Domain Mapping plugin” to do the domain mapping, and currently have the following setup on a single droplet: primary domain: example.com sub-domains: shopping1.example.com -----> shopping1.com sub-domains: shopping2.example.com -----> shopping2.com
Thanks,
Thank you, I followed all the way for my first installation. And it worked perfectly.
My problem is now when I imported a new wordpress installation and try to have both server block files enabled. The second one doesn’t work.
If I try to access the domain it just says me:
Any ideas?
This new site is a multisite with subdomains.
And, by the way, is it right the configuration for subdomains WITHOUT the line
Or should it be there? Anyways, it doesn’t work yet.
How to create like this - http://178.62.202.230/ <-- This is my droplets IP and root directory is /var/www/html/mli.lv/htdocs
And use like - http://178.62.202.230/wordpressite1 http://178.62.202.230/wordpressite2 http://178.62.202.230/wordpressite3 etc.
And root is /var/www/html/mli.lv/htdocs/wordpressite1/htdocs etc.
And all those sites have different database. ? Help.
I’m very new to this level of setting up a server, so I appreciate any help in advance, although I would consider myself an amateur ubuntu user, not brand new.
I went through these steps, like others I would like to start with two wordpress installations on one droplet.
Starting with my domain name mccawleydigital.com this is how I set up my server block at /etc/nginx/sites-available/mccawley
server { # URL: Correct way to redirect URL’s server_name mccawleydigital.com; rewrite ^/(.*)$ http://www.mccawleydigital.com/$1 permanent; } server { server_name www.mccawleydigital.com; root /home/mccawley/mccawley-digital; access_log /var/log/nginx/www.mccawleydigital.com.access.log; error_log /var/log/nginx/www.mccawleydigital.com.error.log; include global/common.conf; include global/wordpress.conf; }
When I ping my domain name, my droplet IP address appears. My IP in a web browser shows the NGINX is working message, but when I try to go to mccawleydigital.com in a web browser - server not found. I’ve gone over and over the tutorial, can someone help me with the next step of troubleshooting?
There is a misconfiguration in your vhost.
You should use one server block, as: server {
URL: Correct way to redirect URL’s
servername mccawleydigital.com www.mccawleydigital.com; root /home/mccawley/mccawley-digital; accesslog /var/log/nginx/www.mccawleydigital.com.access.log; errorlog /var/log/nginx/www.mccawleydigital.com.error.log; include global/common.conf; include global/wordpress.conf;
rewrite ^/(.*)$ http://www.mccawleydigital.com/$1 permanent; }
I want to run several WP sites in my vps.
So far I made running the first one, but now, when I try to get to the second domain (with or without www), it just redirect me to my server index page (the one where you see Welcome to Nginx).
This is the server block that I’m using:
So the first site works perfectly. I removed the default block server also…could be a DNS configuration problem?
This comment has been deleted
how to make a few sites with multiple Wordpress?
I am not able to get this to work with just one wordpress site. Eventually I want to have 2 Wordpress sites on 2 different directories on the same server. I included all 3
.conf
fileswordress.conf
common.conf
&multisite.conf
just like it says in the tutorial.My file in
/etc/nginx/sites-enabled/mysite
that is symlinked from/etc/nginx/sites-available/mysite
When I visit my site URL I just get a
web page not available
I configured the
wp-config.php
file as well. Created my MySQL user and made sure the user has access to the database. Also changed the permissions of/var/www/mysite
withchmod -R 755 .
And I have nothing on my logs: No
/var/log/nginx/www.mysite.com.access.log
nor/var/log/nginx/www.mysite.com.error.log
files have been created. Thanks for the help.I created this tutorial using debian two years ago. Configurations might have changed (If I find some time I will check and republish the config files). I recommend you to understand the tutorial and modify the default config files that come with your distribution instead of just copying and pasting.
Typical troubleshooting questions: Have you configured php-fpm? Have you tried uploading a info.php file?
Ubuntu or Debian? Version?
Sorry, I forgot to include some additional information.
I installed it on Ubuntu 14.04 LTS. I did configure php5-fpm
And I do have a simple php file in the directory to test:
Since I dont see anything in the access logs for nginx, could it be a DNS issue?
I followed your guide and all has appeared to be fine, however I have a strange issue whereby the URL’s for internal notification links do not include /network/. Therefore when clicking on them to say install a required plugin, visit a configuration page, activate a plugin etc. I will get a message similar to “You do not have sufficient permissions to access this page.”
Now I know this is not a plugin conflict (everything disabled, uninstalled including themes and different plugin/themes attempted, same issue occurs). I cannot see any viable way it could be a wordpress configuration issue and it certainly is not a privileges problem (as it clearly is the “/network/” part of the URL path that is missing). So I’m guessing it is an nginx routing issue, but I truly cannot find the source, or am I looking in the wrong place?
excellent, everything works … my wordpress ta perfectly in the air. but I have 4 more domains in the air aimed at the servers names of digital ocean, all of them when I type in the browser, always carries the same site, always my only installation … which install more web and how do I each loading up different facilities wordpress?
Hi folks,
Great tutorial, it has worked fine for me until I’ve tried to set up Multisite.
Here’s my situation:
I’m deploying a sub-domain Multisite installation that I have been working on locally using XAMPP (note Apache). My URL structure is as follows:
I have deployed my code and amended wp-config.php (that was originally set-up to be compatible with Apache) and replaced domain.dev with domain.com here:
define('DOMAIN_CURRENT_SITE', 'domain.com');
I have amended all
wp_*_options
,wp_options
,wp_site
and any other tables I deemed important with the amended domain.com domain.I have configured nginx as follows:
Note that I am wanting to redirect any www requests to domain.com
Finally, I have configured my local hosts file to read as follows:
When I attempt any domain I am redirected to another WordPress (not multisite) site on my server, namely the first site in the list in
sites-available
As far as I can tell I have followed everything laid out in this tutorial but unfortunately not getting anywhere!
Oh and my nginx error logs are barren!
Any ideas, anyone?
Much appreciated :)
Thank you for this Tutorial @SantiagoTi .
I am a beginner and have a question. Under the “Creating Server Blocks” area:
Wouldn’t ‘sudo nano /etc/nginx/sites-available/demo’ be trying to write server block code into a directory?
I am using CentOS7, so maybe the installation root is different. Is it normal to write configuration to a directory in Ubuntu?
Thank you for your time.
Really nice guide, less files and more power :D
When I run
cat /proc/cpuinfo | grep processor
, I get ‘0’ processor. In this case, do I need to change toworker_processes 0;
in ```/etc/nginx/nginx.conf````?I’ve changed the wordpress.conf file because a blank page in wordpress.
replacing
with