我在 15.10 上安装了 lamp。它正常工作。昨天我将我的 ubuntu 计算机从 15.10 更新到了 16.04。我尝试访问 localhost,但没有成功。
我尝试过service apache2 restart
并收到以下错误:
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: failed (Result: exit-code) since Sun 2017-06-25 13:50:20 IST; 1min 0s ago
Docs: man:systemd-sysv-generator(8)
Process: 5414 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)
Jun 25 13:50:20 ajay-Lenovo-G50-70 apache2[5414]: *
Jun 25 13:50:20 ajay-Lenovo-G50-70 apache2[5414]: * The apache2 configtest failed.
Jun 25 13:50:20 ajay-Lenovo-G50-70 apache2[5414]: Output of config test was:
Jun 25 13:50:20 ajay-Lenovo-G50-70 apache2[5414]: apache2: Syntax error on line 140 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: cannot open shared object file: No such file or directory
Jun 25 13:50:20 ajay-Lenovo-G50-70 apache2[5414]: Action 'configtest' failed.
Jun 25 13:50:20 ajay-Lenovo-G50-70 apache2[5414]: The Apache error log may have more information.
Jun 25 13:50:20 ajay-Lenovo-G50-70 systemd[1]: apache2.service: Control process exited, code=exited status=1
Jun 25 13:50:20 ajay-Lenovo-G50-70 systemd[1]: Failed to start LSB: Apache2 web server.
Jun 25 13:50:20 ajay-Lenovo-G50-70 systemd[1]: apache2.service: Unit entered failed state.
Jun 25 13:50:20 ajay-Lenovo-G50-70 systemd[1]: apache2.service: Failed with result 'exit-code'.
答案1
明白了,伙计们!别担心!
我了解到 16.04 附带的是 php 7.0 而不是 5.0。我猜是我为 apache 安装了 php 5.0 的模块。
安装php7.0 apache模块:
sudo apt-get install libapache2-mod-php7.0
禁用 php5 模块,因为我们没有 php5.0:
sudo a2dismod php5
启用php7模块:
sudo a2enmod php7.0
重新启动Apache:
sudo service apache2 restart
就这样吧,伙计们