CentOS7编译安装nginx
系统环境-nginx
1. 轻量级,占用资源少
2. 抗并发,nginx 以 epoll 作为开发模型,处理请求是异步非阻塞的
3. nginx 配置方便 负载均衡… 正则 lua 扩展
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core)
yum install net-tools 安装查看端口
yum install wget -y 安装wget
下载
wget http://nginx.org/download/nginx-1.20.2.tar.gz
解压tar xf 压缩文件名称
进入文件夹 cd nginx-1.20.2
[root@localhost nginx-1.20.2]# groupadd nginx (创建组) [root@localhost nginx-1.20.2]# useradd nginx -g nginx -s /sbin/nologin -M
安装nginx(编译)
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module
需要安装gcc
[root@localhost nginx-1.20.2]# yum install gcc gcc-c++ -y
没有pcre,需要安装
[root@localhost nginx-1.20.2]# yum install pcre-devel -y
缺少openssl
[root@localhost nginx-1.20.2]# yum install openssl-devel -y
安装
make && make install
查找安装路径:
whereis nginx
查看所有端口 netstat -ntlp 如果提示-bash: netstat: command not found yum install net-tools
启动、停止nginx
cd /usr/local/nginx/sbin/ ./nginx ---启动 ./nginx -h ---查看命令 ./nginx -v ---查看版本 ./nginx -V ---编译参数 ./nginx -s stop ----停机 ./nginx -s quit ./nginx -s reload ---不影响正在运行的进程 killall nginx ---杀掉进程
killall出现-bash: killall: command not found及使用方法
1. centos下
2. debian、ubuntu系统下
3. 使用
实例
关闭防火墙
systemctl stop firewalld.service (服务器如果重启,防火墙自己就开了)