Few years before I was very confused on how the applications are being deployed and port numbers are configured. It looks like a magic. But for the Sys Ops Engineer it is a simple task.
Then I learned myself the procedure and like to share with you. In this post, let’s assume we have PHP project which needs to be deployed. I am using Ubuntu OS, so the example is based on that.
I am having now the directory
Moving my project directory to the location /var/www/html and it is now like,
Now as the second step, Go to /etc/apache2/
Open the file ports.conf and add the following line under Listen 80. Please note that 80 is the default port for apache webserver. Now without disturbing 80, we are now gonna add our new port 6061
Save the file ports.conf and go to the directory /etc/apache2/sites-available
Now create our project configuration file. I am having “myproj.conf”
Open myproj.conf file and add the following VirtualHost settings in it.
DirectoryIndex index.php index.cgi index.html
Options Indexes FollowSymLinks
Require all granted
Points to note here are,
- You need to give your IP address to the ServerName
- DirectoryIndex has by default index.php or index.cgi or index.html file as landing page. If you want to display home.php as front page, include that at the beginning of index.php and remove the rest of of files specified there.
- Require all granted grants full permission to avoid Permission denied error.
Now create symlink inside the directory /etc/apache2/sites-enabled through terminal. Go to the path and give below command
sudo ln -s /etc/apache2/sites-available/myproj.conf myproj.conf
Now do restart the apache
sudo service apache2 restart
Open your browser, type localhost:6061