软件环境:centos7 nginx-1.13.7

一、安装依赖软件

打开终端安装依赖软件
yum -y install gcc gcc-c++ autoconf automake make
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

二、下载并安装nginx

cd 到 /usr/local目录下
//下载软件

wget http://nginx.org/download/nginx-1.13.7.tar.gz

//解压
tar zxvf nginx-1.13.7.tar.gz

//创建安装目录
mkdir -p /usr/local/nginx

//修改配置
cd nginx-1.13.7/
./configure --prefix=/usr/local/nginx

//安装
make && make install

三、启动

进入安装目录
cd /usr/local/nginx/sbin

启动
./nginx    

这时候在安装机器就可以输入地址查看了。

如果远程访问的话需要关闭防火墙或者将80端口开放,添加新端口后需要reload 防火墙。

关闭防火墙:

CentOS 7.0默认使用的是firewall作为防火墙。

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

 

开放端口:

添加  firewall-cmd --zone= --add-port=80/tcp --permanent    (--permanent永久生效,没有此参数重启后失效)

重新载入 firewall-cmd --reload 

查看 firewall-cmd --zone=  --query-port=80/tcp

删除 firewall-cmd --zone=  --remove-port=80/tcp --permanent

 

输入地址后出现如下表示安装成功了。

四、解决端口冲突

安装后如出现上图信息表示nginx端口与其他软件端口冲突,解决办法建议修改端口。

方法一、停止占用80端口的程序,具体自行查询。

方法二、修改nginx.conf文件中nginx端口号。

cd /usr/local/nginx/conf 进入目录

vim nginx.conf 打开文件

找到listen位置,将默认80端口修改为未被占用端口。

按esc,:wq保存退出.

再次启动nginx即可。

 

 #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen      88;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

 

 

 

 

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:23 天前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐