Click to See Complete Forum and Search --> : Configuring PHP to work with Apache and MySql
griffen
06-03-2001, 12:19 PM
Just installed Apache and MySql. Problem is that I create a test script which sits in htdocs folder. No error messages come up. Just a blank screen. The file is called test.php.
I am using PHP 4.0
tried the line:
cp php.ini-optimized /etc/httpd/php.ini
Then gone to the httpd.conf file and looked for
LoadModule php4_module lib/apache/libphp4.so
Do I add it?
Any other suggestions to what might be the problem would be highly appreciated. Thank you for your time.
James.
freebsd
06-03-2001, 12:34 PM
>> Do I add it?
You were using statically compiled in method from the message you posted couple days ago. You can load libphp4.so module dynamically only if it was built as a share module using DSO (apxs) method.
griffen
06-03-2001, 01:28 PM
Okay I configured PHP using:
$ cd /tmp
$ tar -zxvf php-3.0.7.tar.gz
$ cd php-3.0.7
$ ./configure --with-apxs=/usr/local/apache/bin/apxs \
--with-config-file-path=/etc/httpd \
--with-mysql \
--with-gd \
--with-zlib \
--with-system-regex
The real problem comes when I have to configure PHP.
You said "You can load libphp4.so module dynamically only if it was built as a share module using DSO (apxs) method"
I know that apxs exists because I built it dynamically. How do I load the module?
James.
r00t619
06-03-2001, 01:36 PM
Take a look at this NHF that I have been working on. This is how I usually build Apache/PHP4/MySQL, etc.
http://www.pixel-eight.com/linuxnewbie/Building_Apache.txt
Hope this helps you out. Let me know if you like this NHF or if you have any suggestions.
BTW: You are compiling PHP3 and talking about trying to load the PHP4 module. Obviously this won't work :D
[ 03 June 2001: Message edited by: r00t619 ]
freebsd
06-04-2001, 01:47 AM
>> The real problem comes when I have to configure PHP
Not only PHP but all other software you are going to try to compile yourself. It's all about a bad habit Linux people been doing.
>> --with-apxs=/usr/local/apache/bin/apxs
This is absolutely a non-standard path Apache should be installed to. Not to mention Mysql at /usr/local/mysql/....
What is standard and what is non-standard? Why shouldn't I set the --prefix=/usr/local/mysql or --prefix=/usr/local/apache?
I'd like to place everything under /usr/local/apache for ease of uninstall and maintenance, so putting everything to /usr/local/apahce is the appropriate install location for me :)
Face it!! gcc doesn't search /usr/local/apache nor does it search /usr/local/mysql. Should you want gcc to search for it automatically everytime you compile software yourself, simply add /usr/local/lib to ldconfig's search path, that is it. That said, you also need to follow the standard, that is, to set the prefix of anything you compile yourself to /usr/local. If you follow the standard, /usr/local/lib/mysql/libmysqlclient.so is then searchable automatically. Using --with-mysql is fine for installing PHP.
If you choose to use /usr/local/apache, do this prior to running configure:
CPPFLAGS="-I/usr/local/mysql/include"
LDFLAGS="-L/usr/local/mysql/lib"
export CPPFLAGS
export LDFLAGS
./configure [ options here ]
The link r00t619 provided would fail to add mysql support for PHP because --with-mysql doesn't help the configure script to locate mysql. Not to mention adding additional support like gd.
Here are the directories that should be in /usr/local (no others):
bin, etc, include, info, lib, libexec, sbin, share, src, man and man/man[1-9] man/cat[1-9].
Yes, unlike BSD systems that use /usr/local correctly. Linux people installing Apache with a prefix of /usr/local/apache absolutely defeats the purpose of /usr/local. Why not set the prefix to /opt/apache or /var/apache instead?
Now let's take a look at your line: LoadModule php4_module lib/apache/libphp4.so
That tells me libphp4.so is at /usr/local/apache/lib/apache/libphp4.so. Why in the world should there be a duplicate apache directory under /usr/local? Why can't it be /usr/local/apache/lib/libphp4.so?
Because your prefix was supposed to be /usr/local, so libphp4.so would be in /usr/local/lib/apache/libphp4.so.
Some day, you might wanna try BSD, which you won't see this kind of trouble, because BSDs using /usr/local prefix correctly makes compiling software yourself much easier. You don't have a need to add extra lib path at all.
>> Okay I configured PHP using:
>> $ cd /tmp
It's also a bad practice to put any tarballs in /tmp directory. That defeats the purpose for having a /tmp directory. It would be worst if you don't have much space in /tmp directory. A more appropriate location would be in /usr/local/src.
[ 04 June 2001: Message edited by: freebsd ]
killerasp
06-09-2001, 05:00 PM
FreeBSD, im not sure what you meant in your last post. How should i go about it if i wanted to install apache in /usr/local/apache?
freebsd
06-10-2001, 06:59 AM
>> How should i go about it if i wanted to install apache in /usr/local/apache?
You never should in the first place. If you must do it, Apache may install fine. The problem you mostly will face is adding additional share modules (i.e. PHP) using DSO method. You must set extra flags like the two I mentioned previously so those paths will be searched. If you still don't know how to do this, don't even try /usr/local/apache because you are warned not to set the prefix to /usr/local/apache.
To put it simple, when you run ./configure, it doesn't search the non-standard location like /usr/local/apache or /usr/local/mysql. All BSD system and probably some Linux add /usr/local/lib to its search path by default. The ones that don't have a broken /usr/local because that distribution don't understand the purpose of /usr/local. The ones that do, /usr/local/lib/mysql is automatically searchable. Say adding Mysql support to PHP, you just need to specify --with-mysql because /usr/local/lib/mysql will be searched while /usr/local/mysql/lib (non-standard) will not.
I have seen other people having problem starting Apache thousand times with an error like: Unable to load libmysqlclient.so something simply because PHP never serach /usr/local/mysql/lib, and didn't add mysql support.
[ 10 June 2001: Message edited by: freebsd ]
Sweede
06-10-2001, 02:28 PM
wow, that is all sooooo wrong.
while it may be true for most other gay linux programs, it definitly is NOT true with apache, php nor MySQL.
you can install apache in /usr/local/bum/freggin/egypt/over/across/the/gaza/strip/east/of/the/nile/apache
and it wont make one bit of difference ANYWHERE.
a quick run down..
tar zxvf apache...
cd apache...
./configure \
--with-layout=RedHat \
--enable-module=most \
--enable-shared=max \
--server-uid=httpd \
--server-gid=httpd \
## add these for suexec support w/ multi users
--enable-suexec \
--suexec-caller=httpd \
--suexec-docroot=/home
--suexec-logfile=/var/log/httpd/suexec_log
make
make install
cd ../
tar zxvf php...
cd php...
./configure \
--with-apxs=/usr/sbin/apxs \
--enable-config-path=/etc/httpd/php.ini
[whatever else DO NOT USE THE --with-mysql OPTION !!! you dont need it]
if you want to add SSL support, follow the mod_ssl instructions on how to add, and then use the --enable-rule=DEAPI flag when configing PHP, (and any other apache module)
if you want to install mysql,php,apache all by source and in say, /usr/local/webserver/... go right ahead
apache,
./configure --prefix=/usr/local/webserver/apache \
[other stuff]
php,
./configure \
--with-apxs=/usr/local/webserver/apache/bin/apxs \
[other stuff]
mysql,
./configure \
--prefix=/usr/local/webserver/mysql
why will this work?? because PHP has its own built in MySQL client. (DO NOT USE --with-mysql !!, unless you have something else, such as mod_auth_mysql, installed).
but suppose you do ?? , no problem
--with-mysql=/usr/local/webserver/mysql
and lo and behold, mysql support will be built into PHP and all is good.
no cannot load libmysqlclient.so.10 errors like Freebsd thinks.
but the best way to do it is how i first described, --with-layout-RedHat (check out config.layout)
which also describes..
Classical Apache layout (binary distro too)
prefix = /usr/local/apache
Standard GNU layout
prefix = /usr/local
BSD layout..
prefix = /var/www
exec_prefix=/usr/contrib
exec_prefix is where binary files are put in, also the include files (/usr/contrib/include/apache)
now im sure thats a standard path.
Oh yea, one last thing.
USE PHP4 !!!!
there's no reason in the world to be using php3, not a single one, and there will never be a valid reason NOT to update to php4.
Sweede
06-10-2001, 02:38 PM
Originally posted by r00t619:
<STRONG>Take a look at this NHF that I have been working on. This is how I usually build Apache/PHP4/MySQL, etc.
http://www.pixel-eight.com/linuxnewbie/Building_Apache.txt
Hope this helps you out. Let me know if you like this NHF or if you have any suggestions.
BTW: You are compiling PHP3 and talking about trying to load the PHP4 module. Obviously this won't work :D
[ 03 June 2001: Message edited by: r00t619 ]</STRONG>
couple things about your NHF.
having
--enable-module=ssl \
--enable-module=most \
--enable-shared=max \
--enable-rule=SHARED_CORE \
--enable-rule=SHARED_CHAIN \
--enable-module=so
is redundent, they'll be included and made DSO with the most/max lines.
Step 7 can be elimated by running configure in the apache directory before step doing mod_ssl in step 5.
in step 8, php autmaticly includes built in mysql support, the --with-mysql line is not needed.
as of php4.0.2 , enable-track-vars is always enabled. since your also builing php into apache (i.e. not as a single binary), you dont need to have the --enable-force-cgi-redirect line as that only applies to the CGi binary (ie. not using the --with-[server] flag).
AddType application/x-httpd-php .phtml
.phtml is depreciated as of php 3.0.x series.
.php is the standard with some .php3 laying around
AddType application/x-httpd-php .php .php3
AddType application/x-httpd-php-source .phps
in step
6, DO NOT USE A PASSWORD WHEN MAKING A CERTIFICATE
this will allow apache to start up un-attended.
freebsd
06-10-2001, 05:54 PM
>> wow, that is all sooooo wrong.
No, yours actually is. Yes, PHP has built-in MySQL support but that's not what everyone wants. The built-in support is minimal and is known to cause problem with other modules that depend on MySQL support. Using this built-in support is NOT the right approach nor is it a workaround for those who can't get --with-mysql to work, it's a misleading approach instead. It's hiding the fact that one can't get --with-mysql to work but to downgrade to only use the built-in MySQL support. If one wants full MySQL support, they must compile the server module using --with-mysql or --with-mysql=/non/standard/path/to/mysql.
>> but suppose you do ?? , no problem --with-mysql=/usr/local/webserver/mysql
That would work but non-standard. Mysql defaults to intall to /usr/local, not /usr/local/mysql. If you follow the standard, --with-mysql is just fine. If you installed MySQL to a non-standard location, then --with-mysql=/non/standard/path/to/mysql is needed.
>> but the best way to do it is how i first described
Wrong and misleading to build minimal MySQL support.
>> --with-layout-RedHat (check out config.layout)
Right. But Redhat layout doesn't use /usr/local/apache because Redhat misled users the use of /usr/local. They encourage users to install anything local (doesn't come with its distribution by default) to /usr/local. But users often misinterpreted that and install it to /usr/local/apache.