How to host multiple websites on Linode?
/home/deployer/apps/portfolio
I want to do something like
/home/deployer/apps
/portfolio
/otherapp
Right now I'm using a DNS for rafaelfragoso.com on the DNS tab And my Linode only have one IP address.
What changes do I need to make to host more than one website? Thanks!
5 Replies
@Vance:
If you want to have your Linode respond with different content when it is accessed by a different name (e.g., example.net), you need to set up "name-based virtual hosting." The
nginxin the Linode library discuss this. You can find additional documentation by searching on that term. guides
I'll take a look.
Add the following to the file, with the information changed for your website:
<virtualhost *:80=""># Admin email, Server Name (domain name), and any aliases
ServerAdmin webmaster@example.com
ServerName www.example.com
ServerAlias example.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /home/example_user/public/example.com/public
# Log file locations
LogLevel warn
ErrorLog /home/example_user/public/example.com/log/error.log
CustomLog /home/example_user/public/example.com/log/access.log combined</virtualhost>
Then run````
sudo a2ensite web1.example.com
and then````
sudo service apache2 restart
Repeat this process for each web server directory and website you want to create.
I have the Linode's IP address and I have my domain (rafaelfragoso.com). I have my domain configured with nginx and passenger and everything works just fine. Now that I don't need the Linode's ip address to access my website, I want to use it for a different project like this:
/home/deployer/apps/rafaelfragoso.com/ (rafaelfragoso.com)
/home/deployer/apps/beta/ (xx.xx.xx.xx Linode's ip)
How can I accomplish that?
PS: I'm not using the sites-enabled/sites-available folders.
@rafaelfragosom:
I'm using Nginx as my web server.
I have the Linode's IP address and I have my domain (rafaelfragoso.com). I have my domain configured with nginx and passenger and everything works just fine. Now that I don't need the Linode's ip address to access my website, I want to use it for a different project like this:
/home/deployer/apps/rafaelfragoso.com/ (rafaelfragoso.com) /home/deployer/apps/beta/ (xx.xx.xx.xx Linode's ip)
How can I accomplish that?
PS: I'm not using the sites-enabled/sites-available folders.
That can be accomplished by setting up a virtual host in Nginx, setting the server_name to your Linode's IP address. You'd then set the root to /home/deployer/apps/beta (or whatever you want to serve via the IP). I actually use that trick at home due to a bug in my router – I have remote management disabled, but it still displays the remote management page UNLESS I forward connections to my home server to give people a "Quit Spying On Me!" message
EDIT: Personally I think using sites-available/sites-enabled keeps things more organized, it makes it easier to enable/disable virtual hosts without deleting or moving them. Just my 1 cent.