Due to be released October 18th, Ubuntu 12.10 (”Quantal Quetzal”) looks like it’s going to be a pretty decent operating system. Most of the changes are minor, but in testing it I’ve found it to be very stable. I’ve whipped up some tutorials in preparation of the release for those folks looking to get their machines going.
Most web developers prefer a local webserver when doing development. If you can work this way it’s more convienient especially when going solo. Today’s tutorial will show you how to set up Apache, PHP and MySQL on your Quantal Quetzal machine so you can get rolling.
Install Apache
First you install Apache, and it’s as easy as it ever was:
After a quick install it will come up automatically. Load up a browser and point it http://localhost and you should see this:
This is your bare Apache server. Next we’ll add PHP.
Install PHP
You’ll want to install the latest version of PHP 5, to do that type:
This will install PHP5 plus the libraries to interface with Apache.
You’ll want to restart the server
To test it out, create a file called test.php:
Let’s use the phpinfo() function so we can check out our installation:
It should look like this:
You can inspect your options and if you want to change anything, your php location is here:
Install MySQL
Next you’ll need to install the MySQL server. This is also super easy:
MySQL will ask you for a password. You really shouldn’t leave this blank, even if it is just going to be on your local machine. It only takes a second to do and some applications will require a password of some type on the server.
Test your server to make sure it’s working properly.
It should look something like this:
Now you’re up and running!
You may want something to manage your MySQL data, I realize not everyone is as crazy about the prompt as I am. PHPMyAdmin is great:
or you could download something like MySQL Workbench and work with your database that way.
Optional Publishing Method
Publishing can be kind of a pain because when you install Apache it makes the document root of the webserver /var/www that is owned by root. So this causes a problem. Here is one solution.
then, open up your config file:
And change your DocumentRoot. There will be a section that says:
then restart your server:
I created a folder in my home directory called “web” and then created a symbolic link:
so I can work in a folder in my home directory ( I actually do most work in VIM ). Of course there’s a little permissions issue still, so run the following commands, but be sure to subsitute your user name.
Now I can create files or entire an entire website in my own folder ( /home/jeremy/web ) and view it thru localhost.
Conclusion
So it turns out setting up Apache, PHP and MySQL is no different in Quantal Quetzal than in recent Ubuntu versions. Using apt-get for management takes a lot of hassle out of software management. I hope this helps you in setting up a local webserver, so you can start building some awesome stuff.
I will whip out a few more Quantal Quetzal tutorials in the coming days for those early adopters who like to try out the newest stuff. Questions? Leave me a comment!
No comments:
Post a Comment