LNMP开发环境搭建——Nginx编译安装

2016-6-27 邪哥

CentOS 6.5 x86_64 编译安装 nginx 1.10.1

这边对于nginx 及 apache 的差异及各方面的表现就不说了,专注于你要做的事  :)

这边安装的是目前最新的稳定版,你也可以去下载安装自己需要的版本

下载地址  http://nginx.org/download/nginx-1.10.1.tar.gz

[root@localhost soft]# wget http://nginx.org/download/nginx-1.10.1.tar.gz
[root@localhost soft]# tar -zxvf nginx-1.10.1.tar.gz 
[root@localhost soft]# cd nginx-1.10.1
[root@localhost nginx-1.10.1]# ./configure --user=nobody --group=nobody \
 --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module \
 --with-http_v2_module --with-http_gzip_static_module --with-http_realip_module \
 --with-pcre --with-pcre-jit --with-ipv6 --with-http_image_filter_module \
 --with-http_dav_module --with-http_degradation_module --with-http_secure_link_module \
 --with-threads --with-debug
[root@localhost nginx-1.10.1]# make && make install
[root@localhost nginx-1.10.1]# cd .. 
[root@localhost soft]# vi /etc/profile
#在文件底部添加如下内容, 类似windows中的修改环境变量
PATH=/usr/local/nginx/sbin:$PATH
export PATH
#完成后保存退出
[root@localhost soft]# source /etc/profile
[root@localhost soft]# nginx -t
nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
#说明pcre 库寻址有问题
#类似之前的我们添加一些软链接
[root@localhost soft]# vi lnlibpcre.sh
#拷贝粘贴以下内容
src=/usr/local/lib
dest=/usr/lib
 
for i in `ls $src | egrep "libpcre."`
do
	ln -s $src/$i $dest/$i 
done 
#拷贝粘贴内容结束
[root@localhost soft]# chmod +x lnlibpcre.sh 
[root@localhost soft]# ./lnlibpcre.sh 
[root@localhost soft]# ldconfig
[root@localhost soft]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost soft]# nginx
#启动nginx 
这时 我们就可以测试访问 http://localhost/ 看看效果了


目前 nginx 的默认www 目录为 /usr/local/nginx/html

你可以编辑 index.html  写入一些自定义内容后  刷新页面看看是否生效

好了,nginx 的安装 就记到这边

关于nginx 服务管理脚本  及 配置优化 等等  咱们后续再一一介绍 :)

如果你在安装的过程中碰到任何问题  欢迎留言沟通 


ps: 如果实际项目中出现 rewrite  403 问题,请留意优先复核 php.ini 中的 cgi.fix_pathinfo 是否是正常开启的。然后再核查其他可能性


运维 Nginx CentOS

(0) (1268)

发表评论: