# Apache2 stopped working after update

## walterbyrd

```

# uname -a

Linux fir 4.9.34-calculate #1 SMP PREEMPT Thu Jun 29 11:17:11 UTC 2017 x86_64 AMD Athlon(tm) II X4 640 Processor AuthenticAMD GNU/Linux

```

```

# apache2 -v

Server version: Apache/2.4.25 (Unix)

Server built:   Jun 16 2017 12:26:08

```

I think I am running php 5.6. Since I cannot load the module, I am not sure how to tell.

I used the instructions from the wiki:

https://wiki.gentoo.org/wiki/Apache

https://wiki.gentoo.org/wiki/PHP

This is a new apache2 install. I don't think it was working right before the update.

Before the update, I created this file: /var/www/localhost/htdocs/index.php 

```

<html>

 <body>

  <?php phpinfo(); ?>

 </body>

</htm>

```

And it worked. 

But, anything I put in a sub-directory off /var/www/localhost/htdocs/ would not work. 

i.e. /var/www/localhost/htdocs/moodle/index.php would not work.

After I did a system update, apache2 will not start at all.

```

# rc-config start apache2

Starting init script

netmount          | * Mounting network filesystems ...                    [ ok ]

apache2           | * apache2 has detected an error in your setup:

apache2           |apache2: 

Syntax error on line 150 of /etc/apache2/httpd.conf: 

Syntax error on line 7 of /etc/apache2/modules.d/70_mod_php.conf: 

Syntax error on line 2 of /var/lib/eselect-php/mod_php.conf:

: 

Cannot load modules/mod_php.so into server: /usr/lib64/apache2/modules/mod_php.so: 

cannot open shared object file: No such file or directory

apache2           | * ERROR: apache2 failed to start

```

Here is line 150 of /etc/apache2/httpd.conf

```
Include /etc/apache2/modules.d/*.conf
```

Here is line 7 of /etc/apache2/modules.d/70_mod_php.conf

```
Include "/var/lib/eselect-php/mod_php.conf"
```

Here is line 2 of /var/lib/eselect-php/mod_php.conf

```
LoadModule php7_module modules/mod_php.so
```

I am not sure why that specifies php7 - I never put that there.

----------

## fturco

Please post the output of:

```
emerge -pv www-servers/apache dev-lang/php
```

Also, did you run etc-update or similar tools after the upgrade?

----------

## walterbyrd

```

# emerge -pv www-servers/apache dev-lang/php

Local copy of remote index is up-to-date and will be used.

These are the packages that would be merged, in order:

Calculating dependencies... done!

[binary  N     ] dev-libs/oniguruma-5.9.5::gentoo  USE="-combination-explosion-check -crnl-as-line-terminator -static-libs" ABI_X86="(64) -32 (-x32)" 0 KiB

[binary  N     ] dev-libs/libmcrypt-2.5.8-r4::gentoo  0 KiB

[binary   R    ] www-servers/apache-2.4.25:2::gentoo  USE="ssl threads -debug -doc -ldap (-libressl) (-selinux) -static -suexec" APACHE2_MODULES="actions alias auth_basic auth_digest authn_alias authn_anon authn_core authn_dbm authn_file authz_core authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif socache_shmcb speling status unique_id unixd userdir usertrack vhost_alias -access_compat -asis -authn_dbd -authz_dbd -cache_disk -cache_socache -cern_meta -charset_lite -dbd -dumpio -http2 -ident -imagemap -lbmethod_bybusyness -lbmethod_byrequests -lbmethod_bytraffic -lbmethod_heartbeat -log_forensic -macro -proxy -proxy_ajp -proxy_balancer -proxy_connect -proxy_fcgi -proxy_ftp -proxy_html -proxy_http -proxy_scgi -proxy_wstunnel -ratelimit -remoteip -reqtimeout -slotmem_shm -substitute -version" APACHE2_MPMS="-event -prefork -worker" 0 KiB

[binary  N     ] app-eselect/eselect-php-0.9.2::gentoo  USE="apache2 fpm" 0 KiB

[binary  N     ] dev-lang/php-7.0.19:7.0::gentoo  USE="acl apache2 berkdb bzip2 cli crypt ctype curl exif fileinfo filter fpm ftp gd gdbm hash iconv ipv6 json mysql nls opcache pdo phar posix readline session simplexml sockets sqlite ssl threads tokenizer truetype unicode webp xml xmlreader xmlwriter zip zlib -bcmath -calendar -cdb -cgi -cjk -coverage -debug -embed -enchant (-firebird) -flatfile -gmp -imap -inifile -intl -iodbc -kerberos -ldap -ldap-sasl -libedit (-libressl) -mhash -mssql -mysqli -oci8-instant-client -odbc -pcntl -phpdbg -postgres -qdbm -recode (-selinux) -sharedmem -snmp -soap -spell (-systemd) -sysvipc -tidy -wddx -xmlrpc -xpm -xslt" 0 KiB

Total: 5 packages (4 new, 1 reinstall, 5 binaries), Size of downloads: 0 KiB

 * IMPORTANT: 3 news items need reading for repository 'gentoo'.

 * Use eselect news read to view new items.

```

----------

## fturco

You probably need to install dev-lang/php. And read news items with eselect.

----------

## toralf

 *walterbyrd wrote:*   

> 
> 
> ```
> 
> # emerge -pv www-servers/apache dev-lang/php
> ...

 Where is your old PHP ?

----------

## toralf

 *walterbyrd wrote:*   

> [code]But, anything I put in a sub-directory off /var/www/localhost/htdocs/ would not work.

 Are those PHP scripts displayed as text ? Because that means it works as expected. You've to tell Apache to *run* PHP-scripts in a particular subdir instead displaying them as text files (the later is the default mode of a web server).

----------

## walterbyrd

 *fturco wrote:*   

> You probably need to install dev-lang/php. And read news items with eselect.

 

I thought I had. This was working.

```

<html>

 <body>

  <?php phpinfo(); ?>

 </body>

</htm> 

```

After the update, I could no longer start apache2.

Even if PHP is not installed, shouldn't apache2 start?Last edited by walterbyrd on Mon Jul 10, 2017 3:56 pm; edited 1 time in total

----------

## walterbyrd

 *Quote:*   

> Are those PHP scripts displayed as text ? 

 

No. I was getting some error. I should have taken better notes. 

Now, apache2 will not even run. If I can get apache2 running again, I will see what happens.

----------

## fturco

 *walterbyrd wrote:*   

> Even if PHP is not installed, shouldn't apache2 start?

 

Apache won't start if you include PHP modules in the configuration files and PHP is missing.

----------

## walterbyrd

After updating. I have apache2 running again.

I have an app called opigno running in a subdirectory off /var/www/localhost/htdocs

When I try to run /var/www/localhost/htdocs/opigno/index.php

I get:

```

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache Server at fir Port 80

```

The permissions are wide open.Last edited by walterbyrd on Wed Jul 12, 2017 5:24 pm; edited 1 time in total

----------

## Hu

Per the hint from the output you quoted, what does the error log say about this failure?

----------

## toralf

 *walterbyrd wrote:*   

> 
> 
> ```
> ...
> 
> ...

 Please look into the files in /var/log/apache2 - there's likely the information you need.

----------

