1

I have purchases a server today and I am almost through configuring it, I have managed to install mysql and have enabled a firewall which allows access to ports 80, 22 and 443

I am trying to test out a simple php file to see whether all is well but I get a 404 Not found error, I am certain that this file exists which was created using vi as I have confirmed it using Filezilla.

What am I missing? is there another step that I must take to allow a simple php file to work.

1

3 Answers 3

-2

Did you configure it as a LAMP server during the installation, or did you install apache yourself?

If apache is not already installed you can install it using the command:

sudo aptitude install apache2

Also make sure that the correct permissions are setup for apache to access the directory that contains your php file:

sudo chmod -R 744 /myphpdir
sudo chown -R www-data:www-data /myphpdir
3
  • chmod 777 is a horrible idea from a security perspective. This would let anyone on the system (or any compromised account) read/edit/run the php scripts you've written. Any scripts that you write with stored MySQL credentials or other sensitive information are open to the world.
    – bobmagoo
    Sep 5, 2012 at 19:59
  • I know. That was just to let him get it working. Please change it to something more secure - I suggest 744. I have edited my answer now :)
    – Kev
    Sep 5, 2012 at 20:03
  • @mk_89: if you've made it to the end of this lengthy internet debate, there's some great advice on securing an Apache install over at IT Security.
    – bobmagoo
    Sep 5, 2012 at 22:00
1

The file has to be readable by the webserver which usually means by the user www-data. Are you sure your document root is /var/www? Is mod_php enabled?

# sudo apt-get install libapache2-mod-php5
# sudo a2enmod php5

This way apache php support should be enabled. If it says "Module php5 already enabled" everything is fine.

What permissions does /var/www have? And more important, what is the value for DocumentRoot in your apache configuration? (somewhere /etc/apache2/ where your vhosts are defined)

3
  • I don't know how to check if it is installed, im searching on google.
    – mk_89
    Sep 5, 2012 at 17:41
  • Which operating system do you use? The steps to enable PHP and configure apache differ slightly depending on your distribution.
    – Jens
    Sep 5, 2012 at 17:43
  • Ubuntu 12.04, I typed in php -v and it returned something, if that helps
    – mk_89
    Sep 5, 2012 at 17:44
1

Sounds like you need apache or lighttpd

If you didn't pre-configure as a LAMP on install you can follow this ApacheMySQLPHP Ubuntu tutorial

Not the answer you're looking for? Browse other questions tagged .