Here we will talk about how we can install and configure in Linux. we will deploy a site and will access it with DNS
Install Apache on Linux
To install Apache on Linux run following command step by step
sudo apt update
sudo apt update
sudo apt install apache2
now check apache is running or not to check you can run.(if the status is running then fine and apache installed and running successfully)
sudo systemctl status apache2
But if your apache status not running then for this you must need to enable and start it, by using following commands you can eamable and start appache2
Enable
sudo systemctl enable apache2
sudo systemctl start apache2
now hit 127.0.0.1 in browser and if it load the following page then its working fine
Deploy Website on DNS
Create VirtualHost
go to site-available folder for this you can do
cd /etc/apache2/sites-available
create here one more file to create virtual host for your site to create file your can run following command . this command will create file and will open your file in editor. after pasting following code in your file click esc button and then :wq your file will be saved
sudo vim leran-test.conf
now add following code in this file
<VirtualHost *:80>
ServerAdmin test@test
DocumentRoot /var/www/test
ServerName learn.test
ServerAlias www.learn.test
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
- serverAdmin could be your server Eamil
- DocumentRoot : add the path of your website's index page. (the site that i want to deploy is stored on /var/www/test. ) in you case verify your site directory path
- ServerName: add domain name with out www
- ServerAlias: add domain name with www
Register your site in Hosts file
sudo ifconfig
cd / cd etc sudo vim hosts
sudo a2ensite learn-test.conf // its your virtual host file name
sudo systemctl reload apache2 // it will reload appache service
So We have deployed website successfully
Thanks
0 comments: