This article covers a version of CentOS that is no longer supported. If you are currently operating a server running CentOS 6, we highly recommend upgrading or migrating to a supported version of CentOS.
Reason: CentOS 6 reached end of life (EOL) on November 30th, 2020 and no longer receives security patches or updates. For this reason, this guide is no longer maintained.
See Instead:
This guide might still be useful as a reference, but may not work on other CentOS releases. If available, we strongly recommend using a guide written for the version of CentOS you are using.
The following DigitalOcean tutorial may be of immediate interest, as it outlines installing WordPress on a CentOS 7 server:
Wordpress is a free and open source website and blogging tool that uses php and MySQL. It was created in 2003 and has since then expanded to manage 22% of all the new websites created and has over 20,000 plugins to customize its functionality.
The steps in this tutorial require the user to have root privileges. You can see how to set that up here in steps 3 and 4.
Before working with wordpress, you need to have LAMP installed on your server. If you don't have the Linux, Apache, MySQL, PHP stack on your server, you can find the tutorial for setting it up here.
Once you have the user and required software, you can start installing wordpress!
We can download Wordpress straight from their website:
wget http://wordpress.org/latest.tar.gz
This command will download the zipped wordpress package straight to your user's home directory. You can unzip it the the next line:
tar -xzvf latest.tar.gz
After we unzip the wordpress files, they will be in a directory called wordpress in the home directory.
Now we need to switch gears for a moment and create a new MySQL directory for wordpress.
Go ahead and log into the MySQL Shell:
mysql -u root -p
Login using your MySQL root password, and then we need to create a wordpress database, a user in that database, and give that user a new password. Keep in mind that all MySQL commands must end with semi-colon.
First, let’s make the database (I’m calling mine wordpress for simplicity’s sake; feel free to give it whatever name you choose):
CREATE DATABASE wordpress; 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 wordpressuser@localhost; Query OK, 0 rows affected (0.00 sec)
Set the password for your new user:
SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password"); 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 wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password'; 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
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, creating a new usable wordpress config:
cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php
Then open the wordpress config:
vi ~/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', 'wordpress'); /** MySQL database username */ define('DB_USER', 'wordpressuser'); /** MySQL database password */ define('DB_PASSWORD', 'password');
Save and Exit.
We are almost done uploading Wordpress to the server. The final move that remains is to transfer the unzipped WordPress files to the website's root directory.
sudo cp -r ~/wordpress/* /var/www/html
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 yum install php-gd
Last of all restart Apache:
sudo service httpd restart
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).
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
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
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!
I used your guides to install LAMP and Wordpress… they worked perfectly… thank you for your time and effort!
Thank you for your kind words! Please let us know if there are any other article topics that you’d like to see. =]
I’m having an extremely frustrating problem installing wordpress on my centos 6.3 guest (vmware workstation) … I’m at the step where I am supposed to run the install.php file from a web browser, and I can’t run the file because it’s not there in the package! I’ve re-downloaded the wordpress package several times now, and every time I look inside the wp-admin folder, the install.php file is nowhere to be found. Any idea why this would be happening?
The install.php file should come automatically with Wordpress. I just ran through these steps once again on a droplet with Centos 6.3 and it worked without the issue you described above.
What message do you get when you try to access the Wordpress install page?
Hi there, your tutorials are easy to follow and well documented! Thanks ;) I need some help, I cannot setup the automatic wordpress update because i don’t have the good credentials for ftp user in wordpress. How can I add a user/pwd for wordpress access to my server ? Help will be really appreciated ;)
You can actually use SSH instead of FTP to update wordpress.
There are a few steps you need to take:
Install the EPEL repo: <pre>sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm</pre><br/>
Install the php-ssh2 module: <pre>sudo yum install php-pecl-ssh2</pre><br/>
Reload Apache: <pre>sudo service httpd reload</pre><br/>
Then, once you are in wordpress and trying to update something, you will be able to choose another connection. You will see in the section where it asks you for the FTP user and password, there will be another option to use the connection type SSH2. Using SSH2, put in your server userid and password and you should be able to update wordpress.
Hello, it’s working fine! thanks you very much, you rock!
Great stuff. However, I get the following error when browsing to the <ip address>/wp-admin/install.php page:
Can’t select database
We were able to connect to the database server (which means your username and password is okay) but not able to select the intranet database.
Any assistance would be great. Thanks.
Thank you Very MUCH! Appreciate this post. There is a few thing however that I had to change:
Directory structure. First of all, most users will be inside the root folder when running the following command: wget http://wordpress.org/latest.tar.gz So, you need to download the package to the right directory, which is: /var/www/html. Your shell console should
show the following to know you are downloading in the right directory: [root@yourservername html]# wget http://wordpress.org/latest.tar.gz
Running the following command: tar -xzvf latest.tar.gz created a ‘wordpress’ folder inside my ‘html’ folder. This means that when you visit your site, you will have to go
to: www.mysite.com/wordpress. To take all the files out of the wordpress directory up one directory(into the hmtl folder), run the following command when inside the ‘wordpress’ folder shopt -s dotglob ## activate dotglob mv ./* …/ shopt -u dotglob ## deactivate dotglob
Configuring the wp-config.php file If you are stupid like me, you would assume that you should add your user to the config file like this define(‘DB_USER’, ‘wordpressuser@localhost’); like it the post, DO NOT add the @localhost… This caused my site to respond with the annoying ‘database not found’ message
Thanks again for your help
my wordpress is runing but i cant upload themes using the upload function of wordpress: Unable to create directory wp-content/uploads/2013/07. Is its parent directory writable by the server?
this is the message and i upload the theme from ftp but i cant see the theme in my wordpress desktop
i have a shared hosting and i upload the theme all work in these shared hosting.
when i try to install a theme wordpress askme me the ftp user
i put my correct credentiales but dont work this is the message: Unable to locate WordPress Content directory (wp-content).
maybe problema with write permisions for wordpress
@webesdinero: Try editing wp-config.php and adding the following line at the very bottom of the file:
define(‘FS_METHOD’,‘direct’);
Run “chmod 777 /var/www/html/wp-content/uploads”. That should fix it.
When I try to unzip the file using tar -xzvf latest.tar.gz, I get: tar (child): latest.tar.gz: Cannot open: No such file or directory tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error is not recoverable: exiting now
Nevermind, I found the issue.
Great tutorials, have managed to get a home web-server up and running with dynamic dns.
I have a question though about the above tutorial; I get the following error when I try to install the php-ssh2 module
Packages skipped because of dependency problems: php-pecl-ssh2-0.11.0-7.el6.x86_64 from epel
Setting up Install Process Resolving Dependencies –> Running transaction check —> Package php-pecl-ssh2.x86_64 0:0.11.0-7.el6 will be installed –> Processing Dependency: php(zend-abi) = 20090626 for package: php-pecl-ssh2-0 .11.0-7.el6.x86_64 –> Processing Dependency: php(api) = 20090626 for package: php-pecl-ssh2-0.11.0 -7.el6.x86_64 –> Finished Dependency Resolution Error: Package: php-pecl-ssh2-0.11.0-7.el6.x86_64 (epel) Requires: php(api) = 20090626 Installed: php-common-5.5.0-2.el6.remi.x86_64 (@remi-test) php(api) = 20121113-64 Available: php-common-5.3.3-22.el6.x86_64 (base) php(api) = 20090626 Available: php-common-5.3.3-23.el6_4.x86_64 (updates) php(api) = 20090626 Error: Package: php-pecl-ssh2-0.11.0-7.el6.x86_64 (epel) Requires: php(zend-abi) = 20090626 Installed: php-common-5.5.0-2.el6.remi.x86_64 (@remi-test) php(zend-abi) = 20121212-64 Available: php-common-5.3.3-22.el6.x86_64 (base) php(zend-abi) = 20090626 Available: php-common-5.3.3-23.el6_4.x86_64 (updates) php(zend-abi) = 20090626 You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest [06000224@centosbox ~]$ sudo yum install php-pecl-ssh2rpm -Va --nofiles --nodige st
Try running this command instead:
yum install php-devel php-pear
and installing the ssh2 extension via pecl:
pecl install ssh2
Hi Nasser, I tried and it failed again.
Error: Package: php-devel-5.3.3-23.el6_4.x86_64 (updates) Requires: php(x86-64) = 5.3.3-23.el6_4 Installed: php-5.5.0-2.el6.remi.x86_64 (@remi-test) php(x86-64) = 5.5.0-2.el6.remi Available: php-5.3.3-22.el6.x86_64 (base) php(x86-64) = 5.3.3-22.el6 Available: php-5.3.3-23.el6_4.x86_64 (updates) php(x86-64) = 5.3.3-23.el6_4 You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest [06000224@centosbox ~]$ sudo pecl install ssh2 Failed to download pecl/ssh2 within preferred state “stable”, latest release is version 0.12, stability “beta”, use “channel://pecl.php.net/ssh2-0.12” to install install failed [06000224@centosbox ~]$ sudo pecl install ssh2
Try “sudo pecl install channel://pecl.php.net/ssh2-0.12” instead. That should work.
I have a problem where the custom user I setup owns the files and then WordPress can’t auto update anything.
If I run sudo chown -R apache:apache /var/www then WordPress can auto update and all is great, but when I SFTP in, I can’t edit any files as I don’t have permissions.
How do I get the permissions to work properly so that WordPress can auto update and I can edit files?
@Thomas: <pre>chown -R youruser:youruser /var/www usermod -a -G www-data youruser</pre>
That should fix it :]
@Kamal usermod: group ‘www-data’ does not exist
Sorry, try apache instead of www-data.
No go. When I go to add/update/delete a plugin in WordPress it now asks for my FTP information. :(
Ok, so I got it to work after asking some smart friends.
Turns out I had to do the things @Kamal noted plus run sudo chmod -R 775 . (keep that period) while in /var/www/
Now my user and WordPress are happy.
The latest.tar file and the wordpress files you unzipped are all in the root folder, I deleted these through ftp, why download them to there in the first place instead of var/www/html?
@SaM5246: You can download it to /var/www - both would work fine.
noob here followed the tutorial with ease… Centos as guest in VM… but I cant login … trying to recover my password message is: The e-mail could not be sent. Possible reason: your host may have disabled the mail() function…
@edd.tortona: Log in via SSH and install sendmail
<pre>sudo yum install sendmail</pre>
thanks a lot for the tutorial but i get the following error on logging into the wp install page
Can’t select database We were able to connect to the database server (which means your username and password is okay) but not able to select the admin database.
Are you sure it exists? Does the user admin have permission to use the admin database? On some systems the name of your database is prefixed with your username, so it would be like username_admin. Could that be the problem? If you don’t know how to set up a database you should contact your host. If all else fails you may find help at the WordPress Support Forums.
NOTE:I AM INSTALLING IT ON A PAGE UNDER MAGENTO
@drshrey.lakhotia: Have you managed to fix it? If not, please create a new community question:
<a href=“https://www.digitalocean.com/community/questions”>https://www.digitalocean.com/community/questions</a>
I installed wordpress on step 1 but 2nd step commands are not working on Putty. How to log into the MySQL Shell??
@tahirmirza: Run the <code>mysql -u root -p</code> command to login to the MySQL shell.
what if i locked myself out and need to reset the password, I am not able to receive an email when i type my email address… Do i need to install a mail client?
@brody_ross: Yes, run <pre>sudo yum install postfix</pre> and if it prompts you for anything, choose the defaults. If you have a firewall set up, make sure you block access to port 25.
I installed sendmail, Do I also need to install postfix?
@brody_ross: No. You only need one MTA. Since you already installed sendmail, you don’t need to install postfix. Try checking your email’s spam folder, the email might have landed in there.
how would i change the admin user password in wordpress with ssh?
@brody_ross: Check out <a href=“http://codex.wordpress.org/Resetting_Your_Password#Through_MySQL_Command_Line”>http://codex.wordpress.org/Resetting_Your_Password#Through_MySQL_Command_Line</a>
You can install LAMP , or you can install it step by step without any script mistakes.
This is your call.
I preffer unscripted installation
I followed this to the letter. I now have a working WP install.
However, now I would like some guidance on how to add a new SFTP user to be able to access the site and make edits. In addition, how to allow WordPress to do updates/plugin installs automatically.
Please can someone shed some light on this. It might make a good new article as it’s the sort of stuff that people are always asking for.
Everything was just fine. But I am unable to upload any media. Getting this error. Any ideas?
Unable to create directory wp-content/uploads/2014/01. Is its parent directory writable by the server?
Upload directory was not there by default. I created it.
Hi there, I did everything right and Wordpress is working fine now. Thanks for the tutorial but I have a problem.
When I change permalinks settings and click on some post, I get Nothing found on the page. Can anyone help me with that? I’d really appriciate it.
Thanks in advance.
Just my 5 cents to solve issues when trying to crop images:
Error messages: “Image could not be processed. Please go back and try again.” “Crop error…”
Solution: yum --enablerepo=remi install php-gd.i686 yum --enablerepo=remi update
service php-fpm restart
Best regards, Tiago Lima
Thanks for this great guide! I just had one problem. When I get to the end and go to connect to the page, instead of the form to fill out, I get:
“/ * The base configurations of the WordPress. * * This file has the following configurations: MySQL settings, Table Prefix, *” etc etc
Can someone tell me what I did wrong? Thanks!
@guyreese: That sounds like it is just showing the php code instead of executing it. How did you set up your LAMP stack? Is php actually installed? Check out:
https://www.digitalocean.com/community/articles/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-6
Yeah, I followed that guide to set up the LAMP stack. I even went through and installed every module just to be safe. Also, when I go to my server’s info.php page it shows that I have php 5.3.3 installed.
This tutorial was awesome!
I’m a complete newbie. Just got hired to maintain a a lot of apps and no information was left behind. I have running WORDPRESS on my site, and I’d like to enable another site on the same server. In fact, I want to copy mydomain.com/site1 and create mydomain.com/site2 so I can use the same theme and just change content. How can I do this? I copied the entire directory, but when I try to go into mydomain.com/site2/wp-admin, it always takes me back to mydomain.com/site1/wp-login. How can I enable WP for site two? and how can I create a new user?
@pablo: Besides copying the folder, you need to set up a new VirtualHost in Apache and a new database in Mysql. This article is on Ubuntu, but it should point you in the right direction:
https://www.digitalocean.com/community/articles/how-to-set-up-multiple-wordpress-sites-on-a-single-ubuntu-vps
Hello! Very good manual, but when I try to enter ip/wp-admin/install.php I get “No input file specified.” I
m a totally newbie and don
t understand anything in configs. I googled and tried everything, I could do, but it didn`t help. Can you please, help me?