Tutorial

How To Install WordPress on Debian 7

Published on November 4, 2013
Default avatar

By 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 us


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!

excellent, everything works … my wordpress ta perfectly in the air. but I have 4 more domains in the air aimed at the servers names of digital ocean, all of them when I type in the browser, always carries the same site, always my only installation … which install more web and how do I each loading up different facilities wordpress?

I have followed the tutorial here and have obtained ejido with my wordpress working well with various security measures found here, and performance improvements … all well and good … but not against information: How can I have several wordpress installed on even dropets? I installed my wordpress … add domains on the panel in the set up and DO panel batelas this domains and ta … all ok … but all my domains leads to my only installation of wordpress … as did the pointing at the company where I have my domains registered using the name servers of dO and okay … are all opening my instação my VPS / dropets the dO … now how do I have several wordpress in the same dropets? … a wordpress for my every field I added in my dropets ?? who in time of instação I define it that wordpress is installed in a particular field? for I have not equally important administrative issues panel … just use command lines in terminal of my personal linux.

THAAAANKS, this list tutarias beautifully detailed here in the community helped me to have my wordpress hosted digitalocean, and the parameters of security under ssh keys and constraint parameters to root users do not have access access, I’m using different port access to my server … restricted permissions to the directory /home/user/.ssh, I’m using nginx q uses less resources machine that apache … more advantages thanks to this wonderful community … Thank you.

This comment has been deleted

    First off, thanks so much for these tuts!!!

    Going onto the issue:*

    • Droplet, domain etc ok

    • initial server setup ok

    • root privs ok

    • mysql ok

    • download wordpress ok

    • creation wp dbase, user and dbase ok

    • wp configuration ok

    • copy files via rsync ok

    • sudo usermod -a -G www-data ***** ok

    • mv /var/www/index.html /var/www/index.html.orig - directory does notexist

      when doing an ls -l commands under /var/www/ I can see: that this was actually under /var/www /html/index.html so i copied them like that accordingly.

    however the example.com/wp-admin/install.php was still propblematic. I.e. it was giving the 404 error - The requested URL /wp-admin/install.php was not found on this server.

    when i went to wp-admin folder, the ls -l showed that the file was infact there and the file is not empty.

    Any idea what I might have wrong… thanks for any help in advance!!!


    ps. i did all commands under the user that was instructed to be created with all permissions. Whenever I had issues not to continue due to permissions I used the sudo command (I am thinking that it might have been put into a directory or something),

    edit - I moved the wordpress files from

    /var/www/ to cd /var/www/wordpress

    but the results are the same :/

    I got no errors with the commands below: sudo chown www-data:www-data /var/www/* -R sudo usermod -a -G www-data saku

    But, after these commands, user ‘saku’ seems still does not have the write permission to ‘/var/www/’ $ touch /var/www/test touch: cannot touch `/var/www/test’: Permission denied

    PS: User ‘www-data’ has the write permission to ‘/var/www/’.

    That’s fucking bullshit

    Sharon Campbell
    DigitalOcean Employee
    DigitalOcean Employee badge
    October 7, 2014

    I just updated this tutorial to clarify that “username” should be your current Linux user.

    I also updated it to specify that the default index.html page needs to be renamed so you can view the WordPress home page.

    I hope that helps!

    I Have problem to Give ownership of the directory to the apache user user not found Please help…

    root@example:/var/www# sudo usermod -a -G www-data hamad usermod: user ‘hamad’ does not exist

    i already created the username

    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!

    Get our biweekly newsletter

    Sign up for Infrastructure as a Newsletter.

    Hollie's Hub for Good

    Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

    Become a contributor

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

    Welcome to the developer cloud

    DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

    Learn more
    DigitalOcean Cloud Control Panel