Wednesday, June 29, 2011

APACHE SERVER AND PHP, POST INSTALLATION PROBLEMS

PHP POST INSTALLATION PROBLEMS

1. Cannot parse PHP files.
I’m still not able to parse PHP files when I attempt to open them in a browser, I get the option to download them instead. I’ve tried several steps and nothing works.

Solution:
Perform the following tasks
sudo apt-get install libapache2-mod-php5
sudo a2enmod php5

Then re-start Apache:
sudo /etc/init.d/apache2 restart

2. No write permission.
I get the “it worked message”. So everything install semi correctly at least. However, when I try to copy or save files in the /var/www/ folder, I can't. Any ideas?

Solution:
Terminal:
sudo chown USERNAME /var/www/

3. Could not connect to MYSQL server. Here is the PHP code

$host = 'localhost';
$user = 'root';
$pass = 'mypassword';
$database = 'mysql';

mysql_connect($host,$user,$pass);
@mysql_select_db($database) or die( "Unable to select database");

Solution:
Change the value of $host variable from 'localhost' to '127.0.0.1'

4. When I am trying to access a php files below the root folder through my localhost and Apache is giving me a 403 error.

Forbidden
You don't have permission to access /distribution/sample-html-simple.php on this server.

Apache/2.2.16 (Ubuntu) Server at localhost Port 80

Solution:
Make sure folder is accessible to www-data, on the terminal type the command:
sudo chown -R www-data "/var/www/distribution"

1 comment:

Genes M. Acenas Sr said...

Please post a comment if you have problem different from what I've presented. We will help each other.