How To Install the Apache Web Server on Ubuntu Server 20.10
How To Install the Apache Web Server on Ubuntu Server 20.10 :-
sudo apt update
sudo apt install apache2
sudo ufw allow 'Apache' (Adjusting the Firewall)
sudo systemctl status apache2
http://your_server_ip
Setting Up Virtual Hosts (Recommended)
Create the directory for aryanchoudhary:
sudo mkdir /var/www/aryanchoudhary
Assign ownership of the directory:
sudo chown -R $USER:$USER /var/www/aryanchoudhary
The permissions of your web roots should be correct if you haven’t modified your unmask value, but you can make sure by typing:
sudo chmod -R 755 /var/www/aryanchoudhary
Create a sample index.html page using nano or your favorite editor:
nano /var/www/aryanchoudhary/index.html
Inside, add the following sample HTML:
<html>
<head>
<title>Welcome to aryanchoudhary!</title>
</head>
<body>
<h1>Success! The aryanchoudhary virtual host is working!</h1>
</body>
</html>
Save and close the file when you are finished.
Make a new virtual host file at /etc/apache2/sites-available/aryanchoudhary.conf:
sudo nano /etc/apache2/sites-available/aryanchoudhary.conf
Paste in the following configuration block, updated for our new directory and domain name:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName aryanchoudhary
ServerAlias aryanchoudhary
DocumentRoot /var/www/aryanchoudhary
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Save and close the file when you are finished.
Enable the file with a2ensite:
sudo a2ensite aryanchoudhary.conf
Disable the default site defined in 000-default.conf:
sudo a2dissite 000-default.conf
Test for configuration errors:
sudo a2enconf (wild card )
sudo apache2ctl configtest
You should see the following output:
Output
Syntax OK
Restart Apache to implement your changes:
sudo systemctl restart apache2
Apache should now be serving your domain name. You can test this by navigating to
http://aryanchoudhary, where you should see something like this:
Apache Service Controls:-
$ sudo systemctl stop apache2 #stop apache2
$ sudo systemctl start apache2 #start apache2
$ sudo systemctl restart apache2 #restart apache2
$ sudo systemctl reload apache2 #reload apache2
$ sudo systemctl disable apache2 #disable apache2
$ sudo systemctl enable apache2 #enable apache2
sudo systemctl is-active apache2
sudo systemctl is-enabled apache2
sudo systemctl status apache2
Comments
Post a Comment