Bloggers recently installed Nginx, although previously installed, but no record of the installation process, resulting in the installation process is now experiencing pit, now record what I hope to be able to help you.
1: Install the compilation tools and libraries
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel pcre-devel
gcc, gcc-c ++ # is mainly used to compile the relevant use
openssl, openssl-devel # general configuration of https services when you need this anymore
Solution zlib, zlib-devel # is mainly used for file compression
pcre, pcre-devel # Nginx rewrite the HTTP modules and core modules will use PCRE regular expression syntax
make # traversal
make install # install
2: Create a directory nginx
cd /usr/local mkdir nginx
cd nginx
3: Download and unzip nginx
cd / usr / local / the NGIN wget to download http://nginx.org/download/nginx-1.6.2.tar.gz # tar zxvf nginx-1.6.2.tar.gz # decompression
4: enter the installation package directory
cd nginx-1.6.2
5: compile and install nginx, installed by default to / usr / local / nginx in
./configure make && make install
6: Go to the top nginx directory
cd /usr/local/nginx
7: As before tomcat with a docker installed it, you need to configure nginx reverse proxy, modify nginx.conf
cd /usr/local/nginx/conf vim nginx.conf
Localhost port monitor, redirect to 8080 (docker installed tomcat bloggers refer to other articles)
location / { proxy_set_header Host $Host; proxy_set_header X-Forward-For $remote_addr; proxy_pass http://127.0.0.1:8080; }
8: Save the file
esc :wq
9: View nginx.conf configured correctly
/usr/local/nginx/sbin/nginx -t
10: start, restart, stop nginx
cd / usr / local / nginx / sbin / ./nginx # start ./nginx -s stop # stop ./nginx -s quit # quit after ./nginx -s reload # reboot modify the configuration is reloaded into force
./nginx -s reopen: reopen the log file
./nginx -s quit
: This step is a way to stop the process of processing tasks to be completed nginx be stopped. ./nginx -s stop
: This mode is equivalent to first find nginx process id and then use the kill command to force kill the process.
Start Method Two
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
Stop Method Two
ps -ef | grep nginx # query process number kill -QUIT main process ID # leisurely stop kill -TERM main process ID # quick stop kill -9 process ID # master forced stop
11: Access external network ip (Note that if Ali cloud server you need to configure security set of rules that bloggers have added good)
12: boot from the start nginx (personal preference)
vi /etc/rc.local Add the line / usr / local / nginx / sbin / nginx
13: Set execute permissions
chmod 755 rc.local
Successful visit.