如何删除nginx并重新激活apache?

我已经在我的Ubuntu 14.04上安装了Apache2, mysql, php5 and phpmyadmin ,但后来错误地安装了nginx。

现在我的localhost页面显示欢迎使用nginx服务器 。 并且localhost/phpmyadmin链接不起作用。

如何恢复LAMP服务器?

我使用命令删除了ngnix

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

安装apache

 sudo apache2ctl restart 

但最后重启apache2我得到这个错误

 sudo apache2ctl restart AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message httpd not running, trying to start (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down AH00015: Unable to open logs Action 'restart' failed. 

首先,你需要停止nginx以便释放端口80,以便apache2可以在以后监听它。

 sudo service nginx stop 

接下来,如果使用apt-get安装nginx ,可以通过运行以下两个命令之一来删除它(我在下一段中解释了不同之处)

 sudo apt-get remove nginx 

要么

 sudo apt-get purge nginx 

它们都删除了所有包文件,而第二个也删除了包安装的配置文件。
如果您打算稍后使用nginx进行配置,请使用remove 否则,我建议使用purge

删除nginx ,您可以重新启动apache以确保它正在侦听端口80。

 sudo apache2ctl restart 

如果您在安装nginx之前删除了apache ,则可以重新安装它

 sudo apt-get install apache2 

如果之后欢迎来到nginx! 页面出现你可以尝试unistall服务器上存在的nginx上的其他版本

sudo apt-get remove nginx-*

sudo apt-get purge nginx-*

删除所有nginx包

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

这对我有用

 sudo service apache2 restart 

在我的情况下,使用Deepin,我不得不做更多

 sudo apt-get remove nginx-* 

执行

 sudo apt-get autoremove 

当我完成时,我意识到了这一点

 sudo apache2ctl restart 

阿帕奇也被删除了。 我重新安装了命令

 sudo apt-get install apache2 

我重启了服务

 sudo service apache2 restart