Making your own webdev environment on Ubuntu desktop
These machines aren’t all fun fun fun, sometimes you have to use them for some more serious work. In this post I’m going to tell you how to make your own php/mysql web development environment on your own Ubuntu desktop. Once you’ve done this you won’t need to keep uploading files to your server just to check if something works.
Firstly I’d like to point to the post that originally helped me do this at webmasterview.com.
Now, time to open up our trusty terminal. It is possible to do this through synaptics, but its quicker to do it like this:
First thing is to install mysql for databases on our machine. Copy this bit of code into your terminal:
sudo apt-get install mysql-server
Next we need apache2 as our webserver. Here is the code:
sudo apt-get install apache2
Then we need to get php:
sudo apt-get install php5
There are our three basic components. Now we need to hook them together:
sudo apt-get install libapache2-mod-php5
and
sudo apt-get install php5-mysql
Now that’s just grand. We’ve now got all the elements that we need to serve files to the net. The thing is, we’re only doing this so we can work on stuff at home, in which case what we’re really looking for is an easier way to do so. What we need to do is have a public_html folder in our user directory. Perhaps now would be a good time to do that. The next step is making that work on the webserver we’ve just installed. Run this snip of code:
sudo a2enmod userdir
Then restart apache:
sudo /etc/init.d/apache2 force-reload
You should now be able to reach your home folder via http://localhost/~yourusername/
Finally we want to be able to administer our mysql databases. Though there are many good tools for doing this I still go back to the web based phpMyAdmin. Apart from the fact that it’s highly automated (which suits me just fine) it’s also a very common program to find on your paid hosting, so would also be very familiar when you go live. For the quick and dirty way of getting it up and running, download phpMyAdmin and extract to your public_html folder. Personally I rename it to something a little easier. Then rename the file within from config.example.inc.php to config.inc.php and within that file put something in the blowfish_secret field. Then all you have to do is navigate your browser to something like http://localhost/~yourusername/phpMyAdmin
addendum
If your server is going to be visible from the big bad world and this is your everyday machine then you need to turn off that user public_html stuff (it’s insecure for general use!). To do that just enter this instruction
sudo a2dismod userdir
then reload apache as before