Following the advice of some ALUGers in a previous thread I am in the process of upgrading our fileserver to Ubuntu 7.04.
I have successfully installed Ubutu on it and then apt-get installed the modules "apache" and "php5-mysql".
I have created a simple three line "hello world" PHP prog and saved it in /var/www as hello.php :
root@wildebeest:/var/www# cat hello.php <?php echo "Hello World"; ?>
If I type the URL http://localhost/ into firefox I see the default apache index.html holding page as expected (so I know apache is running). If however I type the URL http://localhost/hello.php a box pops up in Firefox saying:
"You have chosen to open: hello.php Which is a: PHP script From: http://localhost What should Firefox do with this file? 1. Open with gedit (default) 2. Save to disc."
Why doesn't Firefox simply display hello.php as a webpage? What am I doing wrong? Do I need to configure something in apache and/or Firefox to display php files as webpages?
Any help welcome!
Sagr.
At first glance, it looks like it's an Apache config problem.
I googled for "apache php ubuntu" and it came up with this: http://www.cwassall.co.uk/pages/linux/ubuntu-server.html
This makes it look like you've got to edit the /etc/apache2/apache2.conf and the /etc/php5/apache2/php.ini files to properly 'link' php5 to apache.
Matt
-----Original Message----- From: main-bounces@lists.alug.org.uk [mailto:main-bounces@lists.alug.org.uk] On Behalf Of sagr Sent: 27 July 2007 21:26 To: main@lists.alug.org.uk Subject: [ALUG] Problem getting Apache/Firefox to display PHP webpages
Following the advice of some ALUGers in a previous thread I am in the process of upgrading our fileserver to Ubuntu 7.04.
I have successfully installed Ubutu on it and then apt-get installed the modules "apache" and "php5-mysql".
I have created a simple three line "hello world" PHP prog and saved it in /var/www as hello.php :
root@wildebeest:/var/www# cat hello.php <?php echo "Hello World"; ?>
If I type the URL http://localhost/ into firefox I see the default apache index.html holding page as expected (so I know apache is running). If however I type the URL http://localhost/hello.php a box pops up in Firefox saying:
"You have chosen to open: hello.php Which is a: PHP script From: http://localhost What should Firefox do with this file? 1. Open with gedit (default) 2. Save to disc."
Why doesn't Firefox simply display hello.php as a webpage? What am I doing wrong? Do I need to configure something in apache and/or Firefox to display php files as webpages?
Any help welcome!
Sagr.
_______________________________________________ main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!
not really helpping fix the problem but just an interesting observation. I installed phpmyadmin and mysql server using aptget, it picked up apache2 as a dependency and seemed to confiigure everything for me. I guess the difference is that you installed apache first.
On 7/27/07, mephi matthew.j.green@ntlworld.com wrote:
At first glance, it looks like it's an Apache config problem.
I googled for "apache php ubuntu" and it came up with this: http://www.cwassall.co.uk/pages/linux/ubuntu-server.html
This makes it look like you've got to edit the /etc/apache2/apache2.conf and the /etc/php5/apache2/php.ini files to properly 'link' php5 to apache.
Matt
-----Original Message----- From: main-bounces@lists.alug.org.uk [mailto:main-bounces@lists.alug.org.uk] On Behalf Of sagr Sent: 27 July 2007 21:26 To: main@lists.alug.org.uk Subject: [ALUG] Problem getting Apache/Firefox to display PHP webpages
Following the advice of some ALUGers in a previous thread I am in the process of upgrading our fileserver to Ubuntu 7.04.
I have successfully installed Ubutu on it and then apt-get installed the modules "apache" and "php5-mysql".
I have created a simple three line "hello world" PHP prog and saved it in /var/www as hello.php :
root@wildebeest:/var/www# cat hello.php
<?php echo "Hello World"; ?>
If I type the URL http://localhost/ into firefox I see the default apache index.html holding page as expected (so I know apache is running). If however I type the URL http://localhost/hello.php a box pops up in Firefox saying:
"You have chosen to open: hello.php Which is a: PHP script From: http://localhost What should Firefox do with this file?
- Open with gedit (default)
- Save to disc."
Why doesn't Firefox simply display hello.php as a webpage? What am I doing wrong? Do I need to configure something in apache and/or Firefox to display php files as webpages?
Any help welcome!
Sagr.
main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!
main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!
On Mon, 2007-07-30 at 20:48 +0100, Venura Mendis wrote:
I installed phpmyadmin and mysql server using aptget, it picked up apache2 as a dependency and seemed to confiigure everything for me. I guess the difference is that you installed apache first.
Thanks for that useful tip... I will bear it in mind if I have to set up another server. When I set up this server however I thought I would take it step by step and install apache2 first to make sure it was running ok before installing php5. I suppose I could un-install php and apache and try re-installing as you suggest but, as Matt suggested; I think the problem is probably that I have simply not configured something correctly in apache2.conf and php.ini
On 7/27/07, mephi matthew.j.green@ntlworld.com wrote:
At first glance, it looks like it's an Apache config problem.
I googled for "apache php ubuntu" and it came up with this: http://www.cwassall.co.uk/pages/linux/ubuntu-server.html
This makes it look like you've got to edit the /etc/apache2/apache2.conf and the /etc/php5/apache2/php.ini files to properly 'link' php5 to apache.
Thanks for the link to ubuntu-server.html but, unfortunately, it does not really go into enough detail. Like you suggest; I think the problem is that I have simply not configured apache2.conf and php.ini correctly to allow PHP to integrate into Apache.
I must admit that I assumed apache2.conf and php.ini would be automatically set up by apt-get so as to integrate them together and I am a bit apprehensive about tweaking anything I do not understand.
I can confirm that apache correctly displays the default placeholder page if I put http://localhost/ into firefox... Apache simply seems unable to display php files causing Firefox to suggest the php webpages are files to download rather than pages to display.
Are there any ALUGers who have managed to get php5 running on their Ubuntu apache2 boxes? If so I was wondering if you could either email your apache2.conf and php.ini files to me so I can compare them with mine and see where I have gone wrong or, alternatively, I have uploaded my own apache2.conf and php.ini up to my webspace if anyone would like to comment on their content and could suggest what I need to tweak.
I have uploaded my apache2.conf file to: http://www.suffolk-ancestor-genealogy-research.co.uk/alug/apache2_conf.txt
I have uploaded my php.ini file to: http://www.suffolk-ancestor-genealogy-research.co.uk/alug/php_ini.txt
My /etc/apache2/httpd.conf file is an empty file (zero bytes).
Any help would be appreciated.
Sagr.
On Tuesday 31 July 2007 08:48:25 sagr wrote:
I have uploaded my apache2.conf file to: http://www.suffolk-ancestor-genealogy-research.co.uk/alug/apache2 _conf.txt
I have uploaded my php.ini file to: http://www.suffolk-ancestor-genealogy-research.co.uk/alug/php_ini .txt
My /etc/apache2/httpd.conf file is an empty file (zero bytes).
Any help would be appreciated.
Make sure you have the apache2 and apache2.2-common packages installed.
Also make sure that php4.load and php5.conf are in /etc/apache2/mods-available/
Then try:
$ sudo a2enmod php5 $ sudo apache2ctl restart
This enabled the PHP5 apache module.
You may also need to try adding something like
AddType application/x-httpd-php .php
to your apache.conf file. This tells apache how to handle .php files.
Cheers, Richard
On Tue, 2007-07-31 at 09:12 +0100, Richard Lewis wrote:
Make sure you have the apache2 and apache2.2-common packages installed.
Also make sure that php4.load and php5.conf are in /etc/apache2/mods-available/
gahh beaten me to it
Anyway I thought I'd better just add that if the php5.conf and php5.load files are not there then they should be symbolic links to said files in /etc/apache2/mods-available
so after checking they exist there and from the mods-enabled directory do a
sudo ln -s ../mods-available/php5.conf
sudo ln -s ../mods-available/php5.load
On 31 Jul 2007, at 9:34 am, Wayne Stallwood wrote:
sudo ln -s ../mods-available/php5.conf
sudo ln -s ../mods-available/php5.load
As Richard said, that's what a2enmod is for.
sudo a2enmod php5 - will make those symlinks for you.
Thanks,
Dave
On Tue, 2007-07-31 at 09:12 +0100, Richard Lewis wrote:
Make sure you have the apache2 and apache2.2-common packages installed.
Yes, they seem to both be installed and up-to-date:
root@wildebeest:~# apt-get install apache2 apache2.2-common Reading package lists... Done Building dependency tree Reading state information... Done apache2 is already the newest version. apache2.2-common is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Also make sure that php4.load and php5.conf are in /etc/apache2/mods-available/
Yes, they seem to be:
root@wildebeest:/etc/apache2/mods-available# ls -l php* -rw-r--r-- 1 root root 133 2007-07-17 19:14 php5.conf -rw-r--r-- 1 root root 59 2007-07-17 19:14 php5.load
Then try:
$ sudo a2enmod php5
root@wildebeest:/etc/apache2/mods-available# a2enmod php5 This module is already enabled!
$ sudo apache2ctl restart
This enabled the PHP5 apache module.
root@wildebeest:/etc/apache2/mods-available# apache2ctl restart apache2: apr_sockaddr_info_get() failed for wildebeest apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
You may also need to try adding something like
AddType application/x-httpd-php .php
to your apache.conf file. This tells apache how to handle .php files.
I have added this line and now get:
root@wildebeest:/etc/apache2# grep AddType apache2.conf # AddType allows you to add to or override the MIME configuration #AddType application/x-gzip .tgz AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php AddType text/html .shtml
Cheers, Richard
Thanks for those tips Richard. I was hoping that adding the: AddType application/x-httpd-php .php line you suggested would solve the problem but even when restarted I still cannot get Firefox to display .php files as webpages.
The only strange thing I noticed as I worked my way through your suggestions is the error: apr_sockaddr_info_get() failed but I am not sure how fatal this is.
I notice some other replies have come through so will get a cup of tea and have a read before replying further.
Thanks for your help Richard, Sagr
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
sagr wrote:
root@wildebeest:/var/www# cat hello.php
<?php echo "Hello World"; ?>
If I type the URL http://localhost/ into firefox I see the default apache index.html holding page as expected (so I know apache is running). If however I type the URL http://localhost/hello.php a box pops up in Firefox saying:
"You have chosen to open: hello.php Which is a: PHP script From: http://localhost What should Firefox do with this file?
- Open with gedit (default)
- Save to disc."
Why doesn't Firefox simply display hello.php as a webpage? What am I doing wrong? Do I need to configure something in apache and/or Firefox to display php files as webpages?
It may be because you appear to be trying to run the script from your server's document root directory. By default, this will not be set up to run executable scripts, and so instead it serves it based on the information it otherwise knows about PHP, i.e. application/x-httpd-php4 (which your browser detects and thus offers you the "what do you want to do with this file that I can't handle"? message. This can also occur because the file itself does not have execution privileges ('ls -al hello.php' should show -rwxr--r-- or maybe rwxrwxr--), although this more often results in a 500 error.
Ordinarily (for security) you would create a separate directory that /isn't/ in the normal document tree, e.g. /var/cgi-bin[1]. Then, in Apache's config you specify
ScriptAlias /var/cgi-bin/ /cgi-bin/
- - this makes everything in this directory automatically a script. You then may *possibly* need to add some other handlers, e.g.
AddHandler cgi-script .php[34]
and/or
AddType application/x-httpd-php[34] .php[34]
Then, after a restart of Apache, you should be able to try http://localhost/cgi-bin/hello.php and it should work :-)
Cheers, Simon
[1] note that it would probably be better to create /var/www/docs for the document tree and /var/www/cgi-bin for scripts
- -- ====================================================================== Simon Ransome http://nosher.net Photo RSS Feed: http://nosher.net/images/images.rss
On Tue, 2007-07-31 at 10:19 +0100, Simon Ransome wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ordinarily (for security) you would create a separate directory that /isn't/ in the normal document tree, e.g. /var/cgi-bin[1]. Then, in Apache's config you specify
ScriptAlias /var/cgi-bin/ /cgi-bin/
- this makes everything in this directory automatically a script. You
then may *possibly* need to add some other handlers, e.g.
AddHandler cgi-script .php[34]
and/or
AddType application/x-httpd-php[34] .php[34]
Then, after a restart of Apache, you should be able to try http://localhost/cgi-bin/hello.php and it should work :-) [1] note that it would probably be better to create /var/www/docs for the document tree and /var/www/cgi-bin for scripts
Yipeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee!
Thanks to Simon, and indeed all the other ALUGers who have freely offered help and advice with this problem, I am happy to report I can now see "Hello World" when I tell Firefox to look at hello.php.
I have however run into another problem: If I type "apache2ctl restart" once my fileserver is up and running then everything works ok but I would prefer Apache to start itself automatically when the PC boots. What is the normal way to achieve this?
Cheers, Simon iD8DBQFGrv6o8tdcY+OcZZwRAt2CAKDSlBJDDpgZfVorRxgM8pczfRoX/wCdFq4K r3zbyT9HDtjU73ETsQnMlGY= =jXM+ -----END PGP SIGNATURE-----
Just a final quick query Simon...
I notice that Evolution says your email was PGP signed but that it had an "Invalid Signature". Is this a problem with you or me? How do I fix this?
Thanks again for your help.
Sagr.