centos7安装nginx

https://blog.csdn.net/Siebert_Angers/article/details/126960866?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168993007616800215039501%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=168993007616800215039501&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_ecpm_v1~rank_v31_ecpm-5-126960866-null-null.142v90control_2,239v3control&utm_term=centos7%20%E5%AE%89%E8%A3%85nginx%20%E5%88%B0%E6%8C%87%E5%AE%9A%E8%B7%AF%E5%BE%84&spm=1018.2226.3001.4187

nginx启动报 ssl parameter requires ngx_http_ssl_module

https://blog.csdn.net/yuan_618859/article/details/124918931

// 指定的安装目录 
./configure --prefix=/usr/local/nginx 

// 避免报错:  加上几个   --with 选项  
-- nginx: [emerg] the "http2" parameter requires ngx_http_v2_module in /usr/local/nginx/conf/conf.d/project_manager.conf:4


./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
sudo ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module


这样就卸载完成了
卸载Nginx需要命令:
1.查看 Nginx 进程
ps aux | grep nginx

2.启动Nginx的目标目录
cd /usr/local/nginx/sbin

3.关闭Nginx
./nginx -s stop

4.查看与Nginx有关的文件夹
find / -name nginx

5.删除与Nginx有关的文件
命令1:rm -rf file /usr/local/nginx*
命令2:find / -name nginx*

6.卸载Nginx的依赖
yum remove nginx

安装Nginx需要命令总结:
查看 C++ 环境是否安装(查看版本号)
gcc -v

安装 C++ 环境
yum install gcc-c++ -y

安装 ssl
yum install -y openssl openssl-devel

查看 zlib 是否安装
cat /usr/lib64/pkgconfig/zlib.pc

安装 zlib
yum install -y zlib zlib-devel

查看 pcre 是否安装(查版本号)
pcre-config --version

安装 pcre
yum install -y pcre pcre-devel

下载 Nginx 地址
解压 Nginx 压缩包
tar -xvf nginx-1.18.0.tar.gz

安装 Nginx
进入目录命令
cd nginx-1.18.0

执行命令
./configure

// 指定的安装目录 
./configure --prefix=/usr/local/nginx 

// 避免报错:  加上几个   --with 选项  
-- nginx: [emerg] the "http2" parameter requires ngx_http_v2_module in /usr/local/nginx/conf/conf.d/project_manager.conf:4


./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
sudo ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module




执行make命令
make

执行make install命令
make install

Nginx 服务操作
启动
命令1:cd /usr/local/nginx/sbin
命令2:./nginx

关闭
命令1:cd /usr/local/nginx/sbin
命令2:./nginx -s stop

重启
命令1:cd /usr/local/nginx/sbin
命令2:./nginx -s reload

端口号操作
查询开启的所有端口
firewall-cmd --list-port

设置80端口开启
firewall-cmd --zone=public --add-port=80/tcp --permanent

验证80端口是否开启成功 (单个端口查询)
firewall-cmd --zone=public --query-port=80/tcp

设置80端口关闭
firewall-cmd --zone=public --remove-port=80/tcp --permanent

防火墙操作
检查防火墙是否开启
systemctl status firewalld

开机自启防火墙
systemctl enable firewalld

开机禁止自启防火墙
systemctl disable firewalld

启动
systemctl start firewalld

关闭
systemctl stop firewalld

重启
firewall-cmd --reload

输入IP测试连接

你可能感兴趣的:(nginx,运维)