nginx部署

nginx安装:

环境:CentOS7

Nginx版本:

下载地址:nginx-1.24.0

开源Web服务提供商 - NGINX开源社区

百度网盘地址:链接:https://pan.baidu.com/s/1fHMyi068Cm8_r7pP9zZeQQ?pwd=ng12 提取码:ng12

命令下载:wget https://www.nginx.org/download/nginx-1.24.0.tar.gz

安装:

解压:tar -zxvf nginx-1.24.0.tar.gz

进入解压目录:cd nginx-1.24.0/

执行环境配置 制定安装目录:./configure --prefix=/usr/local/nginx(安装目录绝对路径)

安装模块示例:./configure --prefix=/usr/local/nginx --with-http_ssl_module(https模块)

问题:

./configure: error: C compiler cc is not found:缺少gcc    yum -y install gcc

./configure: error: the HTTP rewrite module requires the PCRE library.: 缺失 PCRE库  yum -y install pcre-devel

./configure: error: SSL modules require the OpenSSL library. 缺失 OpenSSL  yum -y install OpenSSL openssl-devel

配置成功:

编译及安装:make && make install

启动命令:

进入安装目录:cd /usr/local/nginx(prefix配置目录)

启动:./nginx

停止:./nginx -s stop

重启:./nginx -s reload

启动指定配置文件:./nginx -c /usr/local/nginx/conf/nginx.conf

配置服务文件

cd /lib/systemd/system

新增文件 vim nginx.service

启动nginx: systemctl start nginx.service

查看状态:systemctl status nginx.service

停止nginx: systemctl stop nginx.service

重启nginx:systemctl reload nginx.service

异常:

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

执行:journalctl -xe 查看原因

例:端口被占用;用原始命令停止服务后重启执行

开机自启添加:systemctl enable nginx.service

开机自启关闭:systemctl disable nginx.service

关闭防火墙:systemctl stop firewalld.service

开放端口:firewall-cmd --zone=public --add-port=80/tcp –permanent

查询本机ip:ifconfig

访问nginx:(默认80端口)

  • 23
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值