Home  >  Article  >  Backend Development  >  Nginx installation and configuration nginx apache nginx php nginx rewrite

Nginx installation and configuration nginx apache nginx php nginx rewrite

WBOY
WBOYOriginal
2016-07-29 08:50:46922browse

  Nginx is generally recommended to be installed on a linux system, and the c language compilation environment gcc must be installed

*Download Nginx

Enter http://nginx. org/en/download.html Download nginx (take 1.8 as an example)

nginx 配置,nginx 安装,nginx下载,nginx windows,nginx负载均衡配置,nginx 重启,nginx apache,nginx php,nginx rewrite

*First install nginx dependent packages:

1, install ng inx needs First compile the source code downloaded from the official website. Compilation depends on the gcc environment. If there is no gcc environment, you need to install gcc: yum install gcc-c++

2. The http module of nginx uses pcre to parse regular expressions, so it needs to be installed on linux Install the pcre library on Linux: yuminstall -y pcre pcre-devel

3. The zlib library provides many compression and decompression methods. nginx uses zlib to gzip the contents of the http package, so you need to install the zlib library on linux: yuminstall -y zlib zlib-devel

4, nginx not only supports http protocol, but also https (that is, transmitting http over ssl protocol), so you need to install the openssl library on linux: yuminstall -y openssl openssl-devel

*Installation steps

Step 1: Upload nginx source code to linux System (you can use tools or Alt+p)

Step 2: Unzip the compressed package.

Step 3: Configure. (The red part is the nginx installation directory)

./configure

--prefix=/usr/local/nginx

--pid-path=/var/run/nginx/nginx.pid

--lock -path=/var/lock/nginx.lock

--error-log-path=/var/log/nginx/error.log

--http-log-path=/var/log/nginx/access. log

--with-http_gzip_static_module

--http-client-body-temp-path=/var/temp/nginx/client

--http-proxy-temp-path=/var/temp/nginx/proxy

--http-fastcgi-temp-path=/var/temp/nginx/fastcgi

--http-uwsgi-temp-path=/var/temp/nginx/uwsgi

--http-scgi-temp- path=/var/temp/nginx/scgi

Note: The temporary file directory is specified above as /var/temp/nginx, which needs to be created under /vartemptemp and nginxIf the directory does not exist An error will be reported when nginx starts

Step 4: make

Step 5: makeinstall

*Start and stop Nginx

1. Start: Enter the sbin directory of nginx, ./nginx can be started. (You can check whether two processes are started)

nginx 配置,nginx 安装,nginx下载,nginx windows,nginx负载均衡配置,nginx 重启,nginx apache,nginx php,nginx rewrite

There are two processes, master and worker, indicating that the startup is successful.

nginx 配置,nginx 安装,nginx下载,nginx windows,nginx负载均衡配置,nginx 重启,nginx apache,nginx php,nginx rewrite

Cannot be accessed. Check whether the firewall is turned off

2, stop: Enter the nginx sbin directory You can use the kill+process command, but it is not recommended , Recommended use: ./nginx-s stop

*Nginx configuration

in /usr/local/ The nginx.conf file in the nginx/conf directory is the nginx configuration file

nginx 配置,nginx 安装,nginx下载,nginx windows,nginx负载均衡配置,nginx 重启,nginx apache,nginx php,nginx rewrite








The above introduces the installation and configuration of Nginx, including nginx content. 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