安装nginx:
1.正式开始前,编译环境gcc g++ 开发库之类的需要提前装好.
安装make
yum -y install gcc automake autoconf libtool make
安装g++:
yum install gcc gcc-c++
一般我们都需要先装pcre, zlib,前者为了重写rewrite,后者为了gzip压缩。
2.安装PCRE库
cd /data/server
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz 获取tar包
tar -zxvf pcre-8.40.tar.gz
cd pcre-8.40/
./configure && make && make install
3.安装zlib
cd /data/server
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11/
./configure && make && make install
4.安装openssl
cd /data/server
wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
tar zxvf openssl-fips-2.0.10.tar.gz
cd openssl-fips-2.0.10
./config && make && make install
注:1-4 步可以用下面命令代理
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
5.安装nginx
cd /data/server
wget http://nginx.org/download/nginx-1.10.2.tar.gz
tar -zxvf nginx-1.10.2.tar.gz
cd nginx-1.10.2/
配置命令:
./configure --prefix=/data/server/nginx
--prefix=/data/server/nginx nginx的安装目录
执行结果:
nginx path prefix: "/data/server/nginx"
nginx binary file: "/data/server/nginx/sbin/nginx"
nginx modules path: "/data/server/nginx/modules"
nginx configuration prefix: "/data/server/nginx/conf"
nginx configuration file: "/data/server/nginx/conf/nginx.conf"
nginx pid file: "/data/server/nginx/logs/nginx.pid"
nginx error log file: "/data/server/nginx/logs/error.log"
nginx http access log file: "/data/server/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
编译安装:
make && make install
nginx启动:
进入启动目录sbin:cd /data/server/nginx/sbin/
./nginx # 启动 Nginx
./nginx -s reload # 重新载入配置文件
./nginx -s reopen # 重启 Nginx
./nginx -s stop # 停止 Nginx