08-08-2023
What is Apache2 server ?
- Apache is a open-source software .
- Developed by " Apache Software Foundation ".
- Its a WEB HOSTING SERVER.
Install Apache2 over the system :
sudo apt install apache2
systemctl status apache2
sudo systemctl start apache2
This error is due to another server with same functionality is running,
sudo systemctl stop nginx
sudo systemctl status nginx
sudo systemctl disable nginx
Now start the apach2 server,
sudo systemctl start apache2
sudo systemctl status apache2
sudo systemctl enable apache2
cd /var/www/html/ --> Edit the index.html file
vi /etc/hosts --> Add the entry of the host
All these are local machine changes, so this won't be available in INTERNET.
One Machine - 1 Site
One Machine - Multiple Site ( Virtual )
Types of hosting a web server:
- Name based eg., site1.name.com & site2.name.com
- Port based Virtual Hosting
- IP based
Now creating Name based Virtual Hosting ,
cd /var/www/html
sudo mkdir site1.test.com
sudo mkdir site2.test.com
now go inside these folders ,
Permission Change:
Current owner of the files & folders,
This permission change is required , as these are in ROOT permission it may create some issue in future , so always better to change to any user. Here we are using "www-data".
www-data ---> Who is this default user ? Apache2 user.
sudo chown -R www-data:www-data site1.test.com site2.test.com
Configuration Files :
cd /etc/apache2/
cd /etc/apache2/sites-available
Create a configuration file inside this folder for the two sites,
/etc/apache2/sites-available
sudo vi site1.test.com.conf
Sample Entry Below,
<VirtualHost *:80>
ServerAdmin admin@apple.hashlabs.in
ServerName apple.hashlabs.in
DocumentRoot /var/www/html/apple.hashlabs.in
DirectoryIndex index.html
ErrorLog ${APACHE_LOG_DIR}/apple.hashlabs.in_error.log
CustomLog ${APACHE_LOG_DIR}/apple.hashlabs.in_access.log combined
</VirtualHost>
sudo a2ensite site1.test.com
sudo systemctl reload apache2
sudo systemctl restart apache2
sudo a2ensite site2.test.com
sudo systemctl reload apache2
sudo systemctl restart apache2
sudo vi /etc/hosts
Important & Reference:
- https://github.com/alebcay/awesome-shell
- https://www.nginx.com/ --> WEB HOSTING SERVER
- SHIFT + CONTROL + P --.> Private Tab
- a2ensite ? a2ensite is a script that configures apache2 to enable the provided site (which contains a block). It accomplishes this by generating symlinks in /etc/apache2/sites-enabled . (or) a2ensite is a script that enables the specified site (which contains a '<'VirtualHost'>' block) within the apache2 configuration. It does this by creating symlinks within /etc/apache2/sites-enabled. Likewise, a2dissite disables a site by removing those symlinks.
- digitalocean - Try this site too to buy cloud.
- https://httpd.apache.org/ - Apache2 website
- https://www.javatpoint.com/what-is-apache
Top comments (0)