简体   繁体   中英

Installing PHP on Linux: Cannot load /etc/apache2/modules/libphp5.so into server

I've installed PHP with yum install php , after that I've added the following lines in httpd.conf

LoadModule php5_module modules/libphp5.so
....
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

And after that I've copied libphp5.so to /var/apache2/modules . Then I said /etc/apache2/bin/apachectl -k stop and got the following error.

httpd: Syntax error on line 57 of /etc/apache2/conf/httpd.conf: Cannot load /etc/apache2/modules/libphp5.so into server: /etc/apache2/modules/libphp5.so: undefined symbol: ap_unixd_config

Installed PHP version is 5.4.41 . OS is CentOS Linux release 7.1.1503 .

Can someone tell me where the problem is?

UPD Apache version is 2.4.6 (64-bit), line 57 of httpd.conf is LoadModule php5_module modules/libphp5.so

What's odd about this is that you installed PHP using yum and then went to add php.so to Apache. The RPM should do that for you (that's the whole idea behind package managers). In CentOS 7 the .so file is loaded in /etc/httpd/conf.modules.d (you should have a file called something like 10-php.conf ). There should also be a /etc/httpd/conf.d/php.conf file where your FilesMatch directive is added. If you are defining these twice you could be causing issues.

I would also suggest that you use a later version of PHP than 5.4 (this version will go into End Of Life when PHP 7.0 is released later this year). If you're not using the Remi repo then I would set that up and you can get 5.5 or 5.6. I am using this myself and have not any of the issues you mention. It could also be that the version of PHP you installed is not compiled for CentOS 7 (this issue is unique to Apache 2.4). Remi does have a CentOS 7 repo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM