ubuntu下安装nginx

1.更新下载源

sudo apt-get update

2.安装3个依赖pcre zlib openssl

sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install zlib1g-dev
sudo apt-get install openssl libssl-dev
3.下载nginx

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

4.解压

tar -zxvf nginx-1.23.2.tar.gz
5. 进入解压后的nginx目录,安装配置nginx
./configure --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module
=======================================================
注意:
如果报错

checking for C compiler .. not found

./configure: error: C compiler cc is not found

执行以下命令:

sudo apt-get install build-essential
=======================================================
6.安装
sudo make && sudo make install
7.配置服务/lib/systemd/system/nginx.service

[Unit]
Description=A high performance web server and a reverse proxy server
After=network.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=-/sbin/local/nginx/sbin/nginx -s stop
TimeoutStopSec=5
KillMode=mixed

[Install]
WantedBy=multi-user.target

8.设置服务

systemctl daemon-reload

systemctl enable nginx.service 设置开机启动

systemctl start nginx.service

systemctl restart nginx.service

注意:

systemctl 管理 nginx 与 systemctl start nginx 卡住问题

因为/lib/systemd/system/nginx.service中设置的PIDFile=/run/nginx.pid

要和nginx.conf中的pid保持一致,因此需要修改nginx.conf设置 pid /run/nginx.pid;


暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
下一篇