A community article covers installation via an official package, however, I found this to be problematic with modifications and upgrades. I’ve included instructions for both package installation and manual installation.
I’ve made the following assumptions:
- you want to be able to run multiple sites (or at least have the possibility of)
- site document roots exist at
/var/www/<sitename>
Dependencies
Ensure any major dependencies are installed:
sudo apt-get install apache2 php5-gd mysql-server
Apache2 Virtual Hosts
Create a suitable virtual host entry for the site, e.g. /etc/apache2/sites-available/example.com
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example:80
DocumentRoot /var/www/example.com
<Directory /var/www/example.com>
Options FollowSymLinks
AllowOverride Limit Options FileInfo
DirectoryIndex index.php
</Directory>
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
ErrorLog /var/log/apache2/example.com-error.log
CustomLog /var/log/apache2/example.com-access.log combined
</VirtualHost>
Enable the site and restart apache2:
sudo a2ensite example.com
sudo /etc/init.d/apache2 restart
Installation
By Package
Install using apt-get:
sudo apt-get install wordpress
The application is installed to /usr/share/wordpress, so if you wish to use a sub url (i.e. http://example.com/wordpress) then simply symbolic link to this, e.g.:
sudo ln -s /usr/share/wordpress /var/www/example.com/wordpress
or if you want to run as the root url (i.e. http://example.com/) then use the install location directly in the DocumentRoot and Directory directives in the httpd config.
You need to have a config file for the domain name wordpress is being accessed by, and make symbolic links for any aliases too, e.g.:
sudo cp /usr/share/wordpress/wp-config-sample.php config-example.com.php
sudo ln -s config-example.com.php config-blog.example.com.php
sudo ln -s config-example.com.php config-www.example.com.php
Manually
Install using the following commands:
cd /var/www/example.com
sudo wget http://wordpress.org/latest.tar.gz
sudo tar xvf latest.tar.gz
sudo rm latest.tar.gz
This will create an instance of wordpress at /var/www/example.com/wordpress which will be serviceable at http://example.com/wordpress. To service as the root url, run the following:
sudo mv wordpress/* .
sudo rmdir wordpress
Create a default configuration from the sample config:
sudo cp wp-config-sample.php wp-config.php
Create a .htaccess file for any url mappings:
sudo touch .htaccess
Ensure the correct permissions are given:
sudo chown -R www-data:www-data .
MySQL setup
Create a suitable database, user and permissions.
CREATE DATABASE IF NOT EXISTS `wordpress`;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'wordpresspassword';
GRANT USAGE ON *.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'wordpresspassword';
GRANT ALL PRIVILEGES ON `wordpress`.* TO 'wordpressuser'@'localhost';
Use a suitable database name, username and password - not the above!
Configuration
Database credentials
Modify the configuration file to supply the credentials for the database.
Securing logins and admin site
As described in the Administration Over SSL in the Wordpress Codex, modify the configuration file by adding:
/** Enable SSL */
define('FORCE_SSL_ADMIN', true);
Comments
blog comments powered by Disqus