编程技术分享平台

网站首页 > 技术教程 正文

Centos7 安装nginx(Centos7 安装软件)

xnh888 2024-09-30 04:30:39 技术教程 25 ℃ 0 评论

1、下载nginx下载地址(http://nginx.org/en/download.html)


或者直接使用命令下载 wget http://nginx.org/download/nginx-1.20.1.tar.gz

2、解压

tar -zvxf nginx-1.20.1.tar.gz


3、预编译

进入解压后的目录 nginx-1.20.1进行预编译 ./configure --prefix=/opt/nginx 注意:--prefix是指定安装目录(建议指定

出现错误 ./configure: error: C compiler cc is not found

解决方法:yum -y install gcc gcc-c++

出现错误 ./configure: error: the HTTP gzip module requires the zlib library.

解决方法: yum -y install zlib-devel

这里表示已成功预编译

4、编译

make

出现错误:-bash: make: 未找到命令 (-bash: make: command not found)

解决方法: yum -y install make autoconf

5、安装

make install

安装结束后进入 /opt/nginx/sbin (前面指定安装目录地址/sbin)

[root@ops01 sbin]# pwd
/opt/nginx/sbin
[root@ops01 sbin]# ./nginx
[root@ops01 sbin]# ps -aux|grep nginx
root      7120  0.0  0.0  20572   620 ?        Ss   20:17   0:00 nginx: master process ./nginx
nobody    7121  0.0  0.0  21016  1312 ?        S    20:17   0:00 nginx: worker process
root      7123  0.0  0.0 112816   980 pts/0    R+   20:18   0:00 grep --color=auto nginx

然后启动 ./nginx 这条命令成功没有输出

查看启动状态 ps -ef |grep nginx

然后打开浏览器访问

如果出现访问不了,尝试关闭防火墙 systemctl stop firewalld.service 再访问。

永久关闭防火墙 systemctl disable firewalld.service

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表