CentOS 7 编译安装 Nginx


CentOS 7 编译安装 Nginx https://www.cnblogs.com/liujuncm5/p/6713784.html

  1. 确认有 gcc ,无则 yum install gcc-c++
  2. yum install -y pcre pcre-devel
  3. yum install -y zlib zlib-devel
  4. yum install -y openssl openssl-devel
  5. http://nginx.org/en/download.html 下载 stable version ,解压文件夹移入 /usr
  6. cd /usr/nginx-1.18.0 进入编译安装目录
  7. ./configure 使用默认配置,若提示权限不够则先 chmod +x configure
  8. make
  9. make install
  10. whereis nginx 查找安装位置,会在 /usr/local/nginx/sbin 下
  11. /usr/local/nginx/conf/nginx.conf 中配置端口,设置字符集
  12. 启停
    cd /usr/local/nginx/sbin
    ./nginx 
    ./nginx -s stop
    ./nginx -s quit
    ./nginx -s reload
    

ubuntu 20.04 安装 Nginx

  1. sudo apt install nginx
  2. sudo systemctl disable nginx 禁止开机启动
  3. 修改 /etc/nginx/sites-enabled/default,也可以在此修改端口
    location / {
    		# First attempt to serve request as file, then
    		# as directory, then fall back to displaying a 404.
    		# try_files $uri $uri/ =404;
    		root html;
    		index index.html index.htm;
    	}
    

编译安装 Nginx 参考

  1. 官网下载
  2. apt install build-essential libtool
  3. apt install libpcre3 libpcre3-dev
  4. apt install zlib1g zlib1g-dev
  5. apt install openssl libssl-dev
  6. cd /usr/nginx-1.18.0 进入编译安装目录
  7. ./configure 使用默认配置,若提示权限不够则先 chmod +x configure
  8. make
  9. make install
  10. whereis nginx 查找安装位置,会在 /usr/local/nginx/sbin 下
  11. /usr/local/nginx/conf/nginx.conf 中配置端口,设置字符集
  12. 启停
    cd /usr/local/nginx/sbin
    ./nginx 
    ./nginx -s stop
    ./nginx -s quit
    ./nginx -s reload
    

添加环境变量

  1. 修改 /etc/profile
  2. 尾部新增
    export PATH=$PATH:'/usr/local/nginx/sbin':'/usr/local/node-v16.13.2-linux-x64/bin'
  3. source /etc/profile
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值