在Ubuntu 18.04上安装和配置Nginx

Ubuntu16.04解决问题:E: 无法获得锁 /var/lib/dpkg/lock-frontend - open (11: 资源暂时不可用)

在输入sudo apt-get update后发现终端提示:

E: 无法获得锁 /var/lib/dpkg/lock-frontend - open (11: 资源暂时不可用)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
解决方案一:
ps -e | grep apt


然后执行:sudo kill 进程号

 

 

解决方案二:
有一种情况是

sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
但我遇到的情况是:E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it? 

sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock-frontend
 

 

安装Nginx

Nginx的软件包在Ubuntu默认软件仓库中可用。 安装非常简单,只需键入以下命令:

 

sudo apt update
sudo apt install nginx

安装完成后,请检查Nginx服务的状态和版本:

 

sudo systemctl status nginx

输出:

● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en
Active: active (running) since Sat 2018-05-05 21:54:25 CST; 1 day 7h ago
Docs: man:nginx(8)
Main PID: 2188 (nginx)
Tasks: 5 (limit: 4471)
CGroup: /system.slice/nginx.service
├─2188 nginx: master process /usr/sbin/nginx -g daemon on; master_pro
├─2189 nginx: worker process
├─2190 nginx: worker process
├─2191 nginx: worker process
└─2192 nginx: worker process

5月 05 21:54:17 linuxidc systemd[1]: Starting A high performance web server and
5月 05 21:54:24 linuxidc nginx[2032]: nginx: [warn] conflicting server name "lin
5月 05 21:54:25 linuxidc nginx[2187]: nginx: [warn] conflicting server name "lin
5月 05 21:54:25 linuxidc systemd[1]: Started A high performance web server and a

 

sudo nginx -v

输出:

nginx version: nginx/1.14.0 (Ubuntu)

使用systemctl管理Nginx服务

您可以像任何其他systemd单位一样管理Nginx服务。 要停止Nginx服务,请运行:

 

sudo systemctl stop nginx

要再次启动,请键入:

 

sudo systemctl start nginx

重新启动Nginx服务:

 

sudo systemctl restart nginx

在进行一些配置更改后重新加载Nginx服务:

 

sudo systemctl reload nginx

如果你想禁用Nginx服务在启动时启动:

 

sudo systemctl disable nginx

并重新启用它:

 

sudo systemctl enable nginx

也可以使用service管理Nginx服务

停止Nginx服务,请运行:

 

sudo service nginx stop

要再次启动,请键入:

 

sudo service nginx start

重新启动Nginx服务:

 

sudo service nginx restart

在进行一些配置更改后重新加载Nginx服务:

 

sudo service nginx reload 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值