It looks like you're new here. If you want to get involved, click one of these buttons!Sign In Register
It looks like you're new here. If you want to get involved, click one of these buttons!
The Apache HTTP web server is currently the most popular web server software in the world. It is well suited for working with large projects and is very flexible in terms of configuration, which makes it possible to implement all the features of the hosted web resource.
In this guide you will learn how to install Apache web server on RedHat based distributions (CentOS, AlmaLinux).
Make sure your software is updated before the actual installation. You can do this with the following command:
After updating the packages, run the following command to install Apache:
yum install httpd
To start Apache, run this command:
systemctl start httpd
To check Apache status, run the following command:
systemctl status httpd
The output will provide Apache and some additional information:
You can also verify if Apache was enabled on your server, by entering your server's public IP address in your web browser:
If everything is correct, you will see the default Apache web page (different for CentOS and AlmaLinux):
If you don't want Apache to start automatically on every system boot, run the following command:
systemctl disable httpd
If you want to re-enable this feature and automatically start Apache after every boot, run the following command:
systemctl enable httpd
To stop Apache, run this command:
systemctl stop httpd
You can restart Apache with:
systemctl restart httpd
To reload Apache without losing connections, enter the following command:
systemctl reload httpd
VirtualHost is a directive in the configuration file of the Apache web server, designed to match IP addresses available on the server, domains and directories on the server, as well as manage sites available on the server.
You can create a virtual host configuration file by typing this command:
Add these lines to the configuration file:
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/var/www/html" DirectoryIndex index.html ServerName yourdomain.ltd ErrorLog "/var/log/httpd/yourdomain.ltd.error_log" CustomLog "/var/log/httpd/yourdomain.ltd.access_log" common </VirtualHost>
After editing, you can save changes and exit.
Be sure to restart Apache after creating the configuration file:
systemctl restart httpd