Here are the steps I use when setting up WordPress on new Ubuntu server.
- Log into the console and grab a root shell
Note: I don’t like typing sudo in front of every command$ sudo bash
- Install an ssh server to make remote management easy
# apt-get install openssh-server
- Install a LAMP stack
Note: You will need to remember the root password you setup for MySQL# apt-get install lamp-server^
- Download the latest wordpress
# wget http://wordpress.org/latest.tar.gz
- Extract the archive file
# tar -xzvf latest.tar.gz
- Make a folder to hold the wordpress install
# mkdir /var/www/wordpress
- Move all the WordPress files to folder you created
# cp -r ~/wordpress/* /var/www/wordpress
- Create a mysql user account and database for wordpress.
Note: Will need the root password created when installing the lamp stack# mysql -u root -p
- Create now a new database for wordpress
Note: Replace WordPress with any name of your choicemysql> CREATE DATABASE WordPress;
- Add now a new mysql user for wordpress
Note: Replace “username” with any name of your choicemysql> CREATE USER username;
- Assign a password to the wordpress mysql user
Note: Replace “abcd” with your own passwordmysql> SET PASSWORD FOR 'username' = PASSWORD('abcd');
- Grant the wordpress user all privileges for the wordpress database
mysql> GRANT ALL PRIVILEGES ON WordPress.* TO 'username' IDENTIFIED BY 'abcd';
- After setting up the database and user, exit MySQL
mysql> exit;
- Create a WordPress configuration file by copying the template
Note: If you installed in another directory, then correct the given path to your own.# cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php
- Edit the WordPress configuration (wp-config.php) so it contains your MySQL information
Note: I use nano for all text editing, but feel free to use whatever tickles your fancy# nano /var/www/wordpress/wp-config.php
- Insert now your MySQL settings you have just created by replacing:
- database_name_here —> with the database name you have created. For this tutorial, it’s named “WordPress”
- username_here —> with the MySQL user you have created earlier
- password_here —> with the password you assigned to the MySQL user
Note: After editing is complete, exit nano by a ctrl-x, then y to save
- Create an Apache config for the WordPress site by copying the default
# cp /etc/apache2/sites-available/default /etc/apache2/sites-available/wordpress
- Open the config you copied to edit it
# nano /etc/apache2/sites-available/wordpress
- Edit the wordpress config as follows:
- Change the DocumentRoot and Directory to /var/www/wordpress
- Edit the “AllowOverride” options to say All instead of None
- Disable the default apache config, enable the WordPress apache config, and enable the rewrite module
# a2dissite default && a2ensite wordpress && a2emod rewrite
- Create a .htaccess to hold the wordpress rewrite rules
# touch /var/www/wordpress/.htaccess
- Give the apache service rights to the folder and allow editing of the .htaccess file
# chown -R www-data:www-data /var/www/wordpress/ # chmod -v 664 /var/www/wordpress/.htaccess
- Restart apache to reload settings
# apachectl restart
Finished.