Configuring apache2,mysql and Php on my ubuntu

Posted March 4, 2015 2.1k views

How do I configure apache2 web server on my Ubuntu,so that I can run my html scripts?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

The best way is to create a digitalocean LAMP droplet, it has everything preconfigured. All you’d have to do, at a minimum, is drop your PHP scripts into /var/www and it should be able to serve those scripts. If you wanted to write to that folder using PHP (for example, file uploads or image manipulation), I’d create a subfolder under that and change the ownership to www-data.

If you have a droplet (or any linux machine) but don’t have apache, MySQL and php installed, it’s not too hard to install it. Here’s a tutorial that should give you the basics.

In case you’re going with a manual LAMP install: [Link]

Then I advise to secure your server by enabling the firewall and installing Fail2Ban. It’s not a bad idea to change the default SSH port to something else, because you’ll already see a lot of brute force attempts few hours after setting up the droplet.

Additional steps: [Link]
Fail2Ban: [Link]

If you don’t intend to fiddle with your droplet after setting it up it’s also a nice idea to enable automatic security updates: [Link] (scroll to the bottom of the post)

P.s.: My only issue with Fail2Ban is that it stopped working after the logs rotated—happens every week by default, I think. I may have managed to fix it in my droplet, but I’m not entirely sure yet. Meanwhile keep an eye on your logs to make sure it works.