nginx安装

2024-10-09 08:46:11 浏览数 (2)

安装依赖,安装前准备 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

0 人点赞