How can i have multiple wordpress installs with LEMP?

December 24, 2015 1.6k views
WordPress Nginx LEMP PHP

Hello ,

I was wondering if it is possible to have multiple wordpress installs
all seperate for each domain with Nginx?

I did find a tutorial for multiple installs and multisite.
but i could find it for seperate and LEMP installs.

thanks
Dieter

1 Answer

yes it is possible. I would recommend at least the 2GB droplet if you are planning on more than 3 or 4. Just separate each domain.conf and document root. I run multiple sites on multiple droplets all with Nginx and WordPress.

  • Hi thanks for your awnser

    I am stuck with the conf i cant get it to work can you give me an example of your conf file?

    Thanks
    Dieter

    • I am using CentOS 7 for my installs, i don't use Ubuntu so i can't speak for its configuration. I use a script that i have written to automate the setup of WordPress and deploy Nginx confs as well as setup mysql db. My script is on github for CentOS 6 and it is beta for CentOS 7, if you are running those it will help you out but if you are running Ubuntu i would suggest looking at rtCamp scripts for WordPress.

      My directory structure always looks like this /var/www/$DOMAIN/htdocs with WordPress install inside of htdocs and wp-config.php moved to /var/www/$DOMAIN/.

      domain 1 WordPress - copied and pasted from working server

      server {
      
              server_name domain1.com www.domain1.com;
      
              access_log   /var/log/nginx/domain1.com.access.log;
              error_log    /var/log/nginx/domain1.com.error.log;
      
              root /var/www/domain1.com/htdocs;
              index index.php index.htm index.html;
      
              location / {
                      try_files $uri $uri/ /index.php?$args;
              }
              location ~ /fpm/status/(.*) {
              include fastcgi_params;
              fastcgi_param  SCRIPT_NAME  /status;
              fastcgi_pass $1;
              }
      
              location ~ \.php$ {
                      root /var/www/domain1.com/htdocs;
              fastcgi_pass   127.0.0.1:9000;
              fastcgi_index  index.php;
              fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
              include        fastcgi_params;
              }
      
      
      }
      

      domain 2 WordPress - copied and pasted from working server

      server {
      
              server_name domain2.com www.domain2.com;
      
              access_log   /var/log/nginx/domain2.com.access.log;
              error_log    /var/log/nginx/domain2.com.error.log;
      
              root /var/www/domain2.com/htdocs;
              index index.php index.htm index.html;
      
              location / {
                      try_files $uri $uri/ /index.php?$args;
              }
              location ~ /fpm/status/(.*) {
              include fastcgi_params;
              fastcgi_param  SCRIPT_NAME  /status;
              fastcgi_pass $1;
              }
      
              location ~ \.php$ {
                      root /var/www/domain2.com/htdocs;
              fastcgi_pass   127.0.0.1:9000;
              fastcgi_index  index.php;
              fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
              include        fastcgi_params;
              }
      
      
      }
      
      • is the fastcgi parts necessary ?

        I will take a look at easy engine scripts , but then you basically install a control panel if i am correct ?

        thanks for the help :-)
        i am going to retry setting up a server , install LEMP and retry with a domain i have left with no use.

        currently i am using Serverpilot , any thoughts on that?

        • If you are using PHP-FPM then it is necessary.

          Easy Engine does install alot of bloat but it does do most configuration for you on Ubuntu.

          If you aren't in a crunch for time then it would best to learn how it all works together and install it yourself.

          I am not familiar with Serverpilot since i don't use Ubuntu, but service looks nice.

          • i think i will need PHP-FPM , so it states in the Setup guide.
            i will try around with the installs and see when i get to a problem.
            once i have the Conf file i will post it here so if you can you can check it.

            also i was talking to ServerPilot about Memory , i currently have 3 sites installed on my 512 RAM droplet.

            i used the command free -m and gave me the following :

                         total       used       free     shared    buffers     cached
            Mem:           490        445         44         49         64        137
            -/+ buffers/cache:        243        246
            Swap:          511         40        471
            

            He told me because there was 40 in the swap i needed to upgrade my droplet but then i see i have still 246 left of my ram if i am correct.

            i don't get have traffic to these sites and all still remains smooth.
            possible to add another site or should i follow and upgrade?

            Thanks
            Dieter

Have another answer? Share your knowledge.