Linux installation Nginx
Blog Category:
1) Download Nginx
Java code
- wget http://nginx.org/download/nginx-0.8.54.tar.gz
The default is downloaded to the current directory, which is the PWD directory
2) Unzip
Java code
- Tar zxvf nginx-0.8. 54.tar.gz
Enter Nginx Directory CD nginx-0.8.54
3) Java code
- ./configure
Configure this step may appear, can not find pcre error
Then if you can use the Yum command to install the dependency package.
Java code
- Yum-y install gcc pcre-devel OpenSSL openssl-devel
If you do not have a network, you can find the following packages under the CentOS 5.5 DVD, installed sequentially
Java code
- RPM-IVH pcre-devel-6.6-2.el5_1. 7.i386.rpm
- RPM-IVH openssl-0.9.8e-12.el5_4. 6.i386.rpm
- RPM-IVH e2fsprogs-devel-1.39-23.el5.i386.rpm
- RPM-IVH keyutils-libs-devel-1.2-1.el5.i386.rpm
- RPM-IVH libsepol-devel-1.15. 2-3.el5.i386.rpm
- RPM-IVH libselinux-devel-1.33. 4-5.5.el5.i386.rpm
- RPM-IVH krb5-devel-1.6. 1-36.el5_4. 1.i386.rpm
- RPM-IVH zlib-devel-1.2. 3-3.i386.rpm
- RPM-IVH openssl-devel-0.9.8e-12.el5_4. 6.i386.rpm
Install and then execute./configure
You will see a message similar to the following to indicate that the compilation was successful
Java code
- Configuration Summary
- + Using System PCRE Library
- + OpenSSL Library is not used
- + md5:using System Crypto Library
- + SHA1 Library is not used
- + Using System zlib Library
4) Java code
- Make
5) Java code
- Make install
Install to Java code by default
- /usr/local/nginx
Directory below
6) Start Java code
- /usr/local/nginx/sbin/nginx
To see if it started successfully
Java code
- [Root@maomao sbin]# ps aux | grep nginx
- Root 10391 0.0 0.0 4008 456 ? ss 10:48 0: 00 nginx: [b][color=red]master[/color][/b] process ./nginx
- Nobody 10392 0.0 0.0 4164 796? S : 0:nginx:worker process
Start successfully, Master is the main process, kill the process when it is closed, other sub-processes will automatically turn off
Open your browser http://localhost/to see the default Welcome page for Nginx
Welcome to nginx!
Nginx default is 80 port, we can be in the Nginx installation directory under the conf/nginx.conf file changes.
Java code
- Vim/usr/local/nginx/conf/nginx.conf
Locate the following fragment to make changes, and then restart
Java code
- server {
- Listen 80; //Port
- server_name localhost; //bind domain name
- Location/{
- root HTML; //default directory
- Index index.html index.htm; //default home name
- }
- }
After the change, restart Nginx.
Java code
- Kill-hup ' Cat/usr/local/nginx/logs/nginx.pid '
Hup signal is a smooth restart
Stop Nginx
Java code
- Kill ' Cat/usr/local/nginx/logs/nginx.pid '
Linux installation Nginx