美文网首页
Linux 安装 Nginx

Linux 安装 Nginx

作者: 索性流年 | 来源:发表于2020-07-27 15:50 被阅读0次

安装相应依赖

  • 防止后期安装报错
  • 依次执行命令
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel

下载

解压安装

  • 将下载文件解压修改名称为 nginx
  • 将文件上传至 /usr
cd /usr/nginx
./configure --prefix=/usr/local/nginx
  • 如若提示权限不足将 nginx 文件权限修改为可读写

编译

  • 依次执行如下命令
make
make install

启动

cd /usr/local/nginx/sbin
./nginx
  • 浏览器访问 ip
  • 图片.png
  • 如若报错
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)

终止 Nginx

pkill -9 nginx
  • 手动创建文件命令
touch /usr/local/nginx/logs/error.log
touch /usr/local/nginx/logs/access.log

重启

./nginx -s reload

修改防火墙

  • 如若需要外部连接则需要修改防火墙
  • 或者设置指定地址允许通过防火墙
  • 这里(个人)选择禁止防火墙
#禁用防火墙
systemctl stop firewalld.service
#禁止防火墙开机启动
systemctl disable firewalld.service

相关文章

网友评论

      本文标题:Linux 安装 Nginx

      本文链接:https://www.haomeiwen.com/subject/zzqzlktx.html