010.环境
Centos 7
nginx-1.19.0
020.准备工作
需要安装:
gcc
gcc-c++
PCRE
zlib
021.安装gcc
yum install gcc gcc-c++ -y
022.安装PCRE:
下载地址:https://sourceforge.net/projects/pcre/files/pcre/,本人下的是最新版本pcre-8.44.tar.gz
tar zxvf pcre-8.44.tar.gz -C /usr/local/
cd /usr/local/pcre-8.44
./configure
make && make install
023.安装zlib:
下载地址:http://zlib.net/
tar zxvf zlib-1.2.11.tar.gz -C /usr/local/
cd /usr/local/zlib-1.2.11
./configure
make && make install
030.安装nginx:
下载地址:http://nginx.org/en/download.html
tar zxvf nginx-1.19.0.tar.gz
cd /nginx-1.19.0
./configure
make && make install
安装后会在/usr/local/下生成nginx文件夹
mkdir /etc/nginx
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
cp /usr/local/nginx/conf/nginx.conf /etc/nginx/nginx.conf
cp /usr/local/nginx/conf/mime.types /etc/nginx/mime.types
nginx -c /etc/nginx/nginx.conf
040.开机启动:
vim /lib/systemd/system/nginx.service
添加以下内容:
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /etc/nginx/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
设置权限、开机启动:
chmod 745 /lib/systemd/system/nginx.service
systemctl enable nginx.service
050.简单的配置
# 隐藏版本号
server_tokens off;
060.参考资料: