Apache web server is widely used open-source web server for web application. It provides dynamically run multiple website, redirection, whitelist-bloacklist and security features for websites. Ubuntu and centOS is common used linux web server.
In this article, we will learn hou to install and configure apache web server in CentOS server. So let's start by logging in server in Terminal.
The first step is to install any package is to update the system software repositories list. So run the below command.
sudo yum update
Now install Apache server running below command.
sudo yum install httpd
If you have installed firewalld in your server, then you need to open port 80 to allow apache to handle the requests. You can do it by running the below command.
sudo firewall-cmd --permanent --add-service=http
Or if you have installed SSL certificate for the domain, you need to open port 443.
sudo firewall-cmd --permanent --add-service=https
Now reload firewall services.
sudo firewall-cmd --reload
You need to start apache server in CentOS server.
sudo systemctl start httpd
If you want to stop apache server, you can stop the apache server with below command.
sudo systemctl stop httpd
To restart the the server, run this command:
sudo systemctl restart httpd
If you want to check apache status, you can run the command:
sudo systemctl status httpd
This will output like this:
Apahe main configuration file located at /etc/httpd/conf/httpd.conf
. The default directory apache handle is /var/www/html
. So if you want to put the website project at different directory or want to add multiple domains, you need to creat seperate configuration file for each domain.
First add the domain configuration file path in the main apache configuration file. Open /etc/httpd/conf/httpd.conf
file in nano editor.
sudo nano /etc/httpd/conf/httpd.conf
And add the filepath at the end of file in it.
IncludeOptional sites-enabled/*.conf
Save and exit the file. Now create a file with your domain name and put the configuration options with appropriate file path.
sudo nano /etc/httpd/sites-enabled/domain.com.conf
<VirtualHost *:80>
ServerName www.domain.com
ServerAlias domain.com
DocumentRoot /var/www/html/domain.com
ErrorLog /var/www/html/domain.com/log/error.log
CustomLog /var/www/html/domain.com/log/requests.log combined
</VirtualHost>
Save and exit the file. That's it. Your domain is successfully configured to served at the path /var/www/html/domain.com
directory.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
jQuery append content inside selected element
JQuery has made easy to handle Javascrip...How to Merge two Collections in Laravel
Laravel collection class Illuminate\Supp...How to refresh a page with jQuery
Use the JavaScript Met...How to add attributes to an HTML element in jQuery
Use the jQuery attr() method You can...How to get the position of an element relative to the parent using jQuery
Use the jQuery position() meth...