频道栏目
首页 > 资讯 > Linux > 正文

Linux(centOS7.2系统)下nginx的安装步骤讲解

18-05-29        来源:[db:作者]  
收藏   我要投稿

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 bydefault’. 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库:

[root@VM_0_14_centos ~]# rpm -qa | grep zlib

zlib-1.2.7-15.el7.i686

zlib-1.2.7-15.el7.x86_64

然后用以下命令删除其中一个版本

[root@VM_0_14_centos ~]# yum erase zlib-1.2.7-15.el7.i686

假设你上述库都安装完成后

5、到 usr/local目录下下周nginx安装包进行安装,建议安装在改目录下,否则在全局下没有nginx命令,需要加软连接,用该命令解决,加入你没安装在usr/local下,后者为你的安装目录

[root@VM_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

然后至浏览器中查看是否启动好,贴上我的图

这里写图片描述
相关TAG标签
上一篇:防止黑客入侵 这些人用过的密码千万别用
下一篇:centos7.3系统下安装mysql5.7教程
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站