nginx配置失败,卸载后重装出问题 awk: cannot open /etc/nginx/nginx.conf (No such file or directory)

nginx配置失败,卸载后重装出问题

 
wangyaofeng@wangyaofeng-NJ091AA-AB2-g3721cx:~$ sudo apt-get install nginx
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
将会安装下列额外的软件包:
  nginx-common nginx-core
建议安装的软件包:
  fcgiwrap nginx-doc
下列【新】软件包将被安装:
  nginx nginx-common nginx-core
升级了 0 个软件包,新安装了 3 个软件包,要卸载 0 个软件包,有 12 个软件包未被升级。
需要下载 0 B/348 kB 的软件包。
解压缩后会消耗掉 1,296 kB 的额外空间。
您希望继续执行吗? [Y/n] y
正在选中未选择的软件包 nginx-common。
(正在读取数据库 ... 系统当前共安装有 192360 个文件和目录。)
正准备解包 .../nginx-common_1.4.6-1ubuntu3.2_all.deb  ...
正在解包 nginx-common (1.4.6-1ubuntu3.2) ...
正在选中未选择的软件包 nginx-core。
正准备解包 .../nginx-core_1.4.6-1ubuntu3.2_amd64.deb  ...
正在解包 nginx-core (1.4.6-1ubuntu3.2) ...
正在选中未选择的软件包 nginx。
正准备解包 .../nginx_1.4.6-1ubuntu3.2_all.deb  ...
正在解包 nginx (1.4.6-1ubuntu3.2) ...
正在处理用于 man-db (2.6.7.1-1ubuntu1) 的触发器 ...
正在处理用于 ufw (0.34~rc-0ubuntu2) 的触发器 ...
正在处理用于 ureadahead (0.100.0-16) 的触发器 ...
ureadahead will be reprofiled on next reboot
正在设置 nginx-common (1.4.6-1ubuntu3.2) ...
正在设置 nginx-core (1.4.6-1ubuntu3.2) ...
awk: cannot open /etc/nginx/nginx.conf (No such file or directory)
正在设置 nginx (1.4.6-1ubuntu3.2) ...



解决办法
参考 http://www.111cn.net/sys/nginx/69517.htm

完全卸载nginx

在配置nginx做实验时配置错了,导致访问不了虚拟主机。一狠心把nginx的配置文件目录(/etc/nginx)都删除了,而且我没有备份这些配置文件,因此想重装nginx。

    本来以为直接使用如下apt-get指令

        sudo apt-get --purge remove nginx
        sudo apt-get install nginx

    就可以搞定,但实际上并没有有自动产生nginx的配置文件,连/etc/nginx目录都没产生。
    于是autoremove

        sudo apt-get --purge remove nginx
        sudo apt-get autoremove
        sudo apt-get install nginx

    提示

        awk: cannot open /etc/nginx/nginx.conf (No such file or directory)

    虽然产生了/etc/nginx目录了,但只有部分配置文件

        conf.d sites-available sites-enabled

    于是

        sudo apt-get --purge remove nginx
        sudo apt-get autoremove

        dpkg --get- selections|grep nginx

    罗列除与nginx相关的软件,

        nginx-common deinstall

    然后sdfsd

        sudo apt-get --purge remove nginx-common
        sudo apt-get install nginx

    然后OK!
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值