平台:centos
1.准备编译环境:gcc g++
安装make:
yum -y install gcc automake autoconf libtool make
安装g++:
yum -y install gcc automake autoconf libtool make
2.nginx一般需要用到重写rewrite和gzip压缩、ssl,所以要先安装prce、zlib、openssl
所以我先准备好了一下几个包:
openssl-1.0.1t.tar.gz
pcre-8.35.tar.gz
zlib-1.2.11.tar.gz
然后放到/usr/local/src目录(网上大多教程选择的,也可以是其他目录)
cd /usr/local/src
3.安装pcre
tar -zxvf pcre-8.35.tar.gz
cd pcre-8.35
./configure
make
make install
4.安装zlib
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install
5.安装ssl,解压即可
tar -zxvf openssl-1.0.1t.tar.gz
6.安装nginx
其中
–with-pcre=/usr/local/src/pcre-8.35 \
–with-zlib=/usr/local/src/zlib-1.2.11 \
–with-openssl=/usr/local/src/openssl-1.0.1t
为各自软件安装的相应目录
tar -zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.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.11 \
--with-openssl=/usr/local/src/openssl-1.0.1t
make
make install
7.可以用
netstat -ano|grep 80
查看80端口是否被占用
9.启动
sudo /usr/local/nginx/nginx
10.打开浏览器输入服务器ip访问到nginx即成功
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.