Tutorial

How To Install WordPress on Debian 7

Published on November 5, 2013
author

Adam LaGreca

How To Install WordPress on Debian 7

About WordPress

WordPress is a free and open source blogging tool used by more than 18.9% of the top 10 million websites [as of August 2013]. This makes WordPress the most popular blogging system in use on the Web at more than 60 million websites. Setting up WordPress on a DigitalOcean Droplet with Debian is one of the fastest and simplest ways to host your own website-- Let's get started!

Creating a Droplet

Specify Hostname After visiting your control panel and clicking "create," you will want to enter a hostname that's relevant to how you will be utilizing your virtual private server. For this tutorial, we'll simply use myblog.com.

Select Size of your VPS The size plan you choose is completely up to you. The most basic plan has plenty of capacity to host your WordPress site; however, if traffic to the site will be higher than an average user, it may be best to choose the next plan up. Also, you can always resize your VPS later, so at the moment take your best guess and know that in the future you can adjust simply and easily if necessary.

Select Your Desired Region In most cases, you will be choosing the default option for your location:

Select Image *You'll want to choose the most recent distribution of Debian:

Add SSH Keys It is recommended that you use SSH keys as they are more secure than passwords.

Click Create Droplet!

Initial Server Setup

Install Lamp Before working with WordPress, you need to have LAMP installed on your virtual private server. If you don't have the Linux, Apache, MySQL, PHP stack on your VPS, you can find the tutorial for setting it up in the LAMP tutorial.

*If you are signed in as your new user and not in root, many of the commands in the tutorial above will need to be preceded by "sudo" in order to work.

Root Privileges You will want to setup a new user with root capabilities. These steps and more concerning setting up your Droplet are described in this tutorial: Initial Server Setup.

Please make a note of the username that you create, as you will need it later in this tutorial.

You should be signed in as the new user, not root, when you follow this tutorial.

Download and Setup WordPress on your VPS

Download WordPress

We can download WordPress straight from their website:

wget http://wordpress.org/latest.tar.gz

The next command will now download the zipped WordPress package straight to your user's home directory:

tar -xzvf latest.tar.gz 

Create WordPress Database and User

After we unzip the WordPress files, they will be in a directory called "wordpress" in the home directory.

MySQL Directory For WordPress

We need to take a moment and create a new MySQL directory for WordPress. Go ahead and log into the MySQL Shell:

mysql -u root -p

*Now let's make the database.

This tutorial will call its database wpdatabse for simplicity's sake-- feel free to give it whatever name you choose):

CREATE DATABASE wpdatabase;
Query OK, 1 row affected (0.00 sec)

Then we need to create the new user. You can replace the database, name, and password, with whatever you prefer:

CREATE USER wpuser@localhost;
Query OK, 0 rows affected (0.00 sec)

Set the password for your new user:

SET PASSWORD FOR wpuser@localhost= PASSWORD("dbpassword");
Query OK, 0 rows affected (0.00 sec)

Finish up by granting all privileges to the new user. Without this command, the wordpress installer will not be able to start up:

GRANT ALL PRIVILEGES ON wpdatabase.* TO 
wpuser@localhost IDENTIFIED BY 'dbpassword';
Query OK, 0 rows affected (0.00 sec)

Then refresh MySQL:

FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

Exit out of the MySQL shell:

exit

Setup the WordPress Configuration

The first step to is to copy the sample wordpress configuration file, located in the wordpress directory, into a new file which we will edit, thus creating a new usable wordpress config:

cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php

Then open the wordpress config:

sudo nano ~/wordpress/wp-config.php

Find the section that contains the field below and substitute in the correct name for your database, username, and password:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wpdatabase');

/** MySQL database username */
define('DB_USER', 'wpuser');

/** MySQL database password */
define('DB_PASSWORD', 'dbpassword');

Save and Exit.

Copy the Files

We are almost done uploading Wordpress to the virtual private server. The final move that remains is to transfer the unzipped WordPress files to the website's root directory.

sudo rsync -avP ~/wordpress/ /var/www/

Finally we need to set the permissions on the installation. First, switch in to the web directory:

cd /var/www/

Give ownership of the directory to the Apache user. www-data is the Apache user. You are also going to add your personal user to the www-data group so you don't lose access to the files. You should replace username with the username you created earlier, and which you should be logged in as right now.

sudo chown www-data:www-data /var/www/* -R 
sudo usermod -a -G www-data username

From here, WordPress has its own easy to follow installation form online.

However, the form does require a specific php module to run. If it is not yet installed on your server, download php-gd:

sudo apt-get install php5-gd

Access the WordPress Installation

Once that is all done, the wordpress online installation page is up and waiting for you:

Access the page by adding /wp-admin/install.php to your site's domain or IP address (eg. example.com/wp-admin/install.php) and fill out the short online form (it should look like this).

To see the WordPress site, we will need to rename the default Apache index.html page.

mv /var/www/index.html /var/www/index.html.orig

Now you can access the main site by visiting your domain or IP address.

See More

Once Wordpress is installed, you have a strong base for building your site.

If you want to encrypt the information on your site, you can Install an SSL Certificate

By Adam LaGreca

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors
Default avatar
Adam LaGreca

author

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
10 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

You have a few of typos in this… you switch between wpSuser and wpuser, as well as wordpress.* where wpdatabase.* belongs (when granting permissions).

Helpful to me still, though, so thanks!

sudo rsync -avP ~/wordpress/ /var/www/

why dont you just use cp to copy it? (or mv to move it)

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
January 19, 2014

@dd3: You would have to run two cp commands to copy non-hidden and hidden files (those whose names begin with a dot), while rsync copies both in one command.

I’m stuck here;

Give ownership of the directory to the apache user.

sudo chown www-data:www-data * -R sudo usermod -a -G www-data username

I don’t know what to put for a username here: sudo usermod -a -G www-data username Do I just use ‘username’ or the username I created during the “Initial Server Setup Tutorial”? Or did I miss a step and I was supposed to create an Apache user?

Andrew SB
DigitalOcean Employee
DigitalOcean Employee badge
May 19, 2014

@flagca: Thanks for catching that! Should be fixed now.

I’m ALSO stuck here;

Give ownership of the directory to the apache user. sudo chown www-data:www-data * -R sudo usermod -a -G www-data username I don’t know what to put for a username here: sudo usermod -a -G www-data username Do I just use ‘username’ or the username I created during the “Initial Server Setup Tutorial”? Or did I miss a step and I was supposed to create an Apache user?

Kamal Nasser
DigitalOcean Employee
DigitalOcean Employee badge
July 13, 2014

@f.huacuja: You need to replace username with the actual username you created while following the Initial Server Setup tutorial.

Hello, I finally was able to install Wordpress on my droplet, BUT… I can get into http://104.131.131.157/wp-admin/, but not to the main site: http://101.131.131.157. I get the apache message: !IT WORKS!.. What did I do wrong???

I’d aprreciate you help in this matter…

Fausto A. Huacuja

I GOT IT!!!

I removed the index.html file that was created by apache…

thanks anyway…

Fausto A. Huacuja

how to modificate php.ini cause max upload size to small

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.