# apache2 not working on my system.  [solved]

## cwc

I used this guide: https://wiki.gentoo.org/wiki/Apache

I have not installed php yet.

I am running a legacy system:

# uname -a

Linux azzerare 4.0.5-gentoo #3 SMP Tue Aug 18 17:42:11 PDT 2015 x86_64 AMD Athlon(tm) 64 Processor 3400+ AuthenticAMD GNU/Linux

  [5]   default/linux/amd64/13.0/desktop/gnome/systemd *

When I issue a restart and stop and start

azzerare apache2 # /etc/init.d/apache2 restart

 * WARNING: apache2 is already starting

azzerare apache2 # /etc/init.d/apache2 stop

 * ERROR: apache2 stopped by something else

azzerare apache2 # /etc/init.d/apache2 start

 * WARNING: apache2 is already starting

azzerare apache2 # 

I also do not let a "It works?"  from localhost.

As you can see I have systemd installed.  Could this be the problem?

----------

## lexflex

Hi cwc,

Is there anything in the logfiles ?   (  /var/log/apache2/error_log  or something like that)

Maybe also check using ps if all Apache processes are killed before trying to restart, to make sure you start without Apache still running.

Alex.

----------

## kikko

Hi cwc

IMHO, systemd is a political problem, really...  :Razz: 

On systemd controlled systems, aren't services managed by systemctl command, instead of /etc/init.d/ scripts? 

I have little, Arch-derived systemd experience, so I'm not sure how it behaves on Gentoo

Anyway, I have 2 suggestion for your troubleshooting:

- if Apache starts running you should find some messages in the error_log ("/var/log/apache2/error_log"? see the "ErrorLog" directive in your httpd.conf file)

- if SSL is enabled (and the Wiki says it's by default), you'll need an X.509 key pair ("/etc/ssl/apache2/server.(key|crt)", usually generated with openssl)

  you can remove the "-D SSL" from your "/etc/conf.d/apache2" for troubleshooting purposes (if configuration under /etc/conf.d are managed by systemd, don't know that...)

Let me know if you find something

----------

## cwc

Thanks for the posts.

azzerare apache2 # pwd

/var/log/apache2

azzerare apache2 # ls

nothing in the log files

hmmmm.  

Points:

1. I am glad I installed systemd because I learned something. Actually a lot.

2. I like Gnome3  because I can print easily from my system and use some of the multimedia tools that were difficult to configure with xfce4.

3.  Right now apache2 is a must because I develop small php apps.

4.  Question?  Remove systemd and keep gnome using the Funtoo method

https://wiki.gentoo.org/wiki/GNOME/GNOME_Without_systemd

Here are my systemctl services:

```

azzerare apache2 # systemctl 

UNIT                                                               LOAD   ACTIVE SUB       DESCRIPTION

proc-sys-fs-binfmt_misc.automount                                  loaded active running   Arbitrary Executable File Formats File System Automount Point

sys-devices-pci0000:00-0000:00:02.0-0000:02:00.1-sound-card0.device loaded active plugged   GT216 HDMI Audio Controller

sys-devices-pci0000:00-0000:00:0f.0-ata1-host0-target0:0:0-0:0:0:0-block-sr0.device loaded active plugged   HP_DVD_Writer_1260t

sys-devices-pci0000:00-0000:00:0f.0-ata2-host1-target1:0:0-1:0:0:0-block-sda-sda1.device loaded active plugged   WDC_WD3200AAKS-00UU3A0 1

sys-devices-pci0000:00-0000:00:0f.0-ata2-host1-target1:0:0-1:0:0:0-block-sda-sda2.device loaded active plugged   WDC_WD3200AAKS-00UU3A0 2

sys-devices-pci0000:00-0000:00:0f.0-ata2-host1-target1:0:0-1:0:0:0-block-sda-sda3.device loaded active plugged   WDC_WD3200AAKS-00UU3A0 3

sys-devices-pci0000:00-0000:00:0f.0-ata2-host1-target1:0:0-1:0:0:0-block-sda.device loaded active plugged   WDC_WD3200AAKS-00UU3A0

sys-devices-pci0000:00-0000:00:0f.0-ata3-host2-target2:0:0-2:0:0:0-block-sdb-sdb1.device loaded active plugged   WDC_WD1002FAEX-00Z3A0 1

sys-devices-pci0000:00-0000:00:0f.0-ata3-host2-target2:0:0-2:0:0:0-block-sdb.device loaded active plugged   WDC_WD1002FAEX-00Z3A0

sys-devices-pci0000:00-0000:00:0f.0-ata4-host3-target3:0:0-3:0:0:0-block-sdc-sdc1.device loaded active plugged   WDC_WD1002FAEX-00Z3A0 1

sys-devices-pci0000:00-0000:00:0f.0-ata4-host3-target3:0:0-3:0:0:0-block-sdc.device loaded active plugged   WDC_WD1002FAEX-00Z3A0

sys-devices-pci0000:00-0000:00:10.1-usb3-3\x2d2-3\x2d2:1.0-tty-ttyACM0.device loaded active plugged   Uno R3 (CDC ACM)

sys-devices-pci0000:00-0000:00:12.0-net-enp0s18.device             loaded active plugged   VT6102 [Rhine-II] (A7V600-X Motherboard)

sys-devices-pci0000:00-0000:00:13.0-0000:04:01.0-sound-card1.device loaded active plugged   VT8237A/VT8251 HDA Controller

sys-devices-platform-serial8250-tty-ttyS0.device                   loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS0

sys-devices-platform-serial8250-tty-ttyS2.device                   loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS2

sys-devices-platform-serial8250-tty-ttyS3.device                   loaded active plugged   /sys/devices/platform/serial8250/tty/ttyS3

sys-devices-pnp0-00:05-tty-ttyS1.device                            loaded active plugged   /sys/devices/pnp0/00:05/tty/ttyS1

sys-devices-virtual-net-sit0.device                                loaded active plugged   /sys/devices/virtual/net/sit0

sys-subsystem-net-devices-enp0s18.device                           loaded active plugged   VT6102 [Rhine-II] (A7V600-X Motherboard)

sys-subsystem-net-devices-sit0.device                              loaded active plugged   /sys/subsystem/net/devices/sit0

-.mount                                                            loaded active mounted   /

boot.mount                                                         loaded active mounted   /boot

dev-hugepages.mount                                                loaded active mounted   Huge Pages File System

dev-mqueue.mount                                                   loaded active mounted   POSIX Message Queue File System

mnt-due.mount                                                      loaded active mounted   /mnt/due

mnt-uno.mount                                                      loaded active mounted   /mnt/uno

proc-sys-fs-binfmt_misc.mount                                      loaded active mounted   Arbitrary Executable File Formats File System

run-user-1000.mount                                                loaded active mounted   /run/user/1000

sys-kernel-debug.mount                                             loaded active mounted   Debug File System

tmp.mount                                                          loaded active mounted   Temporary Directory

systemd-ask-password-console.path                                  loaded active waiting   Dispatch Password Requests to Console Directory Watch

systemd-ask-password-wall.path                                     loaded active waiting   Forward Password Requests to Wall Directory Watch

session-1.scope                                                    loaded active running   Session 1 of user cwc

accounts-daemon.service                                            loaded active running   Accounts Service

avahi-daemon.service                                               loaded active running   Avahi mDNS/DNS-SD Stack

colord.service                                                     loaded active running   Manage, Install and Generate Color Profiles

dbus.service                                                       loaded active running   D-Bus System Message Bus

gdm.service                                                        loaded active running   GNOME Display Manager

getty@tty1.service                                                 loaded active running   Getty on tty1

kmod-static-nodes.service                                          loaded active exited    Create list of required static device nodes for the current kernel

polkit.service                                                     loaded active running   Authorization Manager

systemd-fsck-root.service                                          loaded active exited    File System Check on Root Device

systemd-fsck@dev-sda1.service                                      loaded active exited    File System Check on /dev/sda1

systemd-fsck@dev-sdb1.service                                      loaded active exited    File System Check on /dev/sdb1

systemd-fsck@dev-sdc1.service                                      loaded active exited    File System Check on /dev/sdc1

systemd-journal-flush.service                                      loaded active exited    Flush Journal to Persistent Storage

systemd-journald.service                                           loaded active running   Journal Service

systemd-logind.service                                             loaded active running   Login Service

systemd-networkd.service                                           loaded active running   Network Service

systemd-random-seed.service                                        loaded active exited    Load/Save Random Seed

systemd-remount-fs.service                                         loaded active exited    Remount Root and Kernel File Systems

systemd-sysctl.service                                             loaded active exited    Apply Kernel Variables

systemd-tmpfiles-setup-dev.service                                 loaded active exited    Create Static Device Nodes in /dev

systemd-tmpfiles-setup.service                                     loaded active exited    Create Volatile Files and Directories

systemd-udev-trigger.service                                       loaded active exited    udev Coldplug all Devices

systemd-udevd.service                                              loaded active running   udev Kernel Device Manager

systemd-update-utmp.service                                        loaded active exited    Update UTMP about System Boot/Shutdown

systemd-user-sessions.service                                      loaded active exited    Permit User Sessions

systemd-vconsole-setup.service                                     loaded active exited    Setup Virtual Console

udisks2.service                                                    loaded active running   Disk Manager

upower.service                                                     loaded active running   Daemon for power management

user@1000.service                                                  loaded active running   User Manager for UID 1000

wpa_supplicant.service                                             loaded active running   WPA supplicant

-.slice                                                            loaded active active    Root Slice

system-getty.slice                                                 loaded active active    system-getty.slice

system-systemd\x2dfsck.slice                                       loaded active active    system-systemd\x2dfsck.slice

system.slice                                                       loaded active active    System Slice

user-1000.slice                                                    loaded active active    user-1000.slice

user.slice                                                         loaded active active    User and Session Slice

avahi-daemon.socket                                                loaded active running   Avahi mDNS/DNS-SD Stack Activation Socket

dbus.socket                                                        loaded active running   D-Bus System Message Bus Socket

systemd-initctl.socket                                             loaded active listening /dev/initctl Compatibility Named Pipe

systemd-journald-audit.socket                                      loaded active running   Journal Audit Socket

systemd-journald-dev-log.socket                                    loaded active running   Journal Socket (/dev/log)

systemd-journald.socket                                            loaded active running   Journal Socket

systemd-shutdownd.socket                                           loaded active listening Delayed Shutdown Socket

systemd-udevd-control.socket                                       loaded active running   udev Control Socket

systemd-udevd-kernel.socket                                        loaded active running   udev Kernel Socket

dev-sda2.swap                                                      loaded active active    /dev/sda2

basic.target                                                       loaded active active    Basic System

getty.target                                                       loaded active active    Login Prompts

graphical.target                                                   loaded active active    Graphical Interface

local-fs-pre.target                                                loaded active active    Local File Systems (Pre)

local-fs.target                                                    loaded active active    Local File Systems

multi-user.target                                                  loaded active active    Multi-User System

network.target                                                     loaded active active    Network

nss-user-lookup.target                                             loaded active active    User and Group Name Lookups

paths.target                                                       loaded active active    Paths

remote-fs.target                                                   loaded active active    Remote File Systems

slices.target                                                      loaded active active    Slices

sockets.target                                                     loaded active active    Sockets

sound.target                                                       loaded active active    Sound Card

swap.target                                                        loaded active active    Swap

sysinit.target                                                     loaded active active    System Initialization

timers.target                                                      loaded active active    Timers

systemd-tmpfiles-clean.timer                                       loaded active waiting   Daily Cleanup of Temporary Directories

```

----------

## kikko

Hi cwc

what are the permissions of "/var/log/apache2" folder? 

you can try start the service on a terminal (just for troubleshooting purposes, of course  :Wink:  )

```
/sbin/httpd -k start -e debug -f /etc/apache2/httpd.conf
```

I'm not 100% sure httpd binary is in /sbin/... anyway you can give it a try

----------

## cwc

 *kikko wrote:*   

> Hi cwc
> 
> what are the permissions of "/var/log/apache2" folder? 
> 
> you can try start the service on a terminal (just for troubleshooting purposes, of course  )
> ...

 

drwxr-x--- 2 apache  apache            4096 Sep 15 05:15 apache2

no:

#/sbin/httpd

or

#/bin/httpd

----------

## cwc

 *kikko wrote:*   

> Hi cwc
> 
> IMHO, systemd is a political problem, really... 
> 
> On systemd controlled systems, aren't services managed by systemctl command, instead of /etc/init.d/ scripts? 
> ...

 

Missed this:

```

- if SSL is enabled (and the Wiki says it's by default), you'll need an X.509 key pair ("/etc/ssl/apache2/server.(key|crt)", usually generated with openssl) 

```

Interesting I should find help here:

http://gentoo-en.vfose.ru/wiki/Apache2/SSL_Certificates

Think I'll try to leave ssl and figure out how to set the key.  I've only one it once before using Centos.

Throw me a bone on setting the server.key  

I am going to have to learn how to do this.

Thanks

----------

## kikko

 :Confused:   WTF? httpd binary name is /usr/sbin/apache2 in Gentoo...  :Confused: 

Ok, so you can do the troubleshooting steps using /usr/sbin/apache2 instead of httpd: 

chech the syntax of config file 

```
 # /usr/sbin/apache2 -t
```

start Apache2 in debug mode 

```
 # /usr/sbin/apache2 -X -D DEFAULT_VHOST
```

Default config doesn't seem to work OOTB in debug mode  :Shocked: 

you must add the "-D DEFAULT_VHOST" part to have the Listen port configuration loaded...

for the SSL part, OpenSSL is the (only, for now) tool of choice; take a look at this http://www.akadia.com/services/ssh_test_certificate.html on creating personal, self-signed certificates  :Wink: 

----------

## cwc

azzerare ~ # systemctl enable apache2.service

Created symlink from /etc/systemd/system/multi-user.target.wants/apache2.service to /usr/lib64/systemd/system/apache2.service.

azzerare ~ # systemctl start apache2.service

It works!

----------

## cwc

I had no idea apache2.service was available it did not show on the systemctl list.

azzerare ~ # systemctl enable apache2.service

Created symlink from /etc/systemd/system/multi-user.target.wants/apache2.service to /usr/lib64/systemd/system/apache2.service.

azzerare ~ # systemctl start apache2.service

Apache2 now works.

It works?

----------

