Page

[nginx]使用centos6编译安装nginx-1.10记录

745Anson16-12-04



一、安装编译工具及库文件,我的机子之前已经安装好了

yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

blob.png


二、①安装pcre工具(nginx的rewrite功能需要使用)

wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

blob.png


②解压pcre

tar zxvf pcre-8.35.tar.gz

blob.png

③编译安装pcre

cd pcre-8.35 && ./configure 
make && make install

④查看pcre版本

pcre-config --version

blob.png


三、安装nginx, 在官网找到最新安装包

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=/usr/local/webserver/nginx --with-http_stub_status_module 
--with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35       
(prefix:nginx的安装目录; with-pcre:pcre的安装目录)

make

make install

/usr/local/webserver/nginx/sbin/nginx -v         (查看nginx版本)


blob.png


如果安装失败,请重新照着流程安装。

报错:nginx.pid" failed (2: No such file or directory)

解决:/usr/local/webserver/nginx/sbin/nginx -c /usr/local/webserver/nginx/conf/nginx.conf


四、配置nginx

配置文件:/usr/local/webserver/nginx/conf/nginx.conf


参考菜鸟教程配置

http://www.runoob.com/linux/nginx-install-setup.html


/usr/local/webserver/nginx/sbin/nginx -s reload            # 重新载入配置文件
/usr/local/webserver/nginx/sbin/nginx -s reopen            # 重启 Nginx
/usr/local/webserver/nginx/sbin/nginx -s stop              # 停止 Nginx

配置环境变量:

命令行:export PATH=$PATH:/usr/local/webserver/nginx/sbin     //编译器目录

blob.png

相关命令:


                查看80端口

                netstat -ntpl

                

                killall nginx

                删除nginx进程


blob.png




来自ansion博客

2016年12月5日