我尝试通过以下方式在 ubuntu 16.04 lts 上安装 apache2:
sudo apt-get install apache2 -y
输出结果如下:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2-data apache2-utils
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom
The following NEW packages will be installed:
apache2 apache2-data apache2-utils
0 upgraded, 3 newly installed, 0 to remove and 1 not upgraded.
Need to get 330 kB of archives.
After this operation, 1,718 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 apache2-utils amd64 2.4.18-2ubuntu3.9 [81.8 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 apache2-data all 2.4.18-2ubuntu3.9 [162 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 apache2 amd64 2.4.18-2ubuntu3.9 [86.6 kB]
Fetched 330 kB in 0s (439 kB/s)
Selecting previously unselected package apache2-utils.
(Reading database ... 470444 files and directories currently installed.)
Preparing to unpack .../apache2-utils_2.4.18-2ubuntu3.9_amd64.deb ...
Unpacking apache2-utils (2.4.18-2ubuntu3.9) ...
Selecting previously unselected package apache2-data.
Preparing to unpack .../apache2-data_2.4.18-2ubuntu3.9_all.deb ...
Unpacking apache2-data (2.4.18-2ubuntu3.9) ...
Selecting previously unselected package apache2.
Preparing to unpack .../apache2_2.4.18-2ubuntu3.9_amd64.deb ...
Unpacking apache2 (2.4.18-2ubuntu3.9) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for systemd (229-4ubuntu21.16) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for ufw (0.35-0ubuntu2) ...
Rules updated for profile 'Apache Full'
Rules updated for profile 'OpenSSH'
Firewall reloaded
Setting up apache2-utils (2.4.18-2ubuntu3.9) ...
Setting up apache2-data (2.4.18-2ubuntu3.9) ...
Setting up apache2 (2.4.18-2ubuntu3.9) ...
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
invoke-rc.d: initscript apache2, action "start" failed.
● 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 Sat 2019-03-02 18:07:41 CET; 5ms ago
Docs: man:systemd-sysv-generator(8)
Process: 17497 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)
Mar 02 18:07:41 gervis apache2[17497]: *
Mar 02 18:07:41 gervis apache2[17497]: * The apache2 configtest failed.
Mar 02 18:07:41 gervis apache2[17497]: Output of config test was:
Mar 02 18:07:41 gervis apache2[17497]: apache2: Syntax error on line 219 of...d.
Mar 02 18:07:41 gervis apache2[17497]: Action 'configtest' failed.
Mar 02 18:07:41 gervis apache2[17497]: The Apache error log may have more i...n.
Mar 02 18:07:41 gervis systemd[1]: apache2.service: Control process exited,...=1
Mar 02 18:07:41 gervis systemd[1]: Failed to start LSB: Apache2 web server.
Mar 02 18:07:41 gervis systemd[1]: apache2.service: Unit entered failed state.
Mar 02 18:07:41 gervis systemd[1]: apache2.service: Failed with result 'exi...'.
Hint: Some lines were ellipsized, use -l to show in full.
/etc/apache2/apache2.conf 第 219 行如下
但我不知道如何使用这些信息:
Some lines were ellipsized, use -l to show in full.
任何关于此问题的帮助都将受到感谢。
我也尝试过
systemctl status apache2.service
输出如下:
● 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 Sat 2019-03-02 19:36:17 CET; 1min 44s ago
Docs: man:systemd-sysv-generator(8)
Process: 24739 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)
Mar 02 19:36:17 gervis apache2[24739]: *
Mar 02 19:36:17 gervis apache2[24739]: * The apache2 configtest failed.
Mar 02 19:36:17 gervis apache2[24739]: Output of config test was:
Mar 02 19:36:17 gervis apache2[24739]: apache2: Syntax error on line 219 of /etc/apache2/apache2.conf: Syntax error on line 21 of /etc/apache2/sites-enabled/squirrelmail.conf: /etc/apache2/sites-enabled/squirrelmail.conf:21: <VirtualHost> was not closed.
Mar 02 19:36:17 gervis apache2[24739]: Action 'configtest' failed.
Mar 02 19:36:17 gervis apache2[24739]: The Apache error log may have more information.
Mar 02 19:36:17 gervis systemd[1]: apache2.service: Control process exited, code=exited status=1
Mar 02 19:36:17 gervis systemd[1]: Failed to start LSB: Apache2 web server.
Mar 02 19:36:17 gervis systemd[1]: apache2.service: Unit entered failed state.
Mar 02 19:36:17 gervis systemd[1]: apache2.service: Failed with result 'exit-code'.
因此我尝试按照@steeldriver 的建议查看 /sites-enabled/squirrelmail.conf。第 21 行显示:
那儿有问题吗?
答案1
#
从文件第 24 行中删除/sites-enabled/squirrelmail.conf
,其中 是结束标记VirtulaHost
。