下载源码包,解压缩。
下载地址: http://nginx.org/en/download.htmlhtml
检查和安装依赖项,执行shellnginx
yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel # 依赖工具说明: # gcc 编译器 # pcre 正则表达式工具 # zlib 传输内容压缩 # openssl Https支持
进入源码包,执行配置命令正则表达式
./configure --prefix=/usr/local
执行编译安装shell
sudo make && make install # make 编译 # make install 在编译完成后, 把文件安装至指定目录, 这里是/usr/local
在nginx安装后的sbin目录下执行工具
./nginx
./nginx -s stop
./nginx -s reload
ps aux |grep nginx
结果形如code
root 7558 0.0 0.0 24520 1568 ? Ss 14:05 0:00 nginx: master process ./nginx nobody 7692 0.0 0.0 25216 2188 ? S 15:51 0:00 nginx: worker process leo 7817 0.0 0.0 103260 848 pts/0 S+ 18:08 0:00 grep nginx # master proccess为主进程 守护进程 # worker proccess为工做进程, 用于响应请求
编辑文件 /etc/rc.d/rc.local
htm
填写nginx启动命令进程
/usr/local/nginx/sbin/nginx