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. 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
- 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
May be interested
- 7 best Linux distributions based on Red Hatred hat became the largest open source company in the world before it was acquired by ibm, and red hat enterprise linux was its main product.
- 10 measures of Apache securityapache's running on linux does not mean you do not need to update. new vulnerabilities and security risks are always available.
- How to configure DNS Server on Ubuntu Server 11.04dns server is a server with domain name resolution function. in this article, we will detail the steps to install and configure dns server on linux with ubuntu server version 11.04.
- How to install Apache, MySQL and PHP in OS Xusing mamp, you can quickly and easily install apache, php and mysql on your mac.
- How to Install and Configure DaVinci Resolve in Linuxdavinci resolve is known for its color correction capabilities in major movie studios, which come with a powerful video and audio editor and editor, like adobe after effects.
- How to Install KVM in Arch Linux and Configure Virtual Machinesetting up a new virtual machine on arch linux using kvm and qemu can seem daunting. but fret not, as it will be very easy to learn how to do it.
- How to Install Tomcat in Ubuntuthis wikihow teaches you how to download, set up, and start an apache tomcat web server environment on your computer, using an ubuntu linux system. apache tomcat is an open-source, java-based http web server environment. you can implement...
- Compare Nginx and Apachethe truth is that both apache and nginx are at the core of the complete web stack (lamp as well as lemp) and the final choice depends on the needs of each individual.
- 7 Enterprise Linux Server Distributionsthe newest entrants to the linux team are businesses looking for stable and secure distributions to enhance their production cycles.
- Instructions for creating virtual hosts with Apache in Ubuntufor system administrators, apache is indeed one of the most effective support tools today, with high flexibility and stability, easy to set up, configure, and support multiple management. domain even though the web server system has only one ip address. besides, we can also use to store many different sites ...