base_tutorial/4-WebServer/WebServer_old/install apache.md
2025-04-09 10:48:22 +03:30

80 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

What is Apache HTTP?
The Apache HTTP Server is a free and open-source cross-platform web server software, released under the terms of Apache License 2.0. Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation.
Table of Contents
Step 1 Updating the system
Step 2 Install Apache
Step 3 Check Apache status
Step 4 Set up Virtual Hosts
## Step 1 Updating the system##
<code>sudo apt update</code>
Updating Ubuntu system
## Step 2 Install Apache##
<code>sudo apt install apache2</code>
Install Apache Ubuntu
## Step 3 Check Apache status##
<code>sudo systemctl status apache2</code>
Check Apache status
Open your IP address on the browser to check if the Apache server is loading
Apache2 Ubuntu
## Step 4 Set up Virtual Hosts##
Create your domain directory on the server
<code>sudo mkdir /var/www/domain-name</code>
Give permissions to your domain directory
<code>sudo chmod -R 755 /var/www/domain-name</code>
Create a sample index.html
<code>touch /var/www/domain-name/index.html</code>
<code>echo "Your domain is now online" > /var/www/domain-name/index.html</code>
Create a virtual host file
<code>sudo nano /etc/apache2/sites-available/domain-name.conf</code>
Add the following content to your domain-name.conf file
> <VirtualHost *:80> <br>
- ServerAdmin webmaster@localhost <br>
- ServerName domain-name <br>
- ServerAlias www.domain-name <br>
- DocumentRoot /var/www/domain-name <br>
- ErrorLog ${APACHE_LOG_DIR}/error.log <br>
- CustomLog ${APACHE_LOG_DIR}/access.log combined <br>
<\/VirtualHost> <br>
Use a2ensite to enable the file
sudo a2ensite domain-name.conf
or
sudo a2ensite /etc/apache2/sites-available/domain-name.conf
Next, we have to disable the default file
<code>sudo a2dissite 000-default.conf</code>
Check for errors
<code>sudo apache2ctl configtest</code>
The output should be Syntax OK
Restart Apache and navigate to your domain on the browser
<code>sudo systemctl restart apache2<code>/
End