Install nginx in linux

Source: Internet
Author: User
Tags openssl library
: This article describes how to install nginx in linux. if you are interested in the PHP Tutorial, refer to it. 1) Download nginx

Java code

  1. Wget http://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

  1. Tar zxvf nginx-0.8.54.tar.gz


Go to nginx directory cd nginx-0.8.54
3)

Java code

  1. ./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

  1. Yum-y install gcc pcre-devel openssl-devel


If there is no network, you can find the following package under CentOS 5.5 DVD and install it in sequence.

Java code

  1. Rpm-ivh pcre-devel-6.6-2.el5_1.7.i386.rpm
  2. Rpm-ivh openssl-0.9.8e-12.el5_4.6.i386.rpm
  3. Rpm-ivh e2fsprogs-devel-1.39-23.el5.i386.rpm
  4. Rpm-ivh keyutils-libs-devel-1.2-1.el5.i386.rpm
  5. Rpm-ivh libsepol-devel-1.15.2-3.el5.i386.rpm
  6. Rpm-ivh libselinux-devel-1.33.4-5.5.el5.i386.rpm
  7. Rpm-ivh krb5-devel-1.6.1-36.el5_4.1.i386.rpm
  8. Rpm-ivh zlib-devel-1.2.3-3.i386.rpm
  9. Rpm-ivh openssl-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

  1. Configuration summary
  2. + Using system PCRE library
  3. + OpenSSL library is not used
  4. + Md5: using system crypto library
  5. + Sha1 library is not used
  6. + Using system zlib library


4)

Java code

  1. Make


5)

Java code

  1. Make install


Installed

Java code

  1. /Usr/local/nginx

Directory
6) start

Java code

  1. /Usr/local/nginx/sbin/nginx


Check whether startup is successful

Java code

  1. [Root @ maomao sbin] # ps aux | grep nginx
  2. Root 10391 0.0 0.0 4008 456? Ss nginx: [B] [color = red] master [/color] [/B] process./nginx
  3. Nobody 10392 0.0 0.0 4164? S nginx: worker process


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

  1. Vim/usr/local/nginx/conf/nginx. conf


Find the following clip to make changes and then restart

Java code

  1. Server {
  2. Listen 80; // port
  3. Server_name localhost; // bind the domain name
  4. Location /{
  5. Root html; // Default directory
  6. Index index.html index.htm; // default homepage name
  7. }
  8. }


Restart nginx after modification.

Java code

  1. Kill-HUP 'cat/usr/local/nginx/logs/nginx. pid'


The HUP signal is a smooth restart.
Stop nginx

Java code

  1. Kill 'cat/usr/local/nginx/logs/nginx. Pi'


You cannot access the http: // localhost/page.

The above describes how to install nginx in linux, including some content, and hope to help those who are interested in the PHP Tutorial.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.