Niginx 下载及安装
1、下载
<code>wget http://nginx<span>.org</span>/download/nginx-<span>1.10</span><span>.0</span><span>.tar</span><span>.gz</span></code>
我的软件都下载到了 /opt/soft-install 下
2、解压
<code><span>#解压到当前目录</span> tar -zxvf nginx-<span>1.10</span><span>.0</span><span>.tar</span><span>.gz</span> -C .</code>
3、编译并安装
首先得了解下面几个命令的意义
参考:http://feinibuke.blog.51cto.com/1724260/367376
安装到/opt/soft/nginx-1.10.0 目录下
<code><span>cd</span> nginx-<span>1.10</span>.<span>0</span>/ <span># 指定安装到 /opt/soft/ngnix 的目录下</span> ./configure --prefix=/opt/soft/nginx-<span>1.10</span>.<span>0</span></code>
提示:缺少C编译环境
解决
<code><span>yum</span><span>install</span><span>gcc</span><span>gcc</span><span>-</span><span>c</span><span>+</span><span>+</span></code>
继续configure
提示:缺少pcre依赖库
解决
<code>yum <span>install</span> pcre pcre-devel</code>
提示:缺少zlib 依赖库
解决
<code>yum <span>install</span> zlib zlib-devel</code>
出现如下图所示,说明安装环境已经没问题了
总结:编译安装之前必须保证系统已经安装如下依赖库
<code>yum <span>install</span> gcc gcc-c++ yum <span>install</span> pcre pcre-devel yum <span>install</span> zlib zlib-devel</code>
4、安装
<code><span>make</span> & <span>make</span> install</code>
如果看的以下目录结构,说明基本安装没问题了
5、测试Nginx是否安装成功
启动Nginx
<code><span>cd</span> /opt/soft/nginx-<span>1.10</span>.<span>0</span>/ ./sbin/nginx</code>
将80端口开放
<code><span>firewall</span><span>-</span><span>cmd</span><span>-</span><span>-</span><span>z/span><span>-</span><span>-</span><span>add</span><span>-</span><span>port=80/tcp</span><span>-</span><span>-</span><span>permanent</span><span>firewall</span><span>-</span><span>cmd</span><span>-</span><span>-</span><span>reload</span></span></code>
浏览器访问 192.168.2.202
出现以上界面,说明Nginx访问成功。
Niginx 常用命令
1、查看Nginx进程
<code>ps aux<span>|grep nginx</span></code>
2、查看Nginx命令
<code>ngnix <span>-h</span></code>
3、常用Nginx命令
<code><span>#启动</span> ngnix <span>#停止</span> nginx -s stop <span>#重新加载配置</span> nginx -s reload</code>
以上就介绍了CentOS7 编译安装Nginx,包括了centos7方面的内容,希望对PHP教程有兴趣的朋友有所帮助。