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.

mk_89
  • 125
  • 1
  • 2
  • 8
  • See: http://serverfault.com/questions/69685/what-user-should-own-var-www-on-ubuntu-9-04-server http://serverfault.com/questions/6895/whats-the-best-way-of-handling-permissions-for-apache2s-user-www-data-in-var – Zoredache Sep 05 '12 at 21:52

3 Answers3

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)

Jens
  • 342
  • 1
  • 4
  • 14
  • I don't know how to check if it is installed, im searching on google. – mk_89 Sep 05 '12 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 05 '12 at 17:43
  • Ubuntu 12.04, I typed in php -v and it returned something, if that helps – mk_89 Sep 05 '12 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

essefbx
  • 43
  • 9
-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
Kev
  • 249
  • 1
  • 10
  • 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 05 '12 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 05 '12 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](http://security.stackexchange.com/questions/77/apache-server-hardening). – bobmagoo Sep 05 '12 at 22:00