- Install Apache
- Install MySQL
- Install PhP
# sudo apt-get install lamp-server^
After running the apt-get command you will need to reboot the server to finish the install and preform a couple of tests to check everything is working. First test would be to point your browser at the ip address of your new server; if apache was installed correctly you should get the following web page;
Once you have confirmation of the apache web server working you should then check the php and mysql features are also working. Creating a simple html / php script will help with this;
<html>Save a similar section of code with your MySQL username and password to a file with the .php extension in the root directory of your web server (should be /var/www) and point your browser at this new file. If all goes well you should get the following lines displayed in your browser. Congratulations, you have a running LAMP server (In a coming post I will talk about securing PhP and mySQL).
<body>
The Apache2 server works!</br>
<?php
print "PhP5 is working!</br>";
$usr = "username";
$pwd = "password";
$hst = "localhost";
$dbms = mysql_connect($hst, $usr, $pwd) or die("Unable to connect to MySQL");
print "Connected to MySQL!</br>";
mysql_close($dbms);
?>
</body>
</html>
Again, this would be an opportune time to do a complete backup of your LAMP server so you have an image to restore from as you continue in setting up your new server.The Apache2 server works!
PhP5 is working!
Connected to MySQL!