Summary: This article describes how to install Nginx with Yum source
The first step is to create a source configuration file Nginx.repo in the/etc/yum.repos.d/directory:
cd/etc/Yumrepos.d/vim Nginx.repo
Fill in the following content:
[Nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$ basearch/gpgcheck=0Enabled=1
Saved, a/etc/yum.repos.d/nginx.repo file is generated.
The following instructions can be executed directly below to install Nginx automatically:
Yum Install nginx-y
The installation is complete, the following directly can start Nginx:
/etc/init.d/nginx start
Now Nginx has been launched, direct access to the server will be able to see the Nginx Welcome page.
If you are still unable to access it, you need to configure your Linux firewall.
5 -M state--state new,established-J acceptservice iptables saveservice iptables Restart
Nginx command and configuration file location:
/etc/init.d/nginx Start # start Nginx service /etc/init.d/nginxStop # Stop Nginx service /etc/nginx/nginx.conf # Nginx Configuration file Location
At this point, Nginx has been fully configured to complete the installation.
default.conf configuration file settings in Nginx server, Normal, nginx.conf configure the corresponding information when the shunt request is generally set
Server {Listen the; server_name boss.mydongjia.com; #charset Koi8-R; #access_log/var/log/nginx/log/Host.access.log Main; Location/ {
#这里设置代理服务器的地址和对应的端口和应用名称, in fact, is the agent's Project path address Proxy_pass http://127.0.0.1:8080/xxxxxx/;Proxy_set_header Host $host; Proxy_set_header remote_addr $remote _addr; Proxy_set_header X-real-IP $remote _addr; Proxy_set_header X-forwarded-For $proxy _add_x_forwarded_for; Root/usr/share/nginx/html; Index index.html index.htm; } #error_page404/404. html; # REDIRECT Server error pages to the static page/50x.html # Error_page - 502 503 504/50x.html; Location= /50x.html {root/usr/share/nginx/html; }}
CENTOS 6.5 configuration Yum installation Nginx