An easy way to install WordPress on a localhost (Ubuntu/Debian)

1. Install a LAMP stack

sudo apt-get update

sudo apt-get install apache2 php5 php5-mysql mysql-server

MySql will ask for a password for the root account.

Check your IP address (ifconfig) and put it in a browser. This will make sure that the Apache server is running.

The next step is to verify that PHP scripting module is loaded properly in Apache. This allows Apache to run PHP scripts to serve dynamic content. Without it or an alternative scripting language like Python, Apache is only able to serve static pages. To test the module, you may create a simple PHP script to test.

sudo sh -c ‘echo “<?php phpinfo(); ?>” > /var/www/phptest.php’

This creates a PHP script in the directory /var/www/

Point your browser to /localhost/phptest.php. A page will pop up, showing basic info on the PHP version, etc.

By default, files for web server are stored in the /var/www folder, which is writable by the root user only.

 2. Install wordpress

sudo apt-get install wordpress

The default installation directory is /usr/share/wordpress. This needs to be linked to the /var/www directory for Apache to see the files.

sudo ln -s /usr/share/wordpress /var/www/wordpress

Next, run the WordPress MySQL configuration script using the following command.

sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress localhost

This creates a new MySQL database, as part of the LAMP stack for WordPress to use. You may check wp-config.php to see more details.

You will then point your browser to localhost/wordpress to finish up the installation process.

3. Change ownership of the WordPress folder and why.

If you plan to update the WordPress installation (themes, plugins, etc.), you will need to allow the www-data user, the account used by the Apache server, to change the files stored in /usr/share/wordpress folder.

sudo chown -R www-data /usr/share/wordpress

Otherwise, you will be asked to provide FTP info when upgrading the WordPress installation.

Advertisements