Nginx 有两种安装方式:
1)在线安装的方式
1.添加Nginx 到yum源
sudo rpm -Uvh <http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm>
2.安装Nginx,直接使用yum方式
yum install -y nginx
3.启动nginx,刚安装的nginx不会自行启动,需要执行命令与明星nginx
systemctl start nginx.service
4.访问页面,验证是否安装成功
启动成功之后,因为其默认为80端口,直接在浏览器输入IP地址,直接回车访问即可
http://192.168.132.141:80/
注意必须关闭防火墙
# 关闭防火墙
systemctl stop firewalld.service
# 禁止防火墙开启自启
systemctl disable firewalld.service
或者开放80端口
firewall-cmd --add-port=80/tcp --permanent
# 重启防火墙
firewall-cmd --reload
2)离线安装nginx
1.上传安装包
[root@cdp Nginx]# pwd
/data/app/Nginx
[root@cdp Nginx]# ll
total 1216
-rw-r--r--. 1 root root 1244738 Jun 4 06:03 nginx-1.26.1.tar.gz
2.离线安装的的前置依赖
gcc、perl以及相关的依赖openssl、pcre2、zlib
# 检查是否安装gcc
[root@cdp Nginx]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c+