Linux(九)安装Nginx
一、Nginx安装依赖准备
pcre、pcre-devel、zlib、openssl依赖准备
查看时是否安装gcc :gcc -v

安装gcc:yum -y install gcc

prec点我直接下载

二、将pcre文件解压并且编译、安装
1、解压:tar zxvf pcre-8.35.tar.gz

2、进入解压后的文件夹:cd pcre-8.35
3、检查:./configure
4、编译、安装:make && make install
5、查看是否安装成功:pcre-config --version

安装其他依赖:yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
二、安装Nginx
1、解压:tar zxvf nginx-1.18.0.tar.gz
2、进入解压后的文件:cd nginx-1.18.0
3、检查:./configure
4、编译、安装:make && make install
安装完成后会在/use/local目录下生成一个Nginx文件夹

5、启动Nginx
cd /usr/local/nginx/sbin
./nginx
6、查看是否启动成功:ps -ef |grep nginx

重新载入:./nginx -s reload
重启:./nginx -s reopen
停止:./nginx -s stop
三、查看Nginx配置端口

vi nginx.conf

网页访问:

四、防火墙配置
1、查看开放的端口
firewall-cmd --list-all

2、开放某个端口(例如80)
firewall-cmd --zone=public --add-port=80/tcp --permanent
3、开放端口、重载一下
firewall-cmd --reload
4、开启防火墙
systemctl start firewalld
5、关闭防火墙
systemctl stop firewalld
6、查看防火墙状态
systemctl status firewalld
踩过的坑
在使用make && make install 报错:No targets specified and no makefile found. Stop
解决:
wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
tar zxvf ncurses-5.6.tar.gz
./configure -prefix=/usr/local -with-shared-without-debug --without-cxx-binding
make && make install
目前还不知道是什么原因?有大佬知道的留言给解释下???
持续学习中!!!
头秃!头秃!头秃!