linux nginx安装(基础版)
-
系统版本:centos7
-
检查系统是否安装了gcc、pcre-devel、zlib-devel、openssl-devel
yum list installed | grep "gcc" yum list installed | grep "pcre-devel" yum list installed | grep "zlib-devel" yum list installed | grep "openssl-devel"
-
如果没有安装则执行安装命令
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
-
下载nginx安装包
官方主页:https://nginx.org/download/
或者执行命令
如果没有安装wget执行 yum -y install wget wget https://nginx.org/download/nginx-1.18.0.tar.gz
-
解压安装包,编译并安装
tar -zxvf nginx-1.18.0.tar.gz cd nginx-1.18.0 ./configure --prefix=/usr/local/nginx make make install
-
启动nginx
cd /usr/local/nginx/sbin ./nginx
-
访问界面
-
如果出现访问不了,查看服务器防火墙是否关闭
firewall-cmd --state systemctl stop firewalld.service systemctl disable firewalld.service
-
设置开机启动
vim /etc/rc.d/rc.local #增加nginx启动参数 /usr/local/nginx/sbin/nginx 注意:vi /etc/rc.d/rc.local默认没有执行的权限,需要授权 [root@localhost etc]# chmod +x /etc/rc.d/rc.local