nginx can be installed using the default packages of each platform. This article introduces the use of source code compilation and installation, including specific compilation parameter information.
Before the official start, the compilation environment gcc g++ development library and the like need to be installed in advance. By default, you have already installed it.
Ububtu platform compilation environment can use the following instructions
apt-get install build-essential
apt-get install libtool
centos platform compilation environment can use the following instructions
Install make:
yum -y install gcc automake autoconf libtool make
Install g++:
yum install gcc gcc-c++
The official start is now
------------------------------------------ ------------------------------------
Generally we need to install pcre and zlib first. The former is for re-installation. Write rewrite, which is for gzip compression.
1. Select the source code directory
It can be any directory. The one selected in this article is /usr/local/src
cd /usr/local/src
2. Install the PCRE library
ftp://ftp.csx.cam.ac .uk/pub/software/programming/pcre/ Download the latest PCRE source code package. Use the following commands to download, compile and install the PCRE package:
cd /usr/local/src
wget ftp://ftp.csx.cam.ac. uk/pub/software/programming/pcre/pcre-8.35.tar.gz
tar -zxvf pcre-8.35.tar.gz
cd pcre-8.35
./configure
make //Used for automatic compilation
make install
3 .Install the zlib library
http://zlib.net/zlib-1.2.8.tar.gz Download the latest zlib source code package, use the following command to download, compile and install the zlib package:
cd /usr/local/src
wget http ://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make install
4. Install ssl (Some vps do not have ssl installed by default)
cd /usr/local/src
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c. tar.gz
5. Install nginx
Nginx generally has two versions, namely the stable version and the development version. You can choose one of these two versions according to your purpose. The following is to install Nginx to /usr/local Detailed steps under the /nginx directory:
cd /usr/local/src
wget http://nginx.org/download/nginx-1.4.2.tar.gz
tar -zxvf nginx-1.4.2.tar.gz
cd nginx-1.4.2
./configure --sbin-path=/usr/local/nginx/nginx
--conf-path=/usr/local/nginx/nginx.conf
--pid-path=/ usr/local/nginx/nginx.pid
--with-http_ssl_module
--with-pcre=/usr/local/src/pcre-8.35
--with-zlib=/usr/local/src/zlib-1.2. 8
--with-openssl=/usr/local/src/openssl-1.0.1c
or:
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with -pcre=/root/soft/pcre-8.36
./configure --prefix=/usr/local --sbin-path=/usr/local/sbin/nginx --conf-path=/etc/nginx/nginx. conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/ nginx.pid --lock-path=/var/lock/nginx.lock
--user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client / --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre --with-file-aio -- with-http_image_filter_module ;
make
make install
--with-pcre=/usr/src/pcre-8.35 refers to the source code path of pcre-8.35.
--with-zlib=/usr/src/zlib-1.2.7 refers to the source code path of zlib-1.2.7.
After successful installation, the /usr/local/nginx directory is as follows
fastcgi.conf koi-win ime.types scgi_params.default
fastcgi_params.default mime.types.default uwsgi_params
html Occupy, run /usr/local/nginx/nginx command to start Nginx,
netstat - ano|grep 80
If no result is found, execute it. If there is a result, ignore this step (it must be started with sudo under ubuntu, otherwise it can only run in the foreground)
sudo /usr/local/nginx/nginx
Open browsing If the browser accesses the IP of this machine, if Welcome to nginx! appears on the browser, it means that Nginx has been installed and run successfully.
The above introduces the installation of Nginx compilation and deployment environment, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.