linux安装nginx步骤
- 添加nginx存储库
yum -y install epel-release
- 安装nginx
yum -y install nginx
- 启动nginx
systemctl start nginx
- 系统设置开机自启
systemctl enable nginx
- 访问是否成功,http://ip 即可,页面是下面两种,这其实是nginx的欢迎页面(每个版本的nginx各不相同),这并不代表nginx没有正常启动,需要可以修改/usr/share/nginx/html目录下的index.html,可修改成自己想要的页面
linux卸载nginx步骤
- 停止nginx
systemctl stop nginx
- 删除nginx的自动启动
chkconfig nginx off
- yum卸载
yum remove nginx
- 删除nginx的相关文件
rm -rf /usr/sbin/nginx
rm -rf /etc/nginx
rm -rf /etc/init.d/nginx
nginx的gz包安装
-
安装相关组件
yum -y install gcc gcc-c++ zlib zlib-devel openssl openssl-devel pcre pcre-devel
-
官网下载安装包,上传至linux系统
- 解压,zxvf显示解压文件
tar zxf nginx-1.17.1.tar.gz
- 进入nginx源文件目录
cd nginx-1.17.1
- 编译,默认https没有打开,需要添加 --with-http_ssl_module
./configure --with-http_ssl_module
-
安装
make && make install
-
启动
/usr/local/nginx/sbin/nginx
nginx的相关命令
启 动: systemctl start nginx
关 闭: systemctl stop nginx
重 启: systemctl restart nginx
重新加载: systemctl restart nginx
辅助命令
查看防火墙状态: firewall-cmd --state
更新防火墙规则: firewall-cmd --reload
关闭防火墙: systemctl stop firewalld.service
打开防火墙: systemctl start firewalld.service
永久开放80端口: firewall-cmd --zone=public --add-port=80/tcp --permanent