百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>服务器> CentOS下安装nginx以及端口配置教程
分享文章到:

CentOS下安装nginx以及端口配置教程

发布时间:01/15 来源: 浏览: 关键词:
安装nginx就像安装apache一样的简单了,我们只需要简单的几条命令就可以成功的在centos中安装nginx了,最后就是防火强的一个端口配置了。

在nginx官网上找到支持信息:

Currently, nginx packages are available for the following distributions and versions:

RHEL/CentOS:

Version Supported Platforms
5.x x86_64, i386
6.x x86_64, i386
7.x x86_64

Debian:

Version Codename Supported Platforms
6.x squeeze x86_64, i386
7.x wheezy x86_64, i386
8.x jessie x86_64, i386

Ubuntu:

Version Codename Supported Platforms
10.04 lucid x86_64, i386
12.04 precise x86_64, i386
14.04 trusty x86_64, i386, aarch64/arm64
14.10 utopic x86_64, i386

SLES:


To enable automatic updates of Linux packages set up the yum repository for the RHEL/CentOS distributions, the apt repository for the Debian/Ubuntu distributions, or the zypper repository for SLES.

看到是支持CentOS通过yum安装的,直接上命令:

# rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
 
# yum -y install nginx
就成功安装了,然后开启服务,报端口冲突。(由于事先安装了apache占用了80端口)


# service nginx start

Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[FAILED]

于是找到nginx的配置文件


# vim /etc/nginx/nginx.conf

看到里面有一句”include /etc/nginx/conf.d/*.conf;”,于是又找到/etc/nginx/conf.d/default.conf这个文件

vim /etc/nginx/conf.d/default.conf

打开后把listen 80改成listen 8080,然后启动nginx。

1
# service nginx restart
打开浏览器 输入http://localhost:8080/,就可以看到出现如下内容。

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有6人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板