debian9.2 编译安装nginx

1. 安装基础依赖系统模块

apt-get update   #更新源

 apt-get install libpcre3 libpcre3-dev openssl libssl-dev  pcre zlib*  

2 。下载源码

 wget http://nginx.org/download/nginx-1.13.12.tar.gz

tar -xzvf nginx...

3.  ./configure --help  # 查看配置 根据需要 进行配置 不再赘言

4.make && make install  #编译安装

5.echo PATH=$PATH:/usr/local/nging/sbin >> /etc/profile  #设置环境变量 (根据实际安装路径进行设置,不赘言)

6. source /etc/profile

7.vim /lib/systemd/system/nginx.service 录入以下内容:

[Unit]
Description=nginx
After=network.target


[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true


[Install]

WantedBy=multi-user.target

原理在 https://wizardforcel.gitbooks.io/vbird-linux-basic-4e/content/150.html  自己去看, 根据实际情况进行配置

8 . systemctl enable nginx #开机启动

9.systemctl start nginx # 启动nginx   

debian9.2 编译安装nginx_第1张图片 

成功 ,看此篇博客不要一路粘贴,自己理解着走,因为都是手打的,不保证每个命令的正确性,所以有可能单词是错的 

你可能感兴趣的:(nginx,linux)