Home  >  Article  >  Backend Development  >  Install and start nginx in Linux

Install and start nginx in Linux

WBOY
WBOYOriginal
2016-07-28 08:27:381163browse

Since nginx depends on pcre and zlib, when installing nginx, you need to install pcre and zlib first (for convenience, I put the packages of pcre, zlib, and nginx in the same directory).

1. Install pcre

Download the tar.gz package from the official website of pcre. The official website address is: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/, I downloaded it here It is: pcre-8.39.tar.gz

tar -zxvf pcre-8.39.tar.gz
cd pcre-8.39
./configure 
make
make install

2. Install zlib

Download the tar.gz package from the official website of zlib. The official website address is: http://zlib.net/. What I downloaded here is: zlib -1.2.8.tar.gz

tar -xvf zlib-1.2.8.tar.gz 
cd zlib-1.2.8
./configure 
make
make install

3. Install nginx

Download the tar.gz package from the official website of nginx. The official website address is: http://nginx.org/en/download.html, here I download it is: nginx-1.11.2.tar.gz

tar -zxvf nginx-1.11.2.tar.gz
cd nginx-1.11.2
./configure --sbin-path=/usr/local/nginx/sbin/nginx  --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/usr/local/nginx/sbin/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.39 --with-zlib=../zlib-1.2.8
make
make install
At this point, nginx is installed

4. Configure and start nginx

After the above installation steps and directory settings, the startup program of nginx is /usr/local/ nginx/sbin/nginx, the configuration file is /usr/local/nginx/conf/nginx.conf. You can modify the port, reverse proxy path, etc. in the configuration file. The command to start nginx is:

/usr/local/nginx/sbin/nginx -t   //测试nginx.conf的配置是否正确

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf  //根据nginx.conf里的配置,启动nginx服务


The above has introduced how to install and start nginx in Linux, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn