CentOS 7 编译安装 Nginx https://www.cnblogs.com/liujuncm5/p/6713784.html
- 确认有 gcc ,无则 yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
- 在 http://nginx.org/en/download.html 下载 stable version ,解压文件夹移入 /usr
cd /usr/nginx-1.18.0
进入编译安装目录./configure
使用默认配置,若提示权限不够则先chmod +x configure
make
make install
whereis nginx
查找安装位置,会在 /usr/local/nginx/sbin 下/usr/local/nginx/conf/nginx.conf
中配置端口,设置字符集- 启停
cd /usr/local/nginx/sbin ./nginx ./nginx -s stop ./nginx -s quit ./nginx -s reload
ubuntu 20.04 安装 Nginx
sudo apt install nginx
sudo systemctl disable nginx
禁止开机启动- 修改 /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 参考
- 官网下载
apt install build-essential libtool
apt install libpcre3 libpcre3-dev
apt install zlib1g zlib1g-dev
apt install openssl libssl-dev
cd /usr/nginx-1.18.0
进入编译安装目录./configure
使用默认配置,若提示权限不够则先chmod +x configure
make
make install
whereis nginx
查找安装位置,会在 /usr/local/nginx/sbin 下/usr/local/nginx/conf/nginx.conf
中配置端口,设置字符集- 启停
cd /usr/local/nginx/sbin ./nginx ./nginx -s stop ./nginx -s quit ./nginx -s reload
添加环境变量
- 修改 /etc/profile
- 尾部新增
export PATH=$PATH:'/usr/local/nginx/sbin':'/usr/local/node-v16.13.2-linux-x64/bin'
source /etc/profile