I have a server that run Centos 6. Recently I upgrade the php to 7.2 using remi repo and apache 2.4 using the sclo(httpd24).
[user#server1 ~]$ httpd -v
Server version: Apache/2.4.34 (Red Hat)
Server built: May 28 2020 08:47:33
[user#server1 ~]$ php -v
PHP 7.2.33 (cli) (built: Aug 4 2020 10:02:54) ( NTS )
My issue is if i put an phpinfo() in /var/www/html, my browser didn't show anything, and if i open the source i only see the php code.
How do i connect the apache and php together?
Thanks..
Have you made sure that inside the apache server configuration httpd.conf file you are correctly pointing to the php.so file??
You need to make sure the LoadModule php7_module /path/to/the/php#7.2/version/libphp7.so line is in your configuration. If you recently changed the PHP to 7.2 you need to modify the line so it points to the correct php version.
In my case I use the php 7.2, 7.3 and 7.4 versions for different purposes and inside my httpd.conf file i have the following lines:
#LoadModule php7_module /usr/local/opt/php#7.2/lib/httpd/modules/libphp7.so
#LoadModule php7_module /usr/local/opt/php#7.3/lib/httpd/modules/libphp7.so
LoadModule php7_module /usr/local/opt/php#7.4/lib/httpd/modules/libphp7.so
As you can see each version point to a different so file, you need to find the correct one for the 7.2 version and point to it by commenting or uncommenting them depending on the php version.
I upgrade the php to 7.2 using remi
Package in my repository are build against base httpd version 2.2.
You still can use httpd 2.4 (from SCL), but in this case you need to use FPM
Read: PHP Configuration Tips
BTW, as CentOS 6 is close to its end of life (in a few months), I heartily recommend you use a more recent version of CentOS (7 or 8 both have httpd 2.4 by default)
Related
My Server : Win server 2012 64bit, Apache 2.4 64bit, PHP Version 5.6.13 (x64)
After install Apache 2.4, i can start normal.
But If i add PHP to httpd.conf
PHPIniDir "C:\php"
LoadModule php5_module "C:\php\php5apache2_4.dll"
I can't start apache, it show message:
Windows could not start the Apache2.4 on Local Computer. For more information, review the System Event Log. If this is a non-Microsoft service, contact the service vendor, and refer to service-specific error code 1.
why can't start apache if add PHPIniDir Setting to httpd.conf?
I test on Win 7, it is ok.
The cause : my php using php_com_net.dll
So i have to install: MSVC11 (Visual C++ 2012)
my machine: macOS Sierra 10.12.3
I am currently working on a project that requires some PHP v.>=5.6 features. When I start my virtual php server with XAMPP 1.8.3 and check the php info it tells me the version is 5.5.11.
I tried updating the php version following this tutorial https://jason.pureconcepts.net/2016/09/upgrade-php-mac-os-x/
upon updating my local .bash_profile path and checking php -v I get the upgraded php version PHP 7.1.1 (cli) (built: Feb 13 2017 10:05:49) ( NTS )
But when I check the phpinfo on my apache server run by xampp I still see 5.5.11 I updated the httpd.conf file and commented the old php versions out and implemented the new one, but that doesn't seem to have any effect.
<IfDefine JUSTTOMAKEAPXSHAPPY>
#LoadModule php4_module modules/libphp4.so
#LoadModule php5_module modules/libphp5.so
LoadModule php7_module /usr/local/php5/libphp7.so
</IfDefine>
Any other ideas?
Thank you for your help!
It would be easier to install a new version of XAMPP.
Another solution would be to install Apache/PHP from homebrew.
Are you sure that you update the try apache conf file? It should be in "xampp" directory. Anyway you can just download a new version xampp, e. g. from here https://www.apachefriends.org/ru/download.html
I'm trying to upgrade to PHP7 on Apache 2.4 with Centos 6.7
First, I used yum to install php70w which installs PHP7 with Apache 2.2.
Then I upgraded to Apache 2.4 using yum. This was successful.
I then copied the php7.so files to the Apache 2.4 modules directory and then configured the httpd.conf file to include them.
When I restart httpd24 it produces the following error:
Starting httpd: httpd: Syntax error on line 56 of /opt/rh/httpd24/root/etc/httpd/conf/httpd.conf:
Syntax error on line 1 of /opt/rh/httpd24/root/etc/httpd/conf.modules.d/00-php.conf:
Cannot load modules/libphp7.so into server: /opt/rh/httpd24/root/etc/httpd/modules/libphp7.so:
undefined symbol: unixd_config
I've learned that this is because Apache has changed the name of there API see here. So the php.so files are trying to call the API through the old name.
Is there a way to edit the php.so files? Or is there a location to download updated files?
Or is there a different way I should be going about this update?
You need mod_php specifically built against Apache 2.4. No Apache module works w/o being at least recompiled against 2.2 and 2.4 by design.
Might be wise to take this opportunity to bail on mod_php and configure PHP via fastcgi. The world has really moved on from mod_php.
In terminal,
php -v
gives
PHP 5.3.29 (cli) (built: Sep 28 2015 06:33:13)
(with imagick installed) but, in the browser (using apache)
phpinfo();
gives
PHP Version 5.5.27
(with no imagick installed) How do I resolve this?
I don't want to mess about with php.ini and httpd.conf when I'm not entirely sure what I'm doing!
Solved it. I entered
locate libphp5.so
into terminal to find paths to the php installations. This outputted
/usr/libexec/apache2/libphp5.so
/usr/local/Cellar/php53/5.3.29_4/libexec/apache2/libphp5.so
I then edited the apache configuration file
sudo nano /private/etc/apache2/httpd.conf
and changed
LoadModule php5_module libexec/apache2/libphp5.so
to
LoadModule php5_module /usr/local/Cellar/php53/5.3.29_4/libexec/apache2/libphp5.so
NOTE : This line will be different for your local installation, copy the value outputted from the locate command above
I then restarted apache with:
sudo apachectl graceful
Credit to this solution for the command to find the php installations
This may be a help to you : Upgrade to PHP 5.4 on MAC and remove version 5.3.10
I would suggest that you work in a virtual setup instead.
like Vagrant: https://www.vagrantup.com/
Also take a look at Homestead: http://laravel.com/docs/4.2/homestead
"Laravel Homestead is an official, pre-packaged Vagrant "box" that provides you a wonderful development environment without requiring you to install PHP, HHVM, a web server, and any other server software on your local machine.
"
It will also allow you to keep your configuration if you change machine and/or operating system.
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.