Install nginx on CentOS
1) download nginx
Java code
- Wgethttp: // nginx.org/download/nginx-0.8.54.tar.gz
By default, it is downloaded to the current directory, that is, the pwd directory.
2) decompress
Java code
- Tarzxvfnginx-0.8.54.tar.gz
Go to nginx directory cd nginx-0.8.54
3) Java code
- ./Configure
Configure may occur in this step. The error of pcre cannot be found.
If you can connect to the Internet, we recommend that you use the yum command to install the dependency package.
Java code
- Yum-yinstallgccpcre-developensslopenssl-devel
If there is no network, you can find the following package under CentOS 5.5 DVD and install it in sequence.
Java code
- Rpm-ivhpcre-devel-6.6-2.el5_1.7.i386.rpm
- Rpm-ivhopenssl-0.9.8e-12.el5_4.6.i386.rpm
- Rpm-ivhe2fsprogs-devel-1.39-23.el5.i386.rpm
- Rpm-ivhkeyutils-libs-devel-1.2-1.el5.i386.rpm
- Rpm-ivhlibsepol-devel-1.15.2-3.el5.i386.rpm
- Rpm-ivhlibselinux-devel-1.33.4-5.5.el5.i386.rpm
- Rpm-ivhkrb5-devel-1.6.1-36.el5_4.1.i386.rpm
- Rpm-ivhzlib-devel-1.2.3-3.i386.rpm
- Rpm-ivhopenssl-devel-0.9.8e-12.el5_4.6.i386.rpm
Run./configure after installation.
The following information is displayed, indicating that the compilation is successful.
Java code
- Configurationsummary
- + UsingsystemPCRElibrary
- + OpenSSLlibraryisnotused
- + Md5: usingsystemcryptolibrary
- + Sha1libraryisnotused
- + Usingsystemzliblibrary
4) Java code
- Make
5) Java code
- Makeinstall
By default, it is installed in Java code.
- /Usr/local/nginx
Directory
6) Start Java code
- /Usr/local/nginx/sbin/nginx
Check whether startup is successful
Java code
- [Root @ maomaosbin] # psaux | grepnginx
- Root103910.0000004008456? Ss 10: 480: 00 nginx: [B] [color = red] master [/color] [/B] process./nginx
- Nobody103900000000004164796? S10: 480: 00 nginx: workerprocess
The master node is the main process. When the master node is disabled, kill the process. Other Sub-processes are automatically disabled.
Open http: // localhost/in the browser to view the default welcome page of nginx.
Welcome to nginx!
Nginx uses port 80 by default. We can change it in the conf/nginx. conf file under the nginx installation directory.
Java code
- Vim/usr/local/nginx/conf/nginx. conf
Find the following clip to make changes and then restart
Java code
- Server {
- Listen80; // Port
- Server_namelocalhost; // bind the Domain Name
- Location /{
- Roothtml; // default directory
- Indexindex.htmlindex.htm; // default homepage name
- }
- }
Restart nginx after modification.
Java code
- Kill-HUP 'cat/usr/local/nginx/logs/nginx. pid'
The HUP signal is a smooth restart.
Stop nginx
Java code
- Kill 'cat/usr/local/nginx/logs/nginx. Pi'
You cannot access the http: // localhost/page.