centos7如何自主正确地安装配置Nginx?
Admin 2023-07-04 群英技术资讯 737 次浏览
yum -y install make zlib zlib-devel gcc gcc-c++ libtool openssl openssl-devel pcre pcre-devel
(PCRE 作用是让 Nginx 支持 Rewrite 功能)
1、下载Nginx
下载地址:http://nginx.org/,选择稳定版本(例如:nginx-1.12.0.tar.gz)
2、将下载的二进制包移动到/usr/local目录,解压缩文件包
tar zxvf nginx-1.12.0.tar.gz
3、进入安装目录,编译安装
cd nginx-1.12.0
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre --with-http_ssl_module
make
make install
安装完成后的摘要信息:
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
默认安装到/usr/local/nginx目录。
4、查看Nginx版本
/usr/local/nginx/sbin/nginx -v
输出结果如下:
nginx version: nginx/1.12.0
到此,nginx安装完成。
5、启动、关闭Nginx
#检查配置文件是否正确
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -V # 可以看到编译选项
#启动Nginx
/usr/local/nginx/sbin/nginx # 默认配置文件 /usr/local/nginx/conf/nginx.conf,-c 指定
# 重新载入配置文件
/usr/local/nginx/sbin/nginx -s reload
#重启Nginx,不会改变启动时指定的配置文件
/usr/local/nginx/sbin/nginx -s reopen
#停止Nginx
/usr/local/nginx/sbin/nginx -s stop
或
pkill nginx
1、创建Nginx运行使用的用户www
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
2、配置nginx.conf,将/usr/local/nginx/conf/nginx.conf替换为以下内容
[plain] view plain copy
四、防火墙配置
CentOS7默认的防火墙为firewall
添加防火墙规则如下:
#firewall-cmd --add-port=80/tcp //http协议基于TCP传输协议,放行80端口
现在大家对于centos7如何自主正确地安装配置Nginx?的内容应该都有一定的认识了吧,希望这篇能对大家有所帮助。最后,想要了解更多,欢迎关注群英网络,群英网络将为大家推送更多相关的文章。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
有很多朋友问fdisk怎么通过指令来进行硬盘分区?就为了帮助各位小伙伴处理这个问题,小编特地分享了以下相关资料给大家,希望这篇文章能帮助到你解决问题。
之前一篇文章介绍了lvm,今天在这里演示制作lvm的过程。lvm的制作过程有以下几个步骤:磁盘分区使用分区制作pv以pv建立vg从vg分割出lv格式化lv并挂载到目录中使用接下来...
linux中的排序命令是什么?在linux中的排序命令是sort,那么sort命令究竟是怎样排序的呢?用法是什么?接下来就给大家介绍一下sort命令。
linux下本文出现中文乱码怎么办?对于这个问题,本文给大家分享两种解决方法,一种是单一文件设置,另一种是整体设置。那么具体怎样设置呢?接下来我们来看一下解决方法。
基于CentOS下搭建 WordPress 个人博客
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008