PHP not working. Help, please...

Hello,

Hm, so… I’m supposed to migrate a website I’m working on from Windows to Linux, so I downloaded the whole site from its webserver to my Linux enviroment, but, although everything work perfectly under Windows, on Linux all the scripts just won’t load, and I ain’t got no idea of what could be the problem causing this - but I had installed phpMyAdmin and it worked fine. I’m using Apache 2.0 (2.2.17-4.5.1), PHP5 Module for Apache (5.3.5-5.14.1) and MySQL (5.1.53-4.7.1) under openSUSE 11.4 x86_64. Oh, I had the same problem when trying to load the page under Mandriva 2010.

So I tried to reinstall Apache as well as PHP and phpMyAdmin following the instructions in here step by step, but, after reinstalling these not even phpMyAdmin is working anymore, and if I call a(ny) php page from localhost in the browser, a download window pops up, which means Apache doesn’t recognise the php file as a script to be executed by php machine, or something like that.
Looking at httpd.conf (apache configuration file) I noticed there’s no reference to php module. I tried to manually configure it, but it seems there’s also no libphp5.so in my computer (tried to find it using dolphin’s search feature)… I guess I’ll have to unninstall everything php related and then try to compile PHP from source and just thinking of that already gives me headaches.

Can anybody help me? Any tips, before I mess things up even further?

Thanks in advance,

Hênio

Hi Hênio

Do not mess up your system any further.

As a first step please make sure that /etc/sysconfig/apache2 contains php5 in the variable APACHE_MODULES="…"

Then do as root:

# rcapache2 restart

You should get a “Syntax OK”.

Do not change httpd.conf. Instead, put your local settings into a file named /etc/apache2/httpd-local.conf and include the name of the file in the variable APACHE_CONF_INCLUDE_FILES=“httpd-local.conf”. Then report back what happened.

HA, GOT IT! :smiley: There was no “php5” in APACHE_MODULES var, I’ve put it there and now PHP’s partially working again. At least phpMyAdmin is back. Thanks!!
But the said ‘site’ still isn’t working.
Oh, and to see the state of PHP I created a new file (info.php) calling php_info()

<?php php_info(); ?>

and that doesn’t work, the function doesn’t output anything.
But if I do

<?php echo "hello world!"; php_info(); ?>

I get “hello world!”.
Any guess? Might this be related to the ‘site’ not showing a sign of life?

<?php
phpinfo()
?>

Hum… nope.

On Thu, 11 Aug 2011 15:16:02 +0530, granitoce
<granitoce@no-mx.forums.opensuse.org> wrote:

> --------------------
> <?php php_info(); ?>
> --------------------
> and that doesn’t work, the function doesn’t output anything.

of course not; there’s no underscore in that function. use:


<?php print phpinfo(); ?>

and it should work.


phani.

On Thu, 11 Aug 2011 15:16:02 +0530, granitoce
<granitoce@no-mx.forums.opensuse.org> wrote:

> Might this be related to the ‘site’ not showing a sign of
> life?

why your copied site doesn’t work might have many reasons, depending of
what type of site it is.

if it’s a “CMS” (content management system) like drupal or wordpress,
you’ll also need the database that it connects to.

in any case, it’s likely that all the scripts in those files were edited
with windows text editors, and therefore have the wrong new-line
delimiters.

you should tell some more, what type of website you’re trying to
transplant, and what steps you’ve taken apart from copying the file
structure, if any.


phani.

phpinfo() works for me. Make sure you clear any cache in your browser. Also check /var/log/apache2/error_log to see if you missed something else.

On Thu, 11 Aug 2011 15:33:51 +0530, phanisvara <listmail@phanisvara.com>
wrote:

> On Thu, 11 Aug 2011 15:16:02 +0530, granitoce
> <granitoce@no-mx.forums.opensuse.org> wrote:
>
>> Might this be related to the ‘site’ not showing a sign of
>> life?
>
>
> why your copied site doesn’t work might have many reasons, depending of
> what type of site it is.
>
> if it’s a “CMS” (content management system) like drupal or wordpress,
> you’ll also need the database that it connects to.
>
> in any case, it’s likely that all the scripts in those files were edited
> with windows text editors, and therefore have the wrong new-line
> delimiters.
>
> you should tell some more, what type of website you’re trying to
> transplant, and what steps you’ve taken apart from copying the file
> structure, if any.
>

and after unsuccessfully trying to access that site, look in
/var/log/apache2, that’s where your apache error logs are supposed to be.
depending on your setup, one of them should give some info into what type
of error apache2/PHP ran when you tried to access the site.


phani.

On Thu, 11 Aug 2011 15:36:02 +0530, granitoce
<granitoce@no-mx.forums.opensuse.org> wrote:

>
> Hum… nope.
>

what “nope?”

you sure you didn’t make a typo anywhere? there has to be “<?php” in
front, and the function to call is “phpinfo();”. doesn’t matter if you use
the “print” statement or not, it should work with or without; also the
closing “?>” is optional. any extra or missing characters in there would
stop it from working.

if that really doesn’t work, look in your apache2 logs.


phani.

Oh, I had skipped the underscore typo(overcorrection), and was answering to eng-int’s post. Pardon me both of you.
Actually phpinfo() works.

Well, its a website built from scratch, including a content management system written by myself, and I have already installed its database… no steps taken apart from copying everything, and yes, the whole code was written using windows editors. But, since PHP is multiplataform, I thought new-line delimiters wouldn’t be a problem… will I have to replace aaaaaall of them? It’s a huuuuuge code! #laziness

EDIT: Oh, and there’s no /var/log/apache2/ directory.
EDIT2: Also, forgot to mention that there’s no error message from PHP while trying to load the website, no nothing, just a blank page.

I guess display_errors in php.ini is Off by default on linux… changed it’s value to On and now the errors are being displayed.
Well, now that I have some feedback from PHP itself I can fix the rest of the problems. Basically they all seem to be path related problems…
I’ll come back to this after I get some sleep.
Good day and thanks to everybody who helped me. :wink:

Of course there is:

$ ls -ld /var/log/apache2
drwxr-x--- 2 root root 4096 2011-07-27 04:07 /var/log/apache2

But as it belongs to root, you will have to access it with root permissions.

Ah yes, I hadn’t thought of that. Thanks. (y)

I have just noticed the hidden information that this is not a SuSE type installation but a HowtoForge special. I have always found them needlessly complicated, designed for a special case, and often wrong.

My advice would be to roll back, removing all configuration files, and do a straightforward openSuSE LAMP installation. Leave out any web tools like phpMyAdmin or Webmin until things are basicaly working and you have a backup.

Use YaST to install the “Web server and LAMP” pattern.
Mkdir the directories “/srv/www/vhosts/” and e.g. “/srv/www/vhosts/example.com”
Create the file “/srv/www/vhosts/example.com/phpinfo.php” with the contents “<?php phpinfo(); ?>”
Check that “other” has read permissions to this file and directory.
Make sure that “example.com” “www.example.com” are in the /etc/hosts file or nameserver.
In YaST Network Services > HTTPD and work your way through the prompts. You may have to do this twice, and enter the details for the virtual host “example.com” ensuring that its DocumrntRoot is set to “/srv/www/vhosts/” and e.g. “/srv/www/vhosts/example.com”.
Yast > System > System Services (Run Level). Enable/start “apache2” and “mysql”.

Point a web browser to “http://example.com/phpinfo.php”.
Check “/var/log/apache2/error_log” to find out why it did not work.
Remember to “rcapache2 restart” after any changes.