I am trying to run Apache on my CentOS.(I am having very basic knowledge on linux).
[Apache Start Stop] using this link i tried to run: apachect1 start
But I got -bash apachect1: command not found
I also tried to check the status using $ /etc/init.d/nginx status
But I got -bash: /etc/init.d/nginx: No such file or directory
Then I tried to check if Apache is installed using : which apache2
But I got /usr/bin/which: no apache2 in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/git/bin:/usr/local/git/bin:/home/bebo/bin)
It seems that Apache is not installed, however I can see httpd directory in etc folder. Does it have any significance?
Is my assumption correct, if yes how can I install/from where to download & install. Else correct where I am going wrong.
These all the steps will be applied for CentOS 7 and CentOS 8
( Note also apply on RHEL 7/8)
I recommend running the below command to auto-remove the unused packages.
Step 1:
yum autoremove
Step 2: Now run the below command to update the CentOS
yum update
Step 3: Installing the apache software package
yum install httpd
Step 4: Starting the apache service
The name of the Apache service is httpd. Use the below command to start and enable it at the same time in CentOS 7 or later version.
systemctl enable --now httpd
Step 5: Checking the httpd service status
systemctl status httpd
Step 6: Firewall configuration
As per now, we have to allow the HTTP service in the firewall. So, you can find the below command useful for that.
firewall-cmd --permanent --add-service http
firewall-cmd --permanent --add-service https
Now reload the firewall service,
firewall-cmd --reload
Step 7: Test the Apache server. Put the IP address of your computer or the localhost on the web-browser; it will show you the Apache server is running.
To read more about Apache installation, you can visit my blog post. The blog post URL, you can find below.
The best and easiest way to install apache on Centos is using the yum
package manager.
Just run the following:
yum install httpd
After installation depending on your Centos version you start the Apache service as follows:
Centos 6
service httpd start
Centos 7
systemctl start httpd
Check if apache is installed
service httpd status
if the result is "httpd: unrecognized service" , it means not installed.
or
type your domain or ip in browser, if nothing to displayed, it means no apache installed.
Install Apache
yum -y install httpd
Start Apache service
service httpd start
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.