Background I installed a minimal centos7 in virtualbox and then used another source yum to install nginx Host ip Address: 192.168.31.146centos bridge ip192.168.31.158 host hosts add address: 192.168.31.158cent.com to test that nginx has been started, show run...Background
- On
virtual box
Install a minimalcentos 7
- Other sources
yum
Installednginx
- Host ip Address:
192.168.31.146
centos
Bridge ip192.168.31.158
- Host hosts add address:
192.168.31.158 cent.com
Test
nginx
Started. running is displayed.
nginx
Configuration Filedefault.conf
As follows:
nginx -t
Display normal
/usr/share/nginx/html
There is an html file by default.
- Host
ping cent.com
Can be pinged. The ip address is 158.
- There is nothing in the nginx log.
Problem
- Host access
http://cent.com
Inaccessible
- Why can't I access it? Did I miss something ??
Solution
- It is indeed a firewall question. Thanks @ _ Zhao for answering this question. I forgot the firewall!
- For centos7
firewalld
, I saidiptables
Why ..
- Firewalld is installed and enabled by default. To access nginx, run the following command:
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --zone=trusted --add-port=80/tcp
- For other commands, refer to firewalld introduction.
Reply content:Background
- On
virtual box
Install a minimalcentos 7
- Other sources
yum
Installednginx
- Host ip Address:
192.168.31.146
centos
Bridge ip192.168.31.158
- Host hosts add address:
192.168.31.158 cent.com
Test
nginx
Started. running is displayed.
nginx
Configuration Filedefault.conf
As follows:
nginx -t
Display normal
/usr/share/nginx/html
There is an html file by default.
- Host
ping cent.com
Can be pinged. The ip address is 158.
- There is nothing in the nginx log.
Problem
- Host access
http://cent.com
Inaccessible
- Why can't I access it? Did I miss something ??
Solution
- It is indeed a firewall question. Thanks @ _ Zhao for answering this question. I forgot the firewall!
- For centos7
firewalld
, I saidiptables
Why ..
- Firewalld is installed and enabled by default. To access nginx, run the following command:
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --zone=trusted --add-port=80/tcp
- For other commands, refer to firewalld introduction.
@ Savokiss
Firstcentos
Try to use$curl http://127.0.0.1
Command to access nginx.
If you can obtainnginx
.
Then, the problem basically lies in the firewall,centos 7
Firewall usagefirewalld
.
So, you needfirewalld
Allow80
Port.
For specific commandsgoogle
.
Hope to solve your problem.