从零开始的Linux运维屌丝之路,资源免费分享平台   运维人员首选:简单、易用、高效、安全、稳定、社区活跃的开源软件

Nginx编译安装入门教程

发布:蔺要红04-02分类: Nginx


1、下载合适的版本

官方网站:  www.nginx.org    选择合适的版本:stable version has been released  代表稳定版

下载链接

http://nginx.org/download/nginx-1.14.2.tar.gz
http://nginx.org/download/nginx-1.14.0.tar.gz
http://nginx.org/download/nginx-1.12.2.tar.gz


2、安装

mkdir /server/tools -p
mkdir /server/application -p.
mkdir /server/data
cd /server/tools/
yum  install  wget pcre pcre-devel openssl openssl-devel gcc gcc-c++ glibc  -y
wget http://nginx.org/download/nginx-1.14.2.tar.gz
tar zxvf nginx-1.14.2.tar.gz
cd nginx-1.14.2
useradd -M -s /sbin/nologin www
./configure --prefix=/server/application/nginx-1.14.2 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module
make && make install
ln -s /server/application/nginx-1.14.2/ /server/application/nginx

/server/application/nginx/sbin/nginx -c /server/application/nginx/conf/nginx.conf     #-c 指定配置文件启动nginx
/server/application/nginx/sbin/nginx -s stop     #停止nginx
/server/application/nginx/sbin/nginx -V   -V 查看版本以及编译参数

说明:Nginx的Rewrite规则需要PCRE软件的支持


3、Nginx-主配置文件(初学)



4、如果安装出现以下错误解决办法
[[email protected] sbin]# ./nginx (启动出错)
./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

#解决方法:
[ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" -a -z "`grep /usr/local/lib /etc/ld.so.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
 
温馨提示如有转载或引用以上内容之必要,敬请将本文链接作为出处标注,如有侵权我会在24小时之内删除!

欢迎使用手机扫描访问本站