How to update PCRE in CENTOS/Redhat 6 - php

For installing Scribunto, a Mediawiki add ins, it requires at least PCRE version 8.1. But in CENTOS update, the maximum version is 7.8.
I compiled the source code version 8.33 successfully and with "pcretest -C" command, it is already version 8.33. But the phpinfo() has still the old PCRE 7.8.
How to point PCRE in php to the newest version?

Sigh.
I feel ya.
I can tell you that what finally worked for me was building PCRE from source and using FastCGI (the mod_fcgid package in CentOS 6) with a stanza like this in /etc/httpd/conf.d/php.conf:
<IfModule fcgid_module>
SetEnv LD_PRELOAD /usr/local/lib/libpcre.so.1
ScriptAlias /fcgi-bin/ /var/www/fcgi-bin/
AddType application/x-httpd-fastphp .php
Action application/x-httpd-fastphp /fcgi-bin/php-cgi
<Directory /var/www/fcgi-bin/>
# Allows /usr/bin/php-cgi to be symlinked here
Options +FollowSymLinks
</Directory>
</IfModule>
Here are a list of things I tried with the default "modular" PHP setup (php5_module) before giving up and resorting to FastCGI.
PassEnv LD_PRELOAD with LD_PRELOAD=/usr/local/lib/libpcre.so.1 defined in /etc/sysconfig/httpd.
SetEnv LD_PRELOAD /usr/local/lib/libpcre.so.1
LoadFile /usr/local/lib/libpcre.so.1
However, I was putting these directives inside VirtualHost sections, generally, so I won't rule out the possibility that order was the problem. That is, it's entirely possible that these directives would need to come before the PHP module was loaded, and I wasn't doing that. I was using an /etc/httpd/conf.d/php.conf and a vhosts.conf and generally trying not to sully the top-level config file while I was experimenting.
Eventually I ran out of patience and tried going the FCGI route, and that worked for me. If you're married to running PHP as a loadable module, then you may wish to try some of the above options with things like LoadFile specified in httpd.conf before the PHP DSO is loaded.

Related

"Specified procedure could not be found" error while configuring Apache

I try to configure Apache 2.4.2 for localhost so that it worked with PHP and PostgreSQL. I added following code to the end of httpd.conf file (updated after #Galadai's answer):
PHPIniDir "D:/Programy/php"
LoadFile "D:/Programy/php/php5ts.dll"
LoadFile "D:/Gis/PostgreSQL/9.3/bin/libpq.dll"
LoadModule php5_module "D:/Programy/php/php5apache2_4.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Trying to start Apache returns an error. When I run "Test Configuration", it shows following error message:
httpd.exe: Syntax error on line 519 of D:/Programy/Apache/httpd.conf: Cannot load D:/Programy/php/php5ts.dll into server: Specified procedure could not be found.
I had some path issues before, and the error message was almost the same, just there was "module" instead of "procedure". I have found quite a few hints for the "module" version, but their solution was usually to make sure whether the paths fit (I did this), both versions are 32/64 bit (both are 32 bit) and PHP is thread safe (it is). I didn't find any hint how to solve the "procedure" version of the error. I thought it might have been caused by difference in versions (I tried Apache 2.2 before), but this proved to be wrong.
EDIT: now I added PHPIniDir and the first LoadFile before the rest of the document ending, and only difference is that now the problem occurs on php5ts.dll too. The path is correct (if it wasn't there would be "module", not "procedure" problem - tested again).
Any other idea?
My PHP is 5.5.9 (thread safe) and PostgreSQL 9.3, my system is Windows XP 32 bit.
EDIT2: workaround through EnterpriseDB LAPP is not as good as I thought for the first time, so I'm still looking for an answer to this question.
According to php.net manual
httpd.conf should look like this:
#BEGIN PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
PHPIniDir "c:/PHP/"
Loadfile "C:\php\php5ts.dll"
Loadfile "C:\php\libpq.dll"
LoadModule php5_module "c:/PHP/php5apache2_2.dll"
#END PHP INSTALLER EDITS - REMOVE ONLY ON UNINSTALL
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps
I encountered a similar problem. PHP module could not be loaded into my Apache installation.
I used a Windows x64 distribution of Apache 2.4.52 from https://www.apachehaus.com/cgi-bin/download.plx
and PHP version 8.1.2 x64, thread safe from https://windows.php.net/download#php-8.1
And after configuring php extension configuration inside ./conf/httpd.conf,
after running ./bin/httpd.exe, an error returned:
Cannot load C:/Program Files/Applications/php_8_1_2_x64/php8apache2_4.dll into server: The specified procedure could not be found.
SOLUTION: Download a version of apache built with OpenSSL library, as PHP requires this one. LibreSSL won't work.
PHP module wants to internally call the functions of this module but the execution system cannot find the called function (procedure) and reports error.
Replacing bin directory in the Apache server folder with the folder containing correct binaries should work, but I don't know to what extent. Best would be to just set up a new installation and migrate configuration and data files.

apache2.4 build not finding php5.3

I am setting up a test server before upgrading an elderly version of mediawiki on a production server. I am trying to duplicate what will be on the production server - apache2.4 and php5.3.
When I try to access any php file, the server displays it as text rather than running it.
This is all running on Ubuntu 12.04 LTS. The apache package available is version 2.2, so I can't simply apt-get.
I have built apache 2.4 from source, and it correctly serves an index.html from my designated DocumentRoot.
In httpd.conf, I have added:
DocumentRoot = /var/www
AddType application/x-httpd-php .php
<filesMatch>"\.php$:"
SetHandler application/x-httpd-php .php
</filesMatch>
I have installed php5.3, and it is working - I can run phpinfo.php from a command line.
In /etc/php5/apache2/php.ini I have (error displays are for testing only):
engine = On
display_errors = On
display_startup_errors = On
doc_root = /var/www
I am not able to find a reference to a mod_php of any sort either in the httpd.conf or in the directory in which httpd is installed (/usr/local/apache2).
Some of the references on the web mention "modules-available" and "modules-enabled" but these appear to be a convenience added by Debian, and are not part of the apache source build.
What am I missing? I'm sure it's something simple.
After searching and using packages from several repositories for both apache and php, and trying to build either or both from source, I determined that there did not seem to be a libphp5.so that was compatible with apache 2.4. In any case, I didn't find it.
I reconfigured everything to use php as cgi rather than as a module, and got things working that way, which was enough for my intended purpose.
You need to load php module in httpd.conf:
On my Linux Slackware I have this in /etc/httpd/mod_php.conf
LoadModule php5_module lib/httpd/modules/libphp5.so
# Tell Apache to feed all *.php files through PHP. If you'd like to
# parse PHP embedded in files with different extensions, comment out
# these lines and see the example below.
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
And in /etc/httpd/httpd.conf:
# php
Include /etc/httpd/mod_php.conf

Apache won't parse php page

So I've installed LAMP on an Ubuntu machine for some php development and everything is working fine except instead of parsing and displaying php pages, the browser is asking me if I want to download them. I know this is a well documented issue, and I've already been to the Ubuntu page concerning it, and gone through all the potential causes. I've installed libapache2-mod-php5 and upon running sudo a2enmod php5 I get module php5 already enabled. So I think I've pretty much narrowed the problem down to a php file authorizations issue.
Now I should point out that this only happened after I modified the config file to allow a UserDir in my /home/public_html. With the default configuration in folder /var/www php files parsed just fine, and still do, so long as I gave myself root access or modify their permisssions. And I didn't change anything else in the config file.
So, my question is, how do I check/modify the php authorization files? Where are they? What exactly do I check? I can't seem to find any good info on this.
Try an installation of:
sudo apt-get install php5 libapache2-mod-php5
Then restart the service..
/etc/init.d/apache2 restart
or if using httpd:
/etc/init.d/httpd restart
Then let me know how that goes.
So I figured this out with some really tedious searching, I'm surprised the solution is not more widely available, it's really very simple. The /etc/apache2/mods-available/php5.conf file comes with these lines.....
8 # To re-enable php in user directories comment the following lines
9 # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
10 # prevents .htaccess files from disabling it.
11 <IfModule mod_userdir.c>
12 <Directory /home/*/public_html>
13 php_admin_value engine Off
14 </Directory>
15 </IfModule>
...which obviously disable php in user directories. These need to be commented out.
This solved my problem, but I just couldn't figure out why:
AddType application/x-httpd-php .php
I added the above in the /etc/httpd/conf/httpd.conf
My problem arose right when I edited the httpd.conf to configure
I'm on Centos 7 running PHP 7.0.
I had to load the PHP 7 module in my /etc/httpd/conf/httpd.conf file.
LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
As always, remember to sudo service httpd restart after making changes to apache

Why are my PHP files showing as plain text? [duplicate]

This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 7 years ago.
I've been writing PHP applications using PHP for a while in WAMP. Now I'm installing PHP and Apache HTTP Server separately on my work PC. I've installed PHP 5, and the latest Apache. I go to localhost and see it works!
Now I add a file called test.php which displays:
<?php
phpinfo();
?>
But in the browser it just displays plain text. Is there somewhere I have explicitly tell it to use PHP 5?
You should install the PHP 5 library for Apache.
For Debian and Ubuntu:
apt-get install libapache2-mod-php5
And restart the Apache:
service apache2 restart
You'll need to add this to your server configuration:
AddType application/x-httpd-php .php
That is assuming you have installed PHP properly, which may not be the case since it doesn't work where it normally would immediately after installing.
It is entirely possible that you'll also have to add the php .so/.dll file to your Apache configuration using a LoadModule directive (usually in httpd.conf).
Yet another reason (not for this case, but maybe it'll save some nerves for someone) is that in PHP 5.5 short open tags <? phpinfo(); ?> are disabled by default.
So the PHP interpreter would process code within short tags as plain text. In previous versions PHP this feature was enable by default. So the new behaviour can be a little bit mysterious.
You need to configure Apache (the webserver) to process PHP scripts as PHP. Check Apache's configuration. You need to load the module (the path may differ on your system):
LoadModule php5_module "c:/php/php5apache.dll"
And you also need to tell Apache what to process with PHP:
AddType application/x-httpd-php .php
See the documentation for more details.
You might also, like me, have installed php-cgi prior to installing Apache and when doing so it doesn't set up Apache properly to run PHP, removing PHP entirely and reinstalling seemed to fix my problem.
You will need to add handlers in Apache to handle php code.
Edit by command sudo vi /etc/httpd/conf/httpd.conf
Add these two handlers
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
at position specified below
<IfModule mime_module>
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
--Add Here--
</IfModule>
for more details on AddType handlers
http://httpd.apache.org/docs/2.2/mod/mod_mime.html
Are you using the userdir mod?
In that case the thing is that PHP5 seems to be disabling running scripts from that location by default and you have to comment out the following lines:
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_flag engine Off
</Directory>
</IfModule>
in /etc/apache2/mods-enabled/php5.conf (on a ubuntu system)

How to configure PHP under Apache web server in GENTOO Operating System?

is there anyone who knows how to install / configure php under apache?
I have emerge php apache both.
I wanted to use mod_php for apache in GENTOO OS.
php temp.php
command line runs fine, but http://localhost/temp.php is not executing on web server instead it shows the content of the php code.
I found a blog and I followed his instruction and it works !
I'm sharing the solution Referenced Blog
I put these lines in /etc/make.conf:
USE="apache2 mysql php pam ssl xml xml2 berkdb innodb jpeg png"
If you want to install also phpmyadmin, then you should also add pcre session unicode:
USE="apache2 mysql php pam ssl xml xml2 berkdb innodb jpeg png pcre session unicode"
I then changed the file /etc/init.d/apache2, in order to enable public_html folders for users (corresponding to the ~ directory), setting -D USERDIR:
APACHE2_OPTS="-D DEFAULT_VHOST -D PHP5 -D USERDIR
Before starting mysql, you must create (once and for all) the mysql main database, and this can be done simply by running:
/usr/bin/mysql_install_db
There appear to be a number of ways to achieve this but many seem a bit out of date or overly complicated. As of Feb 1 2010 all I did to get PHP and Apache2 working on Gentoo was to install Apache and PHP like this:
bash$ emerge apache
Followed the instructions for the particular extensions I wanted at this list at the Gentoo site
NOTE: this is the important one to get Apache and PHP working together:
bash$ echo "dev-lang/php apache2" >> /etc/portage/package.use
Another common PHP extension:
bash$ echo "dev-lang/php mysql" >> /etc/portage/package.use
And so on.
Then just run bash$ emerge dev-lang/php and restart Apache with the /etc/init.d/apache2 script. PHP should now be available.
You may find some informations in Apache 2.0 on Unix systems
Especially, the
LoadModule php5_module modules/libphp5.so
and
SetHandler application/x-httpd-php
Lines should help :-)
The corresponding lines I have in my Apache's configuration (Apache 2, PHP 5.2, Ubuntu) are :
LoadModule php5_module /usr/lib/apache2/modules/libphp-5.2.9.so
<IfModule mod_php5.c>
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
</IfModule>
above link dead, try this one:
http://overlays.gentoo.org/proj/php/
Try to use official GENTOO documentation:
http://www.gentoo.org/proj/en/php/php4-php5-configuration.xml

Categories