PHP and APACHE - Showing source text

Associate
Joined
3 Oct 2004
Posts
68
Location
Biggin Hill
I am quite new to linux, but last night decided to install MySql, Apache and PHP. I have installed all (after six hours) and can use mysql. However, when I run the php script in firefox and konqurer it shows only the source file text, it does not seem to show what it is supposed to. The php file is suppose to show some infor ( phpinfo(); ). Does anybody know what I may have done wrong. I am using Suse Linux 9.3. Any help would be gratefully recieved.
 
Apache does not know what to do with php files.

The way to fix this depends on how you installed php. Did you use a configure script with something like apxs in it?

Check if php module is being loaded in your httpd.conf or php.conf file in the httpd conf dirs.

Check if you have entries for

AddType application..... .php

It should all be automatic though depending on how you installed. Did you install with Yast or did you use rpm's or the source?

See if there is an yast install for httpd2-php or apache2-php

Don't forget that after changing you need to stop and start apache.
 
Last edited:
I will try this tonight, I did check the httpd.conf file and there was no mention of PHP. After six hours I had lost the will to be honest. I will search for a rpm of httpd2-php or apache2-php as you suggest and try this.

I installed PHP from the command line using a ./configure command, make and then make install.

All this is new to me but I do enjoy it and will continue until it is working.

Do you think something like this is trial and error, can I do any permament damage or corrupt anything on Linux?
 
It's definitely trial and error and worth doing - you can't beat hands on practical experience.

If you installed php via command line then look it looks as if you will need to reconfigure it to use apxs2. To save time create a file called conf_php.sh:

#
#conf_php.sh
#
CPPFLAGS="-I/usr/local/include"
LDFLAGS="-L/usr/local/lib -lstdc++"
./configure --prefix=/usr \
--with-config-file-path="/etc" \
--with-apxs2="/usr/sbin/apxs" \
--enable-exif \
--enable-track-vars \
--enable-calendar \
--enable-magic-quotes \
--enable-trans-sid \
--enable-inline-optimization \
--enable-memory-limit \
--with-zlib \
--with-openssl="/usr" \
--with-curl="/usr" \
--enable-bcmath \
--with-gettext="/usr" \
--with-mysql \
--with-iconv \
--with-gd \

chmod 755 and then just ./conf_php.sh when you need to reconfigure php. If there are no errors then you just make and make install after that. Putting it in a script file makes it easier for adding / removing items.

Just make sure you have the right paths and apps required. The file above is what I used on a Centos server.

The next brick wall you will find may be configure complaining that it can't find apxs2.... You may need to install other stuff.

One other gotcha to look out for is missing libraries. Usually this can be fixed by installing the devel package for the app.

e.g. if you run the script above it should enable php for mysql - let you use php functions such as mysql_connect() etc. But if libraries are missing, and you are sure you have installed mysql-server, mysql-client (or installed the main files from mysql) then try installing mysql-devel. Same goes for php-devel etc. Saves ages if you install the devel apps as well as the main apps.
 
I am now getting this error when trying to start apache:

linux:/home/Dean/webserver/conf # ../bin/./apachectl start
httpd: Syntax error on line 53 of /home/Dean/webserver/conf/httpd.conf: Cannot load /home/Dean/webserver/modules/libphp5.so into server: /home/Dean/webserver/modules/libphp5.so: undefined symbol: zend_parse_parameters

Any ideas what I have done now?
 
Back
Top Bottom