nginx安装
安装依赖,安装前准备
yum install gcc
yum install pcre-devel
yum install zlib zlib-devel
yum install openssl openssl-devel
下载解压安装包
//创建一个文件夹
cd /usr/local
mkdir nginx
cd nginx
//下载tar包
wget http://nginx.org/download/nginx-1.13.7.tar.gz
tar -xvf nginx-1.13.7.tar.gz
安装nginx
//进入nginx目录
cd /usr/local/nginx
//执行命令
./configure
//执行make命令
make
//执行make install命令
make install
# //测试配置文件
[root@VM-4-3-centos nginx]# ./sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
# nginx启动命令
[root@VM-4-3-centos sbin]# ./nginx
# nginx停止命令 或者 : nginx -s quit
[root@VM-4-3-centos sbin]# ./nginx -s stop
[root@VM-4-3-centos sbin]# ps -ef | grep nginx
root 26194 22309 0 15:44 pts/0 00:00:00 grep --color=auto nginx
如果是已经停止服务了,是不可以重启的。只有在正常运行的情况下,才可以reload重启。
# 重启命令
[root@VM-4-3-centos sbin]# ./nginx -s reload
nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
[root@VM-4-3-centos sbin]# ./nginx
# 查看进程命令
[root@VM-4-3-centos sbin]# ps -ef | grep nginx
root 26291 1 0 15:44 ? 00:00:00 nginx: master process ./nginx
nobody 26292 26291 0 15:44 ? 00:00:00 nginx: worker process
root 26309 22309 0 15:44 pts/0 00:00:00 grep --color=auto nginx
[root@VM-4-3-centos sbin]# ./nginx -s reload
[root@VM-4-3-centos sbin]# ps -ef | grep nginx
root 26291 1 0 15:44 ? 00:00:00 nginx: master process ./nginx
nobody 26396 26291 0 15:45 ? 00:00:00 nginx: worker process
root 26411 22309 0 15:45 pts/0 00:00:00 grep --color=auto nginx
# 测试访问
[root@VM-4-3-centos conf]# curl http://127.0.0.1:80
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南