# another problem Apache+PHP



## zeiz (Nov 3, 2009)

On 2 boxes: 7.2 (updated), apache-2.2.13, php5-5.2.11_1, ssl enabled and
8.0-RC2 (all updated), without SSL 
I'm trying to open local website in /usr/local/www/apache22/data
and on both boxes I'm getting the same error: 


> Fatal error: Call to undefined function session_start() in /usr/local/www/data/index.php on line 2


Php module has been loaded. From httpd-error.log:

```
[Tue Nov 03 09:49:08 2009] [notice] Digest: generating secret for digest authentication ...
[Tue Nov 03 09:49:08 2009] [notice] Digest: done
[Tue Nov 03 09:49:09 2009] [notice] Apache/2.2.13 (FreeBSD) mod_ssl/2.2.13 OpenSSL/0.9.8e DAV/2 PHP/5.2.11 with Suhosin-Patch configured -- resuming normal operations
/usr/local/www/data/index.php(2) : Fatal error - Call to undefined function session_start()
[Tue Nov 03 09:54:17 2009] [notice] SIGHUP received.  Attempting to restart
[Tue Nov 03 09:54:17 2009] [warn] (2)No such file or directory: Failed to enable the 'dataready' Accept Filter
[Tue Nov 03 09:54:17 2009] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter
[Tue Nov 03 09:54:17 2009] [notice] Digest: generating secret for digest authentication ...
[Tue Nov 03 09:54:17 2009] [notice] Digest: done
[Tue Nov 03 09:54:18 2009] [notice] Apache/2.2.13 (FreeBSD) mod_ssl/2.2.13 OpenSSL/0.9.8e DAV/2 PHP/5.2.11 with Suhosin-Patch configured -- resuming normal operations
```
From httpd.conf:

```
ServerRoot "/usr/local"
Listen 80

LoadModule authn_file_module libexec/apache22/mod_authn_file.so
LoadModule authn_dbm_module libexec/apache22/mod_authn_dbm.so
LoadModule authn_anon_module libexec/apache22/mod_authn_anon.so
LoadModule authn_default_module libexec/apache22/mod_authn_default.so
LoadModule authn_alias_module libexec/apache22/mod_authn_alias.so
LoadModule authz_host_module libexec/apache22/mod_authz_host.so
LoadModule authz_groupfile_module libexec/apache22/mod_authz_groupfile.so
LoadModule authz_user_module libexec/apache22/mod_authz_user.so
LoadModule authz_dbm_module libexec/apache22/mod_authz_dbm.so
LoadModule authz_owner_module libexec/apache22/mod_authz_owner.so
LoadModule authz_default_module libexec/apache22/mod_authz_default.so
LoadModule auth_basic_module libexec/apache22/mod_auth_basic.so
LoadModule auth_digest_module libexec/apache22/mod_auth_digest.so
LoadModule file_cache_module libexec/apache22/mod_file_cache.so
LoadModule cache_module libexec/apache22/mod_cache.so
LoadModule disk_cache_module libexec/apache22/mod_disk_cache.so
LoadModule dumpio_module libexec/apache22/mod_dumpio.so
LoadModule include_module libexec/apache22/mod_include.so
LoadModule filter_module libexec/apache22/mod_filter.so
LoadModule charset_lite_module libexec/apache22/mod_charset_lite.so
LoadModule deflate_module libexec/apache22/mod_deflate.so
LoadModule log_config_module libexec/apache22/mod_log_config.so
LoadModule logio_module libexec/apache22/mod_logio.so
LoadModule env_module libexec/apache22/mod_env.so
LoadModule mime_magic_module libexec/apache22/mod_mime_magic.so
LoadModule cern_meta_module libexec/apache22/mod_cern_meta.so
LoadModule expires_module libexec/apache22/mod_expires.so
LoadModule headers_module libexec/apache22/mod_headers.so
LoadModule usertrack_module libexec/apache22/mod_usertrack.so
LoadModule unique_id_module libexec/apache22/mod_unique_id.so
LoadModule setenvif_module libexec/apache22/mod_setenvif.so
LoadModule version_module libexec/apache22/mod_version.so
LoadModule ssl_module libexec/apache22/mod_ssl.so
LoadModule mime_module libexec/apache22/mod_mime.so
LoadModule dav_module libexec/apache22/mod_dav.so
LoadModule status_module libexec/apache22/mod_status.so
LoadModule autoindex_module libexec/apache22/mod_autoindex.so
LoadModule asis_module libexec/apache22/mod_asis.so
LoadModule info_module libexec/apache22/mod_info.so
LoadModule cgi_module libexec/apache22/mod_cgi.so
LoadModule dav_fs_module libexec/apache22/mod_dav_fs.so
LoadModule vhost_alias_module libexec/apache22/mod_vhost_alias.so
LoadModule negotiation_module libexec/apache22/mod_negotiation.so
LoadModule dir_module libexec/apache22/mod_dir.so
LoadModule imagemap_module libexec/apache22/mod_imagemap.so
LoadModule actions_module libexec/apache22/mod_actions.so
LoadModule speling_module libexec/apache22/mod_speling.so
LoadModule userdir_module libexec/apache22/mod_userdir.so
LoadModule alias_module libexec/apache22/mod_alias.so
LoadModule rewrite_module libexec/apache22/mod_rewrite.so
LoadModule dnssd_module       libexec/apache22/mod_dnssd.so
LoadModule php5_module        libexec/apache22/libphp5.so

#AddModule mod_php5.c
    <IfModule mod_php5.c>
        DirectoryIndex index.php index.html
    </IfModule>
    <IfModule mod_php5.c>
        AddType application/x-httpd-php .php
        AddType application/x-httpd-php-source .phps
    </IfModule>

<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>

User www
Group www

</IfModule>
</IfModule>

ServerAdmin myuser@my-mail.com

ServerName 192.168.2.2:80

DocumentRoot "/usr/local/www/data"

<Directory />
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

<Directory "/usr/local/www/data">

    AllowOverride None

    Order allow,deny
   AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
#    AddType application/x-httpd-php .php
#    AddType application/x-httpd-php-source .phps
 
</IfModule>

# Secure (SSL/TLS) connections
I    Allow from all

</Directory>

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

ErrorLog "/var/log/httpd-error.log"

LogLevel warn

<IfModule log_config_module>

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "/var/log/httpd-access.log" combined
    </IfModule>

    <IfModule alias_module>

    ScriptAlias /cgi-bin/ "/usr/local/www/cgi-bin/"

    </IfModule>

    <IfModule cgid_module>

</IfModule>

<Directory "/usr/local/www/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

DefaultType text/plain

<IfModule mime_module>

    TypesConfig etc/apache22/mime.types

AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
#    AddType application/x-httpd-php .php
#    AddType application/x-httpd-php-source .phps
 
</IfModule>

# Secure (SSL/TLS) connections
Include etc/apache22/extra/httpd-ssl.conf

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

Include etc/apache22/Includes/*.conf
```
On the Web the site works fine. Highly appreciate any help.


----------



## anomie (Nov 3, 2009)

Two questions: 

 Were you using the suhosin patch previously? (If not, try recompiling php without it.) 
 Did you have a custom include_path in place in php.ini? (If so, maybe the upgrade overwrote it.)


----------



## Seeker (Nov 4, 2009)

You need to recompile PHP, with *session* support in it.


----------



## zeiz (Nov 4, 2009)

PHP was somehow already installed but without apache module.
Apache was also somehow installed but without php support. When I found out that there is no libphp5.so I recompiled both apache and php and the module appeared but working like I described. During reinstall I enabled Suhosin since I don't have jails.
Why the patch is troublesome?

It seems there is no *session* on config tab:

```
â”‚ â”‚[X] CLI        Build CLI version                                â”‚ â”‚  
     â”‚ â”‚[X] CGI        Build CGI version                                â”‚ â”‚  
     â”‚ â”‚[X] APACHE     Build Apache module                              â”‚ â”‚  
     â”‚ â”‚[X] DEBUG      Enable debug                                     â”‚ â”‚  
     â”‚ â”‚[X] SUHOSIN    Enable Suhosin protection system (not for jails) â”‚ â”‚  
     â”‚ â”‚[X] MULTIBYTE  Enable zend multibyte support                    â”‚ â”‚  
     â”‚ â”‚[X] IPV6       Enable ipv6 support                              â”‚ â”‚  
     â”‚ â”‚[X] MAILHEAD   Enable mail header patch                         â”‚ â”‚  
     â”‚ â”‚[X] REDIRECT   Enable force-cgi-redirect support (CGI only)     â”‚ â”‚  
     â”‚ â”‚[X] DISCARD    Enable discard-path support (CGI only)           â”‚ â”‚  
     â”‚ â”‚[X] FASTCGI    Enable fastcgi support (CGI only)                â”‚ â”‚  
     â”‚ â”‚[X] PATHINFO   Enable path-info-check support (CGI only)        â”‚ â”‚
```
How can I enable session support?

And also what following errors mean?:

```
[Tue Nov 03 23:10:25 2009] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter
[Tue Nov 03 23:10:25 2009] [warn] (2)No such file or directory: Failed to enable the 'dataready' Accept Filter
```
They appear only if stop and then start apache during same session and they are not present during boot up.


----------



## Seeker (Nov 4, 2009)

Focus just on this:

```
cd /usr/ports/www/php5-session
make install clean
```


----------



## dennylin93 (Nov 4, 2009)

> ```
> [Tue Nov 03 23:10:25 2009] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter
> [Tue Nov 03 23:10:25 2009] [warn] (2)No such file or directory: Failed to enable the 'dataready' Accept Filter
> ```
> ...



If I remember correctly, there are two modules that can be loaded to help performance. They can be used by either compiling them into the kernel or putting apache22_http_accept_enable="YES" in /etc/rc.conf (the modules will be loaded when Apache starts).

Most of the PHP extensions are in a meta port: lang/php5-extensions.


----------



## zeiz (Nov 4, 2009)

php5-session was already installed. I installed extensions and no changes.
I got mad and recompiled php5 again. Next I was able to open my site :O
Still I don't understand why it didn't work after first reinstall?
Now I installed php5-extensions again but those 2 errors are still here:

```
[Wed Nov 04 16:20:44 2009] [warn] (2)No such file or directory: Failed to enable the 'httpready' Accept Filter
[Wed Nov 04 16:20:44 2009] [warn] (2)No such file or directory: Failed to enable the 'dataready' Accept Filter
```
..............
The solution is here!
Add to /boot/loader.conf:

```
accf_http_load="YES"
accf_data_load="YES"
```
or kldload the modules within current session.
Thank you guys!


----------

