安装原料:
1)pcre-8.42.tar.gz
2)zlib-1.2.11.tar.gz
3)openssl-1.0.1t.tar.gz
4)nginx-1.4.2.tar.gz
下载地址:https://pan.baidu.com/s/1j6Fa2FIUOPwUsTPSSDzcRA
将下载好的压缩包解压出来,得到上面4个文件,并上传到服务器 /usr/local/src 目录下
检验与更新linux的环境
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++
下面正式开始安装软件:
1.安装pcre-8.42.tar.gz
cd /usr/local/src tar -zxvf pcre-8.42.tar.gz cd pcre-8.42 ./configure make make install
2.安装zlib-1.2.11.tar.gz
cd /usr/local/src tar -zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure make make install
3.安装openssl-1.0.1t.tar.gz
cd /usr/local/src tar -zxvf openssl-1.0.1t.tar.gz
4.安装nginx-1.4.2.tar.gz
cd /usr/local/src tar -zxvf nginx-1.4.2.tar.gz mkdir /usr/local/nginx 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.42 --with-zlib=/usr/local/src/zlib-1.2.11 --with-openssl=/usr/local/src/openssl-1.0.1t make make install
------------------------------------软件安装完毕
开始配置nginx
修改 /usr/local/nginx/nginx.conf 文件
#将原有的server配置删除,并进行如下配置 server { listen 20480; server_name localhost; location / { proxy_pass http://121.40.17.224:80/; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
配置完后启动nginx
cd /usr/local/nginx
./nginx
--------------------------服务配置启动完毕
开始配置自启动
1.创建脚本,使用vim nginx命令,复制下列内容到文档中,并保存
#!/bin/sh #chkconfig:2345 80 90 #description:auto start nginx cd / /usr/local/nginx/nginx
将写好的脚本放到 /etc/rc.d/init.d/ 目录下
2.使用chkconfig管理自启动服务
chkconfig --add nginx #添加自启动服务
chkconfig nginx on #使其生效