You are not logged in.

#1 2012-12-16 08:43:35

dxxvi
Member
Registered: 2011-07-23
Posts: 122

[Solved] Unable to start Apache

Hi All,

I install Apache with "sudo pacman -S apache"but "sudo systemctl start httpd.service" failed and "sudo systemctl status httpd.service" showed:

httpd.service - Apache Web Server
	  Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
	  Active: failed (Result: exit-code) since Sun, 2012-12-16 03:36:39 EST; 7s ago
	 Process: 4844 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
	  CGroup: name=systemd:/system/httpd.service

Dec 16 03:36:39 ArchCustom apachectl[4844]: httpd: apr_sockaddr_info_get() failed for ArchCustom
Dec 16 03:36:39 ArchCustom apachectl[4844]: httpd: Could not reliably determine the server's fully qualified domain name, u...erName
Dec 16 03:36:39 ArchCustom systemd[1]: Failed to start Apache Web Server.
Dec 16 03:36:39 ArchCustom systemd[1]: Unit httpd.service entered failed state

Warning: Unit file changed on disk, 'systemctl --system daemon-reload' recommended.

Then I went to /etc/httpd/conf/httpd.conf and changed "#ServerName www.example.com:80" to "ServerName 192.168.4.19:80" (later I changed to "ServerName localhost:80", but it didn't work either). Now the systemctl status showed:

httpd.service - Apache Web Server
	  Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
	  Active: failed (Result: exit-code) since Sun, 2012-12-16 03:39:50 EST; 3s ago
	 Process: 4863 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
	  CGroup: name=systemd:/system/httpd.service

Dec 16 03:39:50 ArchCustom systemd[1]: Failed to start Apache Web Server.
Dec 16 03:39:50 ArchCustom systemd[1]: Unit httpd.service entered failed state

What should I do next?

Thanks.

Last edited by dxxvi (2012-12-20 11:48:20)

Offline

#2 2012-12-17 21:52:46

zenlord
Member
From: Belgium
Registered: 2006-05-24
Posts: 1,221
Website

Re: [Solved] Unable to start Apache

Read the wiki: https://wiki.archlinux.org/index.php/Apache

Configuring Apache can be tricky, so read up on that matter, or find a simple example to start from.

Offline

#3 2012-12-18 13:58:09

kaipee
Member
From: Belfast, UK
Registered: 2012-07-07
Posts: 214

Re: [Solved] Unable to start Apache

@dxxvi I have also been having issues with apache since I moved to systemd at the weekend. Manually running apache did work (sudo httpd, or sudo apachectl start) however systemctl never worked (it ran OK for roughly 1 minute then failed)

Please ignore below, it turns out my systemd switchover did not go correctly. My /var/run did not et correctly symlinked to /run hence why http.service was failing with /run/httpd/httpd.pid
Worth checking anyway....

I have only just noticed that the /usr/lib/systemd/system/httpd.service file is actually incorrect.

It should read

[Unit]
Description=Apache Web Server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/var/run/httpd/httpd.pid
ExecStart=/usr/sbin/apachectl start
ExecStop=/usr/sbin/apachectl graceful-stop
ExecReload=/usr/sbin/apachectl graceful
PrivateTmp=true
LimitNOFILE=infinity

[Install]
WantedBy=multi-user.target

*please note the line regarding PIDFile - should be /var/run/httpd/httpd.pid whereas upon initial install it was /run/httpd/httpd.pid

Can you please post your current /usr/lib/systemd/system/httpd.service file for comparison ?

Last edited by kaipee (2012-12-18 15:59:12)

Offline

#4 2012-12-18 16:06:32

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,835
Website

Re: [Solved] Unable to start Apache

If you've solved your problem, please modify your topic title to reflect that.

As a side note: don't edit /usr/lib/systemd/system/httpd.service, it will be overwitten when you upgrade/reinstall apache. If you need a custom service, copy /usr/lib/systemd/system/xyz.service to /etc/systemd/system/, any service file there overrides any "default" service of the same name.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#5 2012-12-18 16:24:52

kaipee
Member
From: Belfast, UK
Registered: 2012-07-07
Posts: 214

Re: [Solved] Unable to start Apache

@WorMzy I have marked mine as solved - this isn't my thread
I was only editing the file to troubleshoot issues

Offline

#6 2012-12-19 04:14:47

dxxvi
Member
Registered: 2011-07-23
Posts: 122

Re: [Solved] Unable to start Apache

zenlord wrote:

This is the easiest answer to give for my question "What should I do next?" smile Yes, I already read the wiki. Apache run successfully without any modification 3 - 4 times for me in the past. Now I install a new machine and it doesn't work this time.

kaipee wrote:

@dxxvi I have also been having issues with apache since I moved to systemd at the weekend.

Fortunately for me I installed my machine when systemd was already there. This is my /usr/lib/systemd/system/httpd.service

[Unit]
Description=Apache Web Server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/httpd/httpd.pid
ExecStart=/usr/sbin/apachectl start
ExecStop=/usr/sbin/apachectl graceful-stop
ExecReload=/usr/sbin/apachectl graceful
PrivateTmp=true
LimitNOFILE=infinity

[Install]
WantedBy=multi-user.target

and in my system /var/run is sym-linked to /run. And by the way, why is the location for the pid file important? I think we can put the pid file anywhere, right?
/usr/sbin/apachectl configtest says my httpd.conf is fine. However /usr/sbin/apachectl start exits with the status of 1.

Offline

#7 2012-12-19 16:13:09

kaipee
Member
From: Belfast, UK
Registered: 2012-07-07
Posts: 214

Re: [Solved] Unable to start Apache

I just noticed that my /run hadn't been correctly symlinked which was causing issues. I thought it would be worth you checking that also as systemd needs to verify the pid file exists before returning success.

Do you have anything in your /var/log/httpd/error.log(s) ?

Offline

#8 2012-12-20 11:47:36

dxxvi
Member
Registered: 2011-07-23
Posts: 122

Re: [Solved] Unable to start Apache

kaipee wrote:

Do you have anything in your /var/log/httpd/error.log(s) ?

Thank you and thank you and thank you very much smile My /var/log/httpd/error.log said "Name or service not known: mod_unique_id: unable to find IPv4 address of". My /etc/hosts looked like this:

#
# /etc/hosts: static lookup table for host names
#

#<ip-address>	<hostname.domain.org>	<hostname>
127.0.0.1	localhost.localdomain	localhost
::1		localhost.localdomain	localhost

Putting my machine name at the end of the 127.0.0.1 line makes Apache happy.

Offline

#9 2012-12-20 14:01:13

kaipee
Member
From: Belfast, UK
Registered: 2012-07-07
Posts: 214

Re: [Solved] Unable to start Apache

One noob helping another wink

Offline

Board footer

Powered by FluxBB