如何在linux系统上部署nginx

1)首先去 nginx.org/download 官网下载你所需要的版本 我这里是下载的 nginx-1-23-3.tar.gz

2)然后执行 yum -y install lrzsz 安装文件上传软件 执行 rz 选择你下载nginx的位置进行上传

复制代码
yum -y install lrzsz

3)执行 tar -zxvf nginx-1.23.3.tar.gz 给文件进行解压

复制代码
tar -zxvf nginx-1.23.3.tar.gz

4)然后进入文件夹 cd nginx-1.23.3

复制代码
cd nginx-1.23.3

5)我们需要安装一些必要的编译软件 yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

复制代码
yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

6)然后我们执行 ./configure

复制代码
./configure

7)然后我们执行 ./configure --with-http_ssl_module

复制代码
./configure --with-http_ssl_module

8)继续执行 ./configure --with-http_ssl_module --with-http_v2_module

复制代码
 ./configure --with-http_ssl_module --with-http_v2_module

9)然后执行 make 和make install

复制代码
make && make install

10)然后我进入相关文件进行配置 vi /usr/lib/systemd/system/nginx.service

复制代码
vi /usr/lib/systemd/system/nginx.service 

然后 i 然后输入下列内容然后我们在保存退出

复制代码
[Unit]
Description=nginx
After=network.target
​
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
​
[Install]
WantedBy=multi-user.target

11)执行下列相关命令 然后配置防火墙,打开相关端口

复制代码
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-all

12)我们查看nginx状态 执行 systemctl status nginx.service

复制代码
systemctl status nginx.service

13)然后我们开启nginx 执行 systemctl start nginx.service

复制代码
systemctl start nginx.service 

14)systemctl status nginx.service 执行 我们查看状态 ,出现activity 代表服务已经打开了

复制代码
systemctl status nginx.service

15)然后打开服务器输入我们的ip地址 就可以了

相关推荐
JuiceFS13 小时前
从 MLPerf Storage v2.0 看 AI 训练中的存储性能与扩展能力
运维·后端
chen94519 小时前
mysql 3节点mgr集群部署
运维·后端
LH_R20 小时前
OneTerm开源堡垒机实战(三):功能扩展与效率提升
运维·后端·安全
dessler20 小时前
Hadoop HDFS-高可用集群部署
linux·运维·hdfs
少妇的美梦2 天前
logstash教程
运维
chen9452 天前
k8s集群部署vector日志采集器
运维
chen9452 天前
aws ec2部署harbor,使用s3存储
运维
白帽黑客沐瑶2 天前
【网络安全就业】信息安全专业的就业前景(非常详细)零基础入门到精通,收藏这篇就够了
网络·安全·web安全·计算机·程序员·编程·网络安全就业
東雪蓮☆2 天前
深入理解 LVS-DR 模式与 Keepalived 高可用集群
linux·运维·服务器·lvs
qq_264220892 天前
LVS负载均衡群集和LVS+Keepalived群集
运维·负载均衡·lvs