Installing WordPress Step 3: Updating wp-config.php with Database Settings and Security Keys on Linux (CentOS)

This post is part of a step-by-step series on installing WordPress on Linux (CentOS 6)


  1. MySQL has been installed and secured
  2. WordPress Directory has been Installed
    1. Using yum
    2. Without yum
  3. MySQL database for WordPress has been made

Locating the config file

You can find your wp-config.php in your WordPress directory, wherever you installed it. It may be a symlink to the actual file but you can still access it through your WordPress root directory.

Modifying Database Info in wp-config.php

We will use vi to edit the config file:

[ahmed@amayem ~]$ sudo vi /etc/wordpress/wp-config.php

Check here to see how to give a linux user sudo powers.

Enter insert mode by pressing i. Go down to the following lines and put in the appropriate information in the second field as we defined when we setup the MySQL Database.

Database Name

define('DB_NAME', 'database_name_here');

I changed it to the following:

define('DB_NAME', 'testdb');

Database Username

define('DB_USER', 'username_here');

I changed it to the following:

define('DB_NAME', 'wptestuser');

Database Password

define('DB_PASSWORD', 'password_here');

I changed it to the following:

define('DB_NAME', 'testpassword');

Modifying Security Keys in wp-config.php

Since we are here we might as well prepare the security keys. This is easy, we just need to put in some random long string instead of put your unique phrase here. So Instead of the following:

define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

Replace the above with something like the following. You can generate random strings using this online generator. For more on copy pasting in vi check here

define('AUTH_KEY',         '&WJL|9S=pooIiyfdlOU|m-WiJ/mm+~SCL=4?j4C5$-T!FelaMbJ4$`q6,oUn:Kfd');
define('SECURE_AUTH_KEY',  'mFZ9tCF-|a=-uD[Syt<YYW(F:2;*,lGEp5Z <ZEh^C*_yh ]G%7y4,-YI]9*6;xX');
define('LOGGED_IN_KEY',    ':_nk`0z}@?.*fVpXPU=QhW+b4|h6uUXoGt.Ae6`p[/%iB-7GuX~g8>[4XcY/}-+k');
define('NONCE_KEY',        'QA1CQ|$==o]S2boaq$+$fU(n6J(`8+LVh1w<f~_w7LHD[B(&im]4xS>wa)obb*;l');
define('AUTH_SALT',        'G2Ju69{F}-)aee~*BWCNTAeI8IN+cSj+0t]0U<oOmo:-7nrxr!F/xXIbTJygm18}');
define('SECURE_AUTH_SALT', '+Nk)hpC+fs[Q3XWc$fsJY|[&%_2nngi1Fu$r~|d{[`2s0M}|WD+f-dPr3[29_fso');
define('LOGGED_IN_SALT',   'LKW8})#(FEL +;(P<:F(J -u4ur<2 A3x(`X,O64Y#0;G/KaOE &6HJL_N4mxVs&');
define('NONCE_SALT',       '7|e5}5uNjBm<]{>o4q+I^x.U2+o2U0H#+`6`|&Pe 9?U8tlgsodh]ncj?Ti?-<-k');

Save it

Done! Exit insert mode by entering ctrl+c or Esc and then :x to save.

Next Steps

  1. Deciding the Site Root Directory and Moving Files there
  2. Running the WordPress php Install Script


  1. Official WordPress Documentation on configuring wp-config.php
  2. Official WordPress Documentation on Security Keys
  3. Online Security Key Generators

Ahmed Amayem has written 90 articles

A Web Application Developer Entrepreneur.