Issues with my LAMP Server

I've trying to build a simple registration form, I've done it several times, thousands of times, and I've never experienced this mainly because this is the first time that I've set up a LAMP Server. I've been always worked with functional LAMP Servers.

My issue is:

My PHP Code works fine, but as soon as I add a mysql feature like

mysqlconnect($hostname,$username,$password) or die(mysqlerror());

My page appears blank, completely blank, It doesn't matter where do I type that code, it appears blank.

I'm frustrated, I've been trying to fix that a lot of times and I can't.

somebody has an idea what could be happening?

Thanks.

12 Replies

could possibly be something else, but most likely two things are going on:

1) the php-mysql wrapper isn't installed (how to do so depends on your os)

2) php error reporting is turned to silent (could be mixture of errorreporting or displayerrors). Usually these things get turned off in production so as to not reveal that PHP is running. edit you php.ini and refer to http://www.php.net/manual/en/errorfunc. … lay-errors">http://www.php.net/manual/en/errorfunc.configuration.php#ini.display-errors

I'm still looking for a possible answer.

I've seen that i need to configure PHP5 by myself towork with MySQL.

So I went to php.ini and I added the line

extensions = mysql.so

but then I ran the command

locate mysql.so and It's nowhere in my computer.

The things is I didn't set up this server, it was someone else and I think it was a unexperienced linux user, I've been working with these guys 2 days I've seen how they work, probably they screwed up the whole thing, and now I need to fix it in order to finish my job.

I'm trying to run service httpd restart, but I can't!

Assuming you're on a centos/fedora system, it's /sbin/service, so you either add /sbin/ to your path or call it directly from that path. in ubuntu, you'll need to install the sysvconfig package to get it. I'm not familiar enough with other systems, but you should also be able to restart by calling /etc/init.d/apache2 restart (/etc/init.d/httpd for centos/fedora) directly.

Like I said, you probably don't have mysql.so because you don't have the php-mysql package. unless you reveal which OS and version you have, I can't really point you to the right direction.

I'm sorry

I'm working with

Red Hat Enterprise Linux 5.

you'll want to do a yum install php-mysql. You might want to remove the extension=mysql.so from your php.ini because the package should automatically add entries into /etc/php.d/ from which they get autoloaded.

Still doesn't work.

I already typed yum install php-mysql

I delete the old httpd, and Installed the new one using yum,

yum install httpd php mysql-server mysql php-mysql

it installed everything, but i'm still unable to run mysql_ commands in php.

If you're using RHEL 5 just call RH tech support - it is after all why you pay for their distro.

Are the pages still blank? If so, please try to figure out the error reporting that I advised you to turn on in my first response. I'd like to see an example of your php code and the related error message. Throw in a phpinfo() output to make me even happier.

Now it works, I figured it out after a while it was a problem concerning priviliges, so CHMOD solved it.

Is there a way to automatically give the right permissions to all files in /var/www/html/ ??

I have to go to the terminal and type

CHMOD whateverpriviligenumber mynewfile.php

everytime i want to add a new file.

@hassamu:

Now it works, I figured it out after a while it was a problem concerning priviliges, so CHMOD solved it.

Is there a way to automatically give the right permissions to all files in /var/www/html/ ??

I have to go to the terminal and type

CHMOD whateverpriviligenumber mynewfile.php

everytime i want to add a new file.

chmod to what? Apache should only need read access to your php files. How does your site function if your web server can't read your files?

@waldo:

@hassamu:

Now it works, I figured it out after a while it was a problem concerning priviliges, so CHMOD solved it.

Is there a way to automatically give the right permissions to all files in /var/www/html/ ??

I have to go to the terminal and type

CHMOD whateverpriviligenumber mynewfile.php

everytime i want to add a new file.

chmod to what? Apache should only need read access to your php files. How does your site function if your web server can't read your files?

It could be that the webserver is run by another user that doesnt belong in the group that has permissions for alread-properly chmodded files. It's a mistake I see often when people install a ton of packages and then start modifying webservers, sudo, etc.

In other words, I need to change the group that user apache belongs?

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct