Linux(centOS 7.2)下nginx安装步骤
1、gcc安装
查看是否有gcc
gcc -v
没有需要安装gcc,执行以下命令
yum -y install gcc gcc-c++ autoconf pcre pcre-devel make automake
yum -y install wget httpd-tools vim
查看gcc -v 若报 comand not found,再执行
yum -y install gcc automake autoconf libtool make
cc -v查看能看到版本
gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
2、PCRE库安装
yum install pcre pcre-devel
3、zlib库安装
yum install zlib zlib-devel
4、OpenSSL库安装
yum install openssl openssl-devel
期间可能遇到以下错误:
若报错如下:
make: * No rule to make target build', needed by
default’. Stop.
说明有依赖库没安装 ,继续安装上述几个库。
另外上述几个库安装过程中,可能报如下错误
Error: Multilib version problems found. This often means that the root
cause is something else and multilib version checking is just
pointing out that there is a problem. Eg.:
1. You have an upgrade for zlib which is missing some
dependency that another package requires. Yum is trying to
solve this by installing an older version of zlib of the
different architecture. If you exclude the bad architecture
yum will tell you what the root cause is (which package
requires what). You can try redoing the upgrade with
--exclude zlib.otherarch ... this should give you an error
message showing the root cause of the problem.
2. You have multiple architectures of zlib installed, but
yum can only see an upgrade for one of those architectures.
If you don't want/need both architectures anymore then you
can remove the one with the missing update and everything
will work.
3. You have duplicate versions of zlib installed already.
You can use "yum check" to get yum show these errors.
...you can also use --setopt=protected_multilib=false to remove
this checking, however this is almost never the correct thing to
do as something else is very likely to go wrong (often causing
much more problems).
上述常见原因是有两个版本的库。
用以下命令查看zlib库:
[aaa@qq.com_0_14_centos ~]# rpm -qa | grep zlib
zlib-1.2.7-15.el7.i686
zlib-1.2.7-15.el7.x86_64
然后用以下命令删除其中一个版本
[aaa@qq.com_0_14_centos ~]# yum erase zlib-1.2.7-15.el7.i686
假设你上述库都安装完成后
5、到 usr/local目录下下周nginx安装包进行安装,建议安装在改目录下,否则在全局下没有nginx命令,需要加软连接,用该命令解决,加入你没安装在usr/local下,后者为你的安装目录
[aaa@qq.com_0_14_centos nginx-1.14.0]# /usr/local/nginx/sbin/nginx -c /root/nginx-1.14.0/conf/nginx.conf
6、安装步骤:分别执行以下命令
wget http://nginx.org/download/nginx-1.1.10.tar.gz
tar -zxvf nginx-1.1.10.tar.gz
cd nginx-1.1.10
./configure
make
make install
7、修改nginx配置
到nginx安装目录下,用vim 打开命令打开nginx.conf
因为可能apeache占用80端口,apeache端口尽量不要修改,我们选择修改nginx端口。
打开后server中的listen是监听的端口 默认80,修改为8090 或者你想要的端口。
最后一步
8、启动nginx
nginx -s reload
然后至浏览器中查看是否启动好,贴上我的图
下一篇: DC学习(综合与优化)