In this video we review the steps required to host multiple websites on a LAMP stack using Ubuntu Server 18.04.
This guide is intended for a local network but can be expanded upon for internet access so long as security measures like firewalls and such are in place. After following this tutorial on your Ubuntu server you will, from within your local area network (LAN), be able to create sub-folders for each web root. This is a nice local development space. More advanced users may prefer to configure the Apache virtual hosts file and manage DNS but for a local dev environment, this works well.
Prerequisites:
- You have an Ubuntu server built and patched as a LAMP stack and ssh(optional) installed.
In this video we use the following commands:
Create a sub directory in the web root on the server:
sudo mkdir /var/www/html/joomla
sudo mkdir /var/www/html/wordpress
Create the index's
sudo touch /var/www/html/joomla/index.html
sudo touch /var/www/html/wordpress/index.html
then set permissions, files should be 664, folders should be 775 and the owner and group should be www-data.<YOUR SERVER USER>(administrator in my demo)
sudo chown -R www-data.administrator /var/www/html
sudo chmod -R 775 /var/www/html
sudo chmod -R 664 /var/www/html/<OPTIONAL_FOLDER>/<FILEMAME> (ie: joomla/index.html)
Populate the index for joomla
sudo echo '<!DOCTYPE html>
<head>
<title>Joomla test</title>
<style>
body {background-color: black;}
h1 {color: yellow;}
p {color: white;}
</style>
</head>
<body>
<center>
<h1>It Works!!!</h1>
<p>
If you see this page you have been successful with the Joomla test!!!
</p>
</center>
</body>
</html>' >> /var/www/html/joomla/index.html
then for wordpress
sudo echo '<!DOCTYPE html>
<head>
<title>Wordpress test</title>
<style>
body {background-color: black;}
h1 {color: yellow;}
p {color: white;}
</style>
</head>
<body>
<center>
<h1>It Works!!!</h1>
<p>
If you see this page you have been successful with the Wordpress test!!!
</p>
</center>
</body>
</html>' >> /var/www/html/wordpress/index.html
In a web browser you can access the site at:
For the Joomla test
http://server-host-ip-or-name/joomla
For the Wordpress test
http://server-host-ip-or-name/wordpress
For access from outside the LAN you will need a domain name or static IP as well as properly configured DNS and firewall ports.