nginx 1.22.0 linux安装
时间: 2024-01-30 20:11:59 浏览: 120
以下是在Linux环境下安装nginx 1.22.0的步骤:
1. 下载nginx安装包:
```shell
wget http://nginx.org/download/nginx-1.22.0.tar.gz
```
2. 解压安装包:
```shell
tar -zxvf nginx-1.22.0.tar.gz
```
3. 进入解压后的目录:
```shell
cd nginx-1.22.0
```
4. 配置编译参数:
```shell
./configure
```
5. 编译并安装nginx:
```shell
make
sudo make install
```
6. 创建nginx服务配置文件:
```shell
sudo vi /lib/systemd/system/nginx.service
```
7. 在配置文件中添加以下内容:
```
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx
ExecStop=/usr/local/nginx/sbin/nginx
PrivateTmp=true
[Install]
WantedBy=multi-user.target
```
8. 重新加载systemd配置:
```shell
sudo systemctl daemon-reload
```
9. 设置nginx开机自启动:
```shell
sudo systemctl enable nginx
```
10. 启动nginx服务:
```shell
sudo systemctl start nginx
```
11. 检查nginx服务状态:
```shell
sudo systemctl status nginx
```
以上是安装nginx 1.22.0的步骤,你可以按照这些步骤在Linux环境下安装nginx。
阅读全文