It’s something of a complicated installation, since you basically have to create a LAMP Server as you go, but it’s possible to install WordPress 2.9.2 on a desktop PC (or a virtual machine) running either the server or the desktop editions of Ubuntu 10.04. This makes an excellent environment for testing and experimentation, since you can tweak and experiment to your heart’s desire without rendering your production blog inoperable. If you need to run an internal corporate blog of some kind, hosting WordPress on an Ubuntu box or virtual machine is a cheaper solution than more expensive blogging or collaboration software. Or, if you’re really ambitious (and you can afford the bandwidth), you can host an Internet-accessible WordPress blog out of your apartment.
Let’s begin!
First, install Ubuntu into your machine of choice. Once Ubuntu is installed and updated, you will need to install five pieces of software: the Apache web server, the MySQL database server version 5.1, PHP version 5, the MySQL module for PHP, and finally the WordPress software itself.
To install this software, open up a Terminal window (Applications, Accessories, Terminal), and type the following command (note that all Terminal commands are shown here in bold, and that all Terminal commands are case-sensitive):
sudo apt-get install apache2
Follow the prompts to install Apache. Once the installation is finished, you can test that Apache is working by opening up Firefox and navigating to http://127.0.0.1. If you see the “it works!” web page, you have Apache up and running.
Next, you’ll need to install MySQL. Return to the Terminal and type this command:
sudo apt-get install mysql-server-5.1
During the installation you be will asked to provide a root password for MySQL. Be sure to pick a strong password (a combination of lowercase, punctuation, and uppercase letters), since the root user has full access to all tables on all databases. For obvious reasons, you’ll want to remember this password, not least because we need it again in the following steps. MySQL is a big package, and depending on your connection and computer speed, it might take a while to install.
Next, install PHP version 5:
sudo apt-get install php5
Then install the MySQL module for PHP:
sudo apt-get install php5-mysql
Finally, download the WordPress software to your Desktop. You can obtain it from this address:
http://wordpress.org/latest.tar.gz
Now that we’ve got our software installed and downloaded, we’ll need to configure it.
First, you’ll probably need to add a line to your /etc/apache2/apache2.conf file. I’ve read differing things about this, but I have found in my own testing that WordPress would not function properly without it, since Apache did not properly interpret the PHP pages otherwise. To edit apache2.conf, use the following command:
sudo gedit /etc/apache2/apache2.conf
(Note that it’s a good idea to back up any system configuration file before editing it. You can do so quickly by using sudo cp /etc/apache2/apache2.conf ~/Desktop to save a copy to your Desktop. You can of course use vi or emacs or the editor of your choice, but most new users seem to prefer gedit’s GUI.)
Once you are in gedit, add the following line to the end of the file:
AddType application/x-httpd-php .html
Save the file and exit gedit. Restart Apache with this command, so it re-reads its configuration file:
sudo /etc/init.d/apache2 restart
Now we’ll need to prepare MySQL for use with WordPress. First, you’ll need to run MySQL’s install script:
sudo mysql_install_db
Once this is completed, log into the MySQL command-line client:
mysql -u root –p
Enter your MySQL root user password from above, and you’ll find yourself at the MySQL> local client prompt. First, create a database for WordPress to use:
CREATE DATABASE wordpress;
(Note that all commands entered in the MySQL local client must end with a semicolon to denote the end of the statement.)
Once the database is created, you’ll need to create a database user for WordPress to use. While still in the MySQL command line client, type this:
CREATE USER wordpressuser;
Then create a password for your new user (note that your password will actually go within the quotation marks, and is case-sensitive):
SET PASSWORD FOR wordpressuser = PASSWORD(“password”);
Now that you’ve got your WordPress database and your WordPress database user, you’ll need to grant the user all permissions on the database (again, the password goes within the quotation marks, and is case sensitive):
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY ‘password’;
(Make sure to append “@localhost” to wordpressuser; otherwise you’ll get a database error when you try to start WordPress for the first time.)
Then type exit to quit the MySQL local command-line client. Now that we have MySQL prepared, we can now actually install WordPress. Create a directory called /var/www/wordpress, and unpack the WordPress files into that directory. Once the files are unpacked and move to the proper directory, you’ll need to configure WordPress to talk to the MySQL database. To do so, you must create a wp-config.php file in the WordPress directory. Fortunately, WordPress includes a handy wp-config-sample.php you can use as a template.
Type this command (assuming you installed WordPress in the www/wordpress directory):
sudo gedit /var/www/wordpress/wp-config-sample.php
Once there, change the following values (This assumes you used the default database names and passwords listed above):
Change putyourdbnamehere to wordpress.
Change usernamehere to wordpressuser.
Change yourpassword here to the password you selected in the GRANT ALL ON wordpress.* TO wordpressuser IDENTIFIED BY ‘password’; command.
Once you have your changes made (after double-checking the spelling, of course), save your changed file to /var/www/wordpress as wp-config.php.
Everything should now be ready. Open up a web browser, and navigate to http://127.0.0.1/wordpress. If you configured everything correctly, you should then be greeted by the WordPress configuration page. Follow the prompts, and you will have a functional WordPress blog installed on a Ubuntu desktop machine. Congratulations!
One final note: if you configure your blog from a local browser, it will probably set your blog’s address as http://127.0.0.1/wordpress. This is fine if you only want to view it from the host machine, but if you want to view it over the network, you’ll need to change it. Fortunately, you can do so quickly by going Options in the WordPress admin interface, and then to General, and changing the blog’s URL.
-JM
聯(lián)系客服