First download the compressed package:
this is also a dependent package pcre: http://jaist.dl.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz
nginx: http://nginx.org/download/ nginx-1.10.2.tar.gz
download dependencies:
yum install -y gcc gcc-c++
yum install -y pcre-devel
sequence:
first use the above two yum commands to install dependencies, then decompress the pcre package to install, and finally install nginx Installation
package Unzip the two compressed packages of pcre and nginx (final installation) respectively, enter the unzipped folder, and use the
command: ./configure to test.
No problem, make compile
no problem, make install
pay attention to turning off the firewall.
Test nginx command:
/usr/local/nginx/sbin/nginx
View process
ps -ef|grep nginx
Modify nginx configuration file
vi /usr/local/nginx/conf/nginx.conf
Do not close when modifying, reload after modification
/usr/local/nginx/sbin/nginx -s If there is a problem with reload
, kill command
pkill -9 nginx
shutdown command
/usr/local/nginx/sbin/nginx -s quit
ps: Take a website project from tomcat and forward it through
nginx URL: http://localhost:8080/yyyy
Forwarding result URL: http://localhost
nginx configuration file, change the server part:
server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass http://localhost:8080/yyyy; proxy_redirect off; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /yyyy/ { proxy_pass http://localhost:8080/yyyy/; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }