1024programmer Nginx Install Nginx on CentOS6 system

Install Nginx on CentOS6 system

1 Download an rpm package from nginx official website, the download address is :http://nginx.org/en/download.html

wget
http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

2 Install this rpm package

rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm

An error message will appear during the installation process:

warning: nginx-release-centos-6-0.el6.ngx.noarch.rpm: Header V4
RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY

I don’t know what to do, just ignore it

3 Start to install nginx formally

yum install nginx

A lot of information will be displayed, asking if you are ok or not: Is this ok [y/N]:

Enter y, and the installation will be completed after the screen scrolls for a while, and finally the prompt “Complete!” means the installation is complete.

4 Several default directories of nginx

whereis nginx
nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx

1 Configuration directory: /etc/nginx/
2 PID directory: /var/run/nginx.pid
3 Error log: /var/log/nginx/error.log
4 Access log: /var/log/nginx/access.log
5 Default site directory: /usr/share/nginx/html

5 common commands

1 Start nginx: nginx
2 Restart nginx: killall -HUP nginx
3 Test nginx configuration: nginx -t

6 Nginx cannot be accessed from outside the site?

A common problem when nginx is just installed is that it cannot be accessed outside the site, and the local wget and telnet are normal. Except for the server, neither other hosts on the LAN nor hosts on the Internet can access the site. If you use telnet, it prompts:

Connecting to 192.168.0.xxx… Could not open connection to host on port 80: Connection failed

If you use the wget command, it prompts:

Connecting to 192.168.0.100:80… failed: No route to host.

If it is the above symptoms, it is likely that port 80 is blocked by the firewall of CentOS. Try to execute the following command to open port 80:

iptables -I INPUT -p tcp –dport 80 -j ACCEPT

Then use:

/etc/init.d/iptables status

Check the current firewall rules, if there is such a rule:

ACCEPT tcp —
0.0.0.0/0
0.0.0.0/0
tcp dpt:80

It means that the firewall rules have been added successfully, and access outside the site will be normal.

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/install-nginx-on-centos6-system/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索