# PHP/Apache not working!

## audiodef

Did a world update, PHP now not working on my localhost. It was prior to the update. A PHP file displays the code in a browser. 

This is what shows up in the apache error.log:

```

[Tue Jan 04 10:04:49 2011] [error] [client 71.163.19.220] client denied by server configuration: /var/www/localhost/htdocs/mohachat/lib/

[Tue Jan 04 10:04:49 2011] [error] [client 71.163.19.220] client denied by server configuration: /var/www/localhost/htdocs/mohachat/config/

[Tue Jan 04 10:05:41 2011] [error] [client 71.163.19.220] client denied by server configuration: /var/www/localhost/htdocs/mohachat/lib/

[Tue Jan 04 10:05:41 2011] [error] [client 71.163.19.220] client denied by server configuration: /var/www/localhost/htdocs/mohachat/config/

```

I run a moha chat server. I didn't change anything in the moha chat configuration. All I did was run a world update. 

This is very frustrating. Something breaks every time PHP or Apache updates on Gentoo.

----------

## Jimini

I don't know if I remember that correctly, but perhaps I solved such a problem in the past by re-emerging apache.

Edit: did you restart apache yet?

Best regards,

Jimini

----------

## audiodef

The first thing I did was restart apache, which didn't help. 

Then I tried re-emerging apache, which didn't help. 

Then I re-emerged apache with APACHE2_MODULES="cgi", because the output of Portage said that cgid or cgi is now required, and since I don't use threaded, I set cgi. 

Now I get this when trying to start apache:

```

 * apache2 has detected an error in your setup:

Syntax error on line 90 of /etc/apache2/modules.d/00_default_settings.conf:

Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration

 * ERROR: apache2 failed to start

```

 :Evil or Very Mad: 

----------

## audiodef

This was an upgrade to PHP 5.3.4. I'm downgrading now to see if that works.

----------

## Mousee

Works fine for me. Did you try following the PHP Upgrade Guide?

There were quite a few changes since PHP 5.2x - though as you've not provided any information as to what was upgraded during your "world update", it's difficult to help you troubleshoot any further beyond recommending the above guide.

----------

## audiodef

I emerged the stable versions of LAMP. I can't get PHP to work now. I tested a simple page:

```

<?

echo "It works!";

die("Please, just die!");

?>

```

Nothing. Blank page. Ctrl-u in Firefox shows me the PHP code, but the browser itself shows a blank page. 

HELP!   :Rolling Eyes: 

----------

## malern

Try running

```
eselect php list apache2
```

and then selecting the version you want with

```
eselect php set apache2 <num>
```

(then restart apache)

PHP is slotted now, and after I upgraded I found that no version was selected by default, so I had to manually select one.

If that doesn't work could you post the output of 

php -v

cat /etc/conf.d/apache2

and

ls -l /usr/lib/apache2/modules

----------

## julp

Usage of <?/<?= forms instead of <?php/<?php echo implies short_open_tag to On.

```
Syntax error on line 90 of /etc/apache2/modules.d/00_default_settings.conf:

Invalid command 'Order', perhaps misspelled or defined by a module not included in the server configuration
```

It seems authz_host module is absent (absent from APACHE2_MODULES when emerging or not loaded).

```
[Tue Jan 04 10:04:49 2011] [error] [client 71.163.19.220] client denied by server configuration: /var/www/localhost/htdocs/mohachat/config/
```

Don't, access to lib and config subdirectories, need to be restricted ? If it shouldn't, there is a Deny directive somewhere in your Apache configuration or in a .htaccess file in your application directories.

----------

## audiodef

 *malern wrote:*   

> Try running
> 
> ```
> eselect php list apache2
> ```
> ...

 

That didn't work.   :Crying or Very sad: 

php -v returned "bash: /usr/bin/php: No such file or directory"

cat /etc/conf.d/apache2 returned

```

# /etc/conf.d/apache2: config file for /etc/init.d/apache2

# When you install a module it is easy to activate or deactivate the modules

# and other features of apache using the APACHE2_OPTS line. Every module should

# install a configuration in /etc/apache2/modules.d. In that file will have an

# <IfDefine NNN> directive where NNN is the option to enable that module.

#

# Here are the options available in the default configuration:

#

#  AUTH_DIGEST  Enables mod_auth_digest

#  AUTHNZ_LDAP  Enables authentication through mod_ldap (available if USE=ldap)

#  CACHE        Enables mod_cache

#  DAV          Enables mod_dav

#  ERRORDOCS    Enables default error documents for many languages.

#  INFO         Enables mod_info, a useful module for debugging

#  LANGUAGE     Enables content-negotiation based on language and charset.

#  LDAP         Enables mod_ldap (available if USE=ldap)

#  MANUAL       Enables /manual/ to be the apache manual (available if USE=docs)

#  MEM_CACHE    Enables default configuration mod_mem_cache

#  PROXY        Enables mod_proxy

#  SSL          Enables SSL (available if USE=ssl)

#  SUEXEC       Enables running CGI scripts (in USERDIR) through suexec.

#  USERDIR      Enables /~username mapping to /home/username/public_html

#

#

# The following two options provide the default virtual host for the HTTP and

# HTTPS protocol. YOU NEED TO ENABLE AT LEAST ONE OF THEM, otherwise apache

# will not listen for incomming connections on the approriate port.

#

#  DEFAULT_VHOST      Enables name-based virtual hosts, with the default

#                     virtual host being in /var/www/localhost/htdocs

#  SSL_DEFAULT_VHOST  Enables default vhost for SSL (you should enable this

#                     when you enable SSL)

#

APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PHP5"

# Extended options for advanced uses of Apache ONLY

# You don't need to edit these unless you are doing crazy Apache stuff

# As not having them set correctly, or feeding in an incorrect configuration

# via them will result in Apache failing to start

# YOU HAVE BEEN WARNED.

# PID file

#PIDFILE=/var/run/apache2.pid

# timeout for startup/shutdown checks

#TIMEOUT=10

# ServerRoot setting

#SERVERROOT=/usr/lib/apache2

# Configuration file location

# - If this does NOT start with a '/', then it is treated relative to

# $SERVERROOT by Apache

#CONFIGFILE=/etc/apache2/httpd.conf

# Location to log startup errors to

# They are normally dumped to your terminal.

#STARTUPERRORLOG="/var/log/apache2/startuperror.log"

# A command that outputs a formatted text version of the HTML at the URL

# of the command line. Designed for lynx, however other programs may work.

#LYNX="lynx -dump"

# The URL to your server's mod_status status page.

# Required for status and fullstatus

#STATUSURL="http://localhost/server-status"

# Method to use when reloading the server

# Valid options are 'restart' and 'graceful'

# See http://httpd.apache.org/docs/2.2/stopping.html for information on

# what they do and how they differ.

#RELOAD_TYPE="graceful"

```

ls -l /usr/lib/apache2/modules returned

```

total 1220

lrwxrwxrwx 1 root root     34 Jan  5 11:08 libphp5.so -> /usr/lib/php5.3/apache2/libphp5.so

-rwxr-xr-x 1 root root   5436 Jan  5 10:18 mod_actions.so

-rwxr-xr-x 1 root root   9596 Jan  5 10:18 mod_alias.so

-rwxr-xr-x 1 root root   9564 Jan  5 10:18 mod_auth_basic.so

-rwxr-xr-x 1 root root   9564 Jan  5 10:18 mod_authn_alias.so

-rwxr-xr-x 1 root root   5436 Jan  5 10:18 mod_authn_anon.so

-rwxr-xr-x 1 root root   5436 Jan  5 10:18 mod_authn_dbm.so

-rwxr-xr-x 1 root root   5436 Jan  5 10:18 mod_authn_default.so

-rwxr-xr-x 1 root root   5436 Jan  5 10:18 mod_authn_file.so

-rwxr-xr-x 1 root root   9564 Jan  5 10:18 mod_authz_dbm.so

-rwxr-xr-x 1 root root   5404 Jan  5 10:18 mod_authz_default.so

-rwxr-xr-x 1 root root   9596 Jan  5 10:18 mod_authz_groupfile.so

-rwxr-xr-x 1 root root   9564 Jan  5 10:18 mod_authz_host.so

-rwxr-xr-x 1 root root   9532 Jan  5 10:18 mod_authz_owner.so

-rwxr-xr-x 1 root root  13692 Jan  5 09:27 mod_authz_svn.so

-rwxr-xr-x 1 root root   5436 Jan  5 10:18 mod_authz_user.so

-rwxr-xr-x 1 root root  30268 Jan  5 10:18 mod_autoindex.so

-rwxr-xr-x 1 root root  38544 Jan  5 10:18 mod_cache.so

-rwxr-xr-x 1 root root  22076 Jan  5 10:18 mod_cgi.so

-rwxr-xr-x 1 root root  30396 Jan  5 10:18 mod_cgid.so

-rwxr-xr-x 1 root root  87868 Jan  5 10:18 mod_dav.so

-rwxr-xr-x 1 root root  42620 Jan  5 10:18 mod_dav_fs.so

-rwxr-xr-x 1 root root  13692 Jan  5 10:18 mod_dav_lock.so

-rwxr-xr-x 1 root root 137836 Jan  5 09:27 mod_dav_svn.so

-rwxr-xr-x 1 root root  17852 Jan  5 10:18 mod_deflate.so

-rwxr-xr-x 1 root root   9532 Jan  5 10:18 mod_dir.so

-rwxr-xr-x 1 root root  21948 Jan  5 10:18 mod_disk_cache.so

-rwxr-xr-x 1 root root   5436 Jan  5 10:18 mod_env.so

-rwxr-xr-x 1 root root   9648 Jan  5 10:18 mod_expires.so

-rwxr-xr-x 1 root root  17948 Jan  5 10:18 mod_ext_filter.so

-rwxr-xr-x 1 root root   9652 Jan  5 10:18 mod_file_cache.so

-rwxr-xr-x 1 root root  13692 Jan  5 10:18 mod_filter.so

-rwxr-xr-x 1 root root  13756 Jan  5 10:18 mod_headers.so

-rwxr-xr-x 1 root root  38428 Jan  5 10:18 mod_include.so

-rwxr-xr-x 1 root root  17808 Jan  5 10:18 mod_info.so

-rwxr-xr-x 1 root root  22072 Jan  5 10:18 mod_log_config.so

-rwxr-xr-x 1 root root   5420 Jan  5 10:18 mod_logio.so

-rwxr-xr-x 1 root root  22044 Jan  5 10:18 mod_mem_cache.so

-rwxr-xr-x 1 root root  13724 Jan  5 10:18 mod_mime.so

-rwxr-xr-x 1 root root  22252 Jan  5 10:18 mod_mime_magic.so

-rwxr-xr-x 1 root root  30236 Jan  5 10:18 mod_negotiation.so

-rwxr-xr-x 1 root root  59132 Jan  5 10:18 mod_rewrite.so

-rwxr-xr-x 1 root root   9564 Jan  5 10:18 mod_setenvif.so

-rwxr-xr-x 1 root root   9596 Jan  5 10:18 mod_speling.so

-rwxr-xr-x 1 root root 154820 Jan  5 10:18 mod_ssl.so

-rwxr-xr-x 1 root root  21968 Jan  5 10:18 mod_status.so

-rwxr-xr-x 1 root root   9532 Jan  5 10:18 mod_unique_id.so

-rwxr-xr-x 1 root root   9564 Jan  5 10:18 mod_userdir.so

-rwxr-xr-x 1 root root   9564 Jan  5 10:18 mod_usertrack.so

-rwxr-xr-x 1 root root   9532 Jan  5 10:18 mod_vhost_alias.so

```

----------

## audiodef

 *julp wrote:*   

> Usage of <?/<?= forms instead of <?php/<?php echo implies short_open_tag to On.
> 
> 

 

Editing /etc/php/apache2-php5.3/php.ini to change short tags to on resolves the issue of testing a simple script as I described earlier; however, trying to run something like ajax chat or Moha chat from my localhost still results in a blank page after trying to log in (ajax chat) or run the web installer (Moha). 

What condition would allow a simple echo script to work but not a server app written in PHP?

----------

## julp

Apache haven't write permission where it should? A missing PHP function/extension? (mohachat seems to need, at least: apache2 sockets zlib session and mysql or postgres as php USE flags)

Nothing related to PHP in Apache error log? (no "undefined function" or "permission denied" in particular for example?)

If none, try to change display_errors to On and error_reporting to E_ALL & ~E_DEPRECATED (from php.ini - really preferred ; or eventually in Apache configuration/.htaccess by adding these two lines : php_flag display_errors on and php_value error_reporting 22527).

PS: to have php command, PHP must be emerged with cli as USE flag.

----------

## audiodef

I have PHP compiled with the cli use flag and I still get the file not found error. 

This is what shows up in apache's error log when I restart apache, go to a fresh mohachat install page and click "next" from the first page:

```

[Wed Jan 05 14:05:45 2011] [notice] Apache/2.2.16 (Unix) mod_ssl/2.2.16 OpenSSL/1.0.0c configured -- resuming normal operations

[Wed Jan 05 14:05:53 2011] [notice] child pid 5802 exit signal Segmentation fault (11)

[Wed Jan 05 14:05:53 2011] [notice] child pid 5803 exit signal Segmentation fault (11)

[Wed Jan 05 14:05:55 2011] [notice] child pid 7161 exit signal Segmentation fault (11)

```

Something is bjorking somewhere. How do I find out what?

I had errors set to E_ALL & E_STRICT. I changed them to E_ALL & ~E_DEPRECATED, but that didn't seem to affect anything.

I had moha running fine before my last world update. Everything it requires should still be in place, other than PHP deciding to have a party on my server.

----------

