I have been using Ubuntu, just recently started to work on Centos (CentOS Linux release 7.1.1503 (Core)) running in VMplayer on my desktop (Ubuntu).
for some reason, httpd didn't start automatically, I ran "service httpd start" and it started according to "netstat -antp".
[root@localhost ~]# netstat -antp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1161/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1620/master tcp 0 0 10.0.0.19:22 10.0.0.7:20383 ESTABLISHED 2421/sshd: root@pts tcp6 0 0 :::80 :::* LISTEN 2453/httpd tcp6 0 0 :::22 :::* LISTEN 1161/sshd tcp6 0 0 ::1:25 :::* LISTEN 1620/master
I can access the http server locally ( curl http://localhost
within the CentOs command line)
curl http://172.16.13.143/
, it refused the TCP connection. I was able to to ssh into it, it works ok for ssh ssh root@172.16.13.143
.service iptables stop
getenforce
command.I just need to do a quick test on the web interface but I can't. Really need some help. Thanks.
Packages installed on RHEL/CentOS/Fedora systems aren't supposed to start any services automatically (because maybe you're not ready to expose your service to the world until after you've configured it).
Running service httpd start
will start the service temporarily, but it won't start next time you boot. You want systemctl enable httpd
to enable the service to start automatically when you boot your system.
You could check if the firewall is actually disabled. Run iptables -S
to see the current ruleset. The default iptables configuration typically allows only ssh
and nothing else.
Update
Your system is probably running firewalld
to manage the firewall. Try service firewalld stop
.
You can run systemctl disable firewalld
to prevent it from starting next time your system boots.
-- CentOS 7
add the following to '/etc/httpd/conf/httpd.conf'
Replace:
Listen 80
With:
Listen 0.0.0.0:80
this will disable ipv6 and enable ipv4
To check this type:
netstat -an | grep -i tcp | grep -i listen
restart apache service
systemctl restart httpd.service
Also, enable firewall to access port 80
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
Did you do a iptables -L
to make sure no firewall is running?
Execute following command to make sure no other firewalls is running too
ps -ef
"80" is being listened so something is blocking your connection looks like
In a standard installation, CentOS 7 is set to prevent traffic to Apache.
add the ports to your firewall:
for http:
sudo firewall-cmd --permanent --add-port=80/tcp
for https:
sudo firewall-cmd --permanent --add-port=443/tcp
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.