How to install and configure Apache on Rocky Linux
Apache HTTP server is one of the most widely used web servers in the world. It is a free, open source, cross-platform web server that offers powerful features such as loadable modules, strong media support, and extensive integration with other software.
Apache HTTP server is one of the most widely used web servers in the world. It is a free, open source, cross-platform web server that offers powerful features such as loadable modules, strong media support, and extensive integration with other software. It is part of the LAMP server stack (Linux, Apache, MySQL and PHP). By default, HTTP operates on port 80 and HTTPS operates on port 443 of TCP. This tutorial will show you how to install and manage Apache web server on Rocky Linux.
Install Apache
Apache is available on default Linux repositories. The name of the package is 'httpd'. To install Apache, navigate to the terminal and type the following command.
# sudo dnf install –y httpd
Once the installation is complete, enable and start the service with the following command.
# sudo systemctl enable httpd && systemctl start httpd
To verify the service is running, use the following command.
# systemctl status httpd
Enable ports on the firewall
To allow others to access the HTTP or HTTPS service, add a firewall rule.
# sudo firewall-cmd –add-service=https –permanent # sudo firewall-cmd –add-service=http –permanent
Reload the firewall to reflect the changes using the following command.
# sudo firewall-cmd –reload
You can access the default page to check if the Apache service is running smoothly by entering the server's IP address into your web browser and pressing Enter.
This page indicates that the Apache service is working fine.
Apache Management
Apache is controlled by applying directives in the configuration file.
- Apache configuration files are located in the /etc/httpd directory.
- Apache's main configuration file is /etc/httpd/conf/httpd.conf.
- The file with the .conf extension in the /etc/httpd/conf.d/ directory is also included in the main Apache configuration file.
- To load different modules in the configuration file, /etc/httpd/conf.modules.d is used.
- The Apache log files for error_log and access_log files are located in the /var/log/httpd/ directory.
Set up Virtual Host (recommended)
To host multiple websites on Apache, Virtual Host is being used. To configure Virtual Host, add the following lines to the end of the configuration file (/etc/httpd/conf/httpd.conf).
ServerName www.vitux.com ServerAlias vitux.com DocumentRoot /var/www/html/ ServerAdmin admin@vitux.com
Restart the service using the following command.
# sudo systemctl restart httpd
Create a sample page named index.html in the /var/www/html/ directory.
# sudo vim /var/www/html/index.html
Welcome to Vitux.com
Success! The vitux.com virtual host is working fine!
Check the Virtual Host results
To check the Virtual Host results, open a browser and enter the server URL
The article has successfully set up and tested Virtual Host without any errors.
You should read it
- How to install OpenLiteSpeed Web Server on Rocky Linux 8
- How to install Suricata IDS on Rocky Linux
- Install and configure Apache in Ubuntu
- 7 best Linux distributions based on Red Hat
- 10 measures of Apache security
- Optimize Apache server performance
- 7 Enterprise Linux Server Distributions
- Apache 2.0 with SSL / TLS protocol: Step by step instructions (continued Part I)
- Compare Nginx and Apache
- MSI presents the laptop to play 'dinosaur' GE70 Apache Pro
- How to Install Apache Guacamole via Docker on Ubuntu 22.04
- How to set up a firewall in Linux
Maybe you are interested
Windows 12: Start of development in March 2022 Steps to check iPad battery status quickly iPad 5 gym support tools at home: simple but surprisingly effective Buy mobile hard drive, SSD hard drive where genuine, cheap? Instructions to stamp photos, add watermark to images on Android phones Instructions to add watermark, rotate, flip photos with Picasa