centos7如何自主正确地安装配置Nginx?
Admin 2023-07-04 群英技术资讯 687 次浏览
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进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
在linux中,bogon是主机名;当主机名为bogon时,指的是不该出现在internet路由表中的地址,包括私有地址和未正式分配出去的地址,可以利用“hostnamectl”查看主机名是bogon,可以利用“vi /etc/sysconfig/network”修改HOSTNAME来修改主机名。
如果你在进行Linux系统操作时遇到菱形乱码的问题,可以借鉴下小编所整理出来的方案,这篇文章将解决大家的困扰,如果需要,那就不要错过了。
在linux下删除文件,遇到特殊字符是一件非常头疼的事情。1 如果文件名带 ‘-’ 或者‘--’这样的字符删除办法为:rm -- 文件名如文件
linux线程是进程内部的一个执行分支,线程量级很小。一切进程至少都有一个线程。线程共享的资源:1、用户id和组id;2、当前工作目录;3、同一块地址空间;4、每种信号的处理方式。
centos 7.4 搭建ftp服务器 vsftpd
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008