1、安装nginx前,咱们首先要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件,可经过如图所示命令进行检测,若是以安装咱们能够经过图二所示卸载:linux
yum install gcc-c++
yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
## 若是已安装,则remove掉
yum remove nginx
wget https://nginx.org/download/nginx-1.11.3.tar.gz
咱们通常安装linux软件都会在/usr/local目录下,而后进行解压编译安装:nginx
tar -zxvf nginx-1.11.3.tar.gz
mv nginx-1.11.3 /usr/local/nginx-1.11.3
./configure --prefix=/usr/local/nginx
## 安装到/usr/local/nginx的nginx目录下
make
make install
此时安装成功:c++
此时源码包和安装后的包都有了,进入到nginx目录下,(通常要不要修改源码包,再make make install,须要看修改什么)spa
如上,进入到sbin/nginx,启动便可。code
2、配置和说明:server
接下来介绍下启动/中止/重启的具体方法,进入目录后咱们能够用执行sbin/nginx来启动,也能够经过conf/nginx.conf来启动,中止咱们能够查询进程使用kill -9 进程号/pkill -9 nginx来结束nginx服务,重启能够经过 sbin/nginx -s reload来重启,具体命令你们请看如图所示blog
3、nginx的开发实例进程
在nginx.conf文件增长代码ip
gzip on;
include ../conf.d/*.conf;
这样就能够在conf.d文件夹下添加配置文件,例如ssl
server{
listen 80;
server_name felab.**.com;
root /home/project/RDFELabClient/;
}
/usr/local/nginx/sbin/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 successfu
重启绑定host就能够正式访问了
4、把nginx设置全局变量
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/
/usr/local/nginx/sbin/nginx是nginx的启动命令
/usr/sbin/就是环境变量目录