jasjitsm
By:
jasjitsm

Can I host both Wordpress and non-Wordpress sites on the same VPS?

July 17, 2015 3.4k views
CMS WordPress DigitalOcean Getting Started

I am a front end designer and I have very little experience with how to host a website. I somehow stumbled through the console and FTP clients and got a few websites up and running but I want to create a proper infrastructure so I can easily get my sites up in the future.

Anyways, my question is, (how) can I host multiple websites with different and/or no CMS on one server?

2 comments
  • Instead of spending time on learning about servers you could try ServerPilot which installs with a single command and lets you manage websites from a web interface.

  • Thanks jesin! Checked it out, saw a couple videos. Seems incredibly intuitive, fast and organised. Will definitely give it a shot. :)

6 Answers

Hello and welcome to DigitalOcean.

You can host different websites on one Droplet.

I need more information to help you.

  1. What is your OS e.g. Ubuntu, Debian, CentOS ?
  2. What Webserver do you use, e.g. Nginx, Apache ?
  3. Should these Websites be on different Domain Names ?
  • Hi eldin, thanks for your reply.

    I know little of the differences between the technologies you mentioned (I was using Ubuntu and Apache so far) and since I'm looking to do a fresh server install, I'll go with whatever you and the community would recommend for now. i.e. Whatever solution/combination successfully suits the purpose of hosting multiple sites as I'd mentioned. I have no personal preference.

    Although yes, each website should be on a different domain name.

    Thanks.

So here you go. We are going to use Ubuntu and Nginx

Install the Software
sudo apt-get update
sudo apt-get install mysql-server php5-mysql nginx php5-fpm
File Structure
mkdir /var/www/html/domain1
mkdir /var/www/html/domain2
Nginx Configuration

Domain1

sudo nano /etc/nginx/sites-available/domain1

Copy and paste this

server {
        listen   80;


        root /var/www/html/domain1;
        index index.php index.html index.htm;

        server_name example.com;

        location / {
                try_files $uri $uri/ /index.html;
        }

        # pass the PHP scripts to FastCGI server listening on the php-fpm socket
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;

        }

}

save it

Domain2

sudo nano /etc/nginx/sites-available/domain2
server {
        listen   80;


        root /var/www/html/domain2;
        index index.php index.html index.htm;

        server_name example.com;

        location / {
                try_files $uri $uri/ /index.html;
        }

        # pass the PHP scripts to FastCGI server listening on the php-fpm socket
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;

        }

}

save it

The last Step
sudo ln -s /etc/nginx/sites-available/domain1 /etc/nginx/sites-enabled/
sudo ln -s /etc/nginx/sites-available/domain2 /etc/nginx/sites-enabled/

Why Nginx ?

  • It is much faster
  • Easy to manage

PS: If it works click that hearth to show me some love

  • Thanks! I'll try it out as soon as I get home. Looking at the commands it seems quite intuitive. I just had a couple questions:-

    1. How would I get the different domains to point to each site? Just add multiple rules to the same server IP and let "server_name example.com;" take care of it?
    2. Going back to the original question, can I now install Wordpress for one these two sites?

@jasjitsm

  1. You don't need to create rules, "server_name example.com;" is enough.

  2. Just download and extract WordPress. Create a MySQL Database. Open your Browser (with Domain !!!) and follow the Installation Guide.

PS: If you don't know how to create a MySQL Database just ask and I create a Tutorial (complete install of WordPress) for you (with Pictures)

  • I'd really appreciate if you could make a tutorial. :) Completely new at this.

Hello,

I created a Tutorial.

Just one note, I wanted to make it easy as possible, so 99% are just Pictures :-).

The Tutorial. 36h available :-(

If you want, i may create a snapshot and transfer it to you. I just need your E-Mail address.
It is even possible to create a text-version or video if you want

  • Wow, that is very detailed. Thank you so much! :)

    I downloaded the tutorial file from the link you sent, no need to create a snapshot. :)

  • Hi eldin,

    So I followed your steps exactly and got to the "Welcome to nginx on Ubuntu" screen which means nginx is working. But after downloading Wordpress sucessfully, unzipping it, moving it, and setting up the database, I get this error when trying to access wp-admin: "500 Internal Server Error". I didn't get any errors during the process. I thought maybe I'd done something wrong so I wiped the server and started from fresh again but I got the same issue. Any idea what could be the problem?

    Thanks

@jasjitsm I am so sorry. Maybe my Tutorial was a bit confusing. So I decided to create a new one. The new one has a better style and is much easier to understand as it are just pictures with a better resolution (step by step). Now you just need to type the same commands as I have done.

Download the Tutorial (.zip file)

  • Thanks again eldin. It worked perfectly. Got both domains set up and pointing to each website correctly as well. :)

Well, though it is been answered in quiet a bit of a detail, just wanted to add, that a VPS is meant for this purpose. You can host an array of different CMSes on the same server with just a restriction of resources like CPU, RAM & Disk Space vis-a-vis your visitors to these sites :)

--
Regards
Saurabh

Servopia.com
Managed Cloud Hosting For PHP Applications

  • Thanks for the tip Saurabh. :)

    This thread has gotten me quite interested in learning more about server technologies. I avoided it throughout college and stuck to designing and scripting but now I think I should delve a little deeper. ;)

Have another answer? Share your knowledge.