Flipping the Linux switch: Linux web tools, Pt. 2 - Using LAMP for testing
We ultimately decided to tackle setting up a LAMP testing ground. This will certainly not be necessary for every single person out there who just wants to put up a web site. If your site is not using PHP-driven content that interacts with or requires a database backend, and you just plan on designing static web pages, there is absolutely no need to do any of this.
If you are perfectly content to upload your site and integrate any supporting elements (once again, things like databases) live and on the web and make changes there, where it is possible that everyone can see your style sheet testing or things may be temporarily broken, you don't need to do this either.
Some people, though, really like to get things on their CMS tweaked to near perfection before releasing their content on the world. Other people need to know exactly what a dynamic site is going to look and act like before it goes live. The combination of Linux, Apache, MySQL and PHP (LAMP) makes this possible.
Then we hit the "Apply" button, and away we go.
When the mysql> prompt shows its bad self, you'll then enter:
SET PASSWORD FOR 'root'@'localhost'=PASSWORD('enteryourpassword');
Fear not, we will also show a little friendlier way of manipulating MySQL databases in a bit. At this point, though, we can safely consider our LAMP installation complete.
Finally, though, we get to kick the tires on our new testing LAMP server. By default, your server is not able to be seen by the outside world. You are not publicly serving web pages from your home computer. Trust us, you want it this way. Many distros will start an installed version of Apache or MySQL on boot. You can disable this in your system settings, should you just feel better that way.
You can also start, restart, or stop these services with the command line. For now, let's see if Apache is running.
If you should want to start and stop MySQL, as well, the commands are similar, with mysql replacing apache2 (or mysqld replacing httpd) in the above command.
For now, let's just double check Apache 2 is functional. We open our browser, and type in http://locahost and discover:
So there we are. Apache is installed, working, and now we've got this index.html file somewhere on our computer that has the truly profound text "It works!" in it. Where is that file?
Yeah, well, this is the other bit that varies from distribution to distribution. In Ubuntu, you'll find your Apache server document root in the var directory (a favorite of pirates everywhere. VAAAAR!) in the subdirectory www. Other distributions (such as Fedora) will have the public (but, again, public only to people using your computer) directory under /var/www/html. OpenSUSE has it creatively under /srv/www/htdocs.
There is a nice run down of where you can find all sorts of Apache locations and commands for various distributions on the Apache wiki.
Testing the CMS
This is the fun part (really)! It can vary a bit from CMS to CMS, but your sturdy LAMP setup should support them all now. We opted to use WordPress for our sample, but seriously, use what you want. Follow the instructions on the CMS's site, and you should be golden.
The one thing you might want to do (this was necessary with WordPress) is install an easy access interface to MySQL. You won't need it often, most likely, in the testing scenario, but it does make things a lot easier than messing with MySQL on the command line.
Fire up your package management program again, and install phpMyAdmin.
Once inside the belly of your MySQL install, you can create a database for your CMS to use (if it does not create one itself) by typing a database name in the Create New Database cell.
Now is when it all pays off. Unzip your CMS, and copy it into your Apache 2 document root folder. In our case, on Ubuntu, it was /var/www and we needed to copy it as root (you may want to change permissions as necessary on that folder so you're not doing things as root when you don't mean to all over the filesystem).
Then, we simply followed our CMS provider's instructions for install. We entered our database information, and then came the moment of truth:
Here we see that going to http://localhost/wordpress/wp-admin/install.php is successfully returning the php code and the database connection. (Note that the extra "wordpress" directory was due to the way we copied our files into the /var/www directory.)
So here we are, presented with a pretty plain jane sort of default CMS install. Next, we'll fire up some editors to make this install much more visually interesting!