Apache Server Configuration In Linux

860
Apache server configuration in linux

Apache server configuration in linux , One of the most used HTTP server by modern operating systems like Linux and windows.

In Ubuntu the Apache is refer as “Apache2” and the Apache web server configuration file exits in /etc/apache2/apache2.conf.

Once the Apache server is installed, you can check your server running on your IP address, just enter your IP address into your web browser address bar, the Apache Server is live.

http://your_server_ip_address

If you have not install Apache server yet, then first install Apache web Server here.

Apache Server Configuration In Linux , Ubuntu 20.04 LTS and 21.04 LTS

Now Next Step, Set up the Apache web server configuration for your domain, the configuration directory lies in /etc/apache2 and inside the apache2 directory apache2.conf is main Apache configuration file.

Each domain required its own Virtual Host Configuration File which ends with .conf extension and need to be saved in /etc/apache2/sites-available/ directory.

for example,

your_domain.conf

Follow the Steps to Create your Apache Server Configuration In Linux

1. Create a file at /etc/apache2/sites-available/your_domain_name.conf using command .

$ touch /etc/apache2/sites-available/your_domain_name.conf

2. Copy the Lines of Code in your_domain.conf file to make your Virtual Configuration Host for Your Domain.

$ sudo nano /etc/apache2/sites-available/your_domain_name.conf
<virtualhost *:80>  
    ServerAdmin webmaster@localhost  
    ServerName yourdomain.com  
    ServerAlias www.yourdomain.com  

    DocumentRoot /var/www/yourdomain.com  
    ErrorLog ${APACHE_LOG_DIR}/error.log  
    CustomLog ${APACHE_LOG_DIR}/access.log combined  
</virtualhost>

Now Replace ServerName and ServerAlias with your own domain name.

3. Create a directory for your website in /var/www/domain.com

$ mkdir /var/www/yourdomain.com

4. Create an index.html file inside your domain directory and put some html content so that we can visually check the page is live on your web domain.

$ touch /var/www/yourdomain.com/index.html

5. Restart Apache Web Server for the above changes to take effect.

$ sudo systemctl restart apache2

Now just check your domain in your web browser, your site is live.

Conclusion

Here we have successfully configured the Apache Server Configuration In Linux in ubuntu 20.04 LTS and 21.04 LTS.

LEAVE A REPLY

Please enter your comment!
Please enter your name here