This howto will outline how to install Apache httpd, MySQL and multiple WordPress -stable and -development instances on your Centos (or other) Linux desktop so you can work anywhere, regardless of internet connection or not. These instructions can be easily adapted to any Linux system if you have enough specific knowledge of how your distro is setup.

Applicable to Centos Versions:

  • Centos 5.x
  • Centos 6.x

Requirements

Explanation of requirements:

    Note: these links may change in the future, if they become dead, please report it.

  1. Download WordPress -stable (3.3) and -development (3.3b4) zip archives.
  2. Root or sudo access to the Centos system

Doing the Work

Basic description of what will be done and what is expected.

  1. Edit /etc/hosts as root:
  2. Make sure it looks something like this:
    
    # Do not remove the following line, or various programs
    # that require network functionality will fail.
    127.0.0.1       yourhostname localhost.localdomain   localhost
    ::1             yourhostname localhost6.localdomain6 localhost6
    127.0.0.1       wpdev
    127.0.0.1       wordpress1
    127.0.0.1       wordpress2
    
  3. Create web directories as root:
  4. ]# cd /var/www/html; mkdir -p wpdev wordpress1 wordpress2
  5. Install httpd, MySQL and PHP and configure them as root:
  6. ]# yum install httpd mysql-server php
    
    For instructions on setting up MySQL go Here
    Add these lines to the bottom of your httpd.conf located in: /etc/httpd/conf/httpd.conf
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    
    NameVirtualHost *:80
    
    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/wpdev
        ServerName wpdev
        ErrorLog logs/wpdev-error_log
        CustomLog logs/wpdev-access_log common
    <Directory /var/www/html/wpdev>
        AllowOverride All
    </Directory>
    </VirtualHost>
    
    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/wordpress1
        ServerName wordpress1
        ErrorLog logs/wordpress1-error_log
        CustomLog logs/wordpress1-access_log common
    <Directory /var/www/html/wordpress1>
        AllowOverride All
    </Directory>
    </VirtualHost>
    NameVirtualHost *:80
    
    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/wordpress2
        ServerName wordpress2
        ErrorLog logs/wordpress2-error_log
        CustomLog logs/wordpress2-access_log common
    <Directory /var/www/html/wordpress2>
        AllowOverride All
    </Directory>
    </VirtualHost>
  7. Add MySQL database as root:
  8. ]# mysql -p
    Enter password:
    mysql> CREATE DATABASE wordpress1;
    mysql> GRANT ALL PRIVILEGES ON wordpress1.* TO 'you'@'localhost' IDENTIFIED BY 'yourpass';
    mysql> FLUSH PRIVILEGES;
    mysql> QUIT;
    
  9. Configuring wp-config.php as root:
  10. ]# cd /var/www/html/wordpress1; unzip latest.zip; mv wp-config-sample.php wp-config.php
    ]# vi wp-config.php
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    
    // ** MySQL settings - You can get this info from your web host ** //
    
    /** The name of the database for WordPress */
    define('DB_NAME', 'wordpress1');
    
    /** MySQL database username */
    define('DB_USER', 'you')
    
    /** MySQL database password */
    define('DB_PASSWORD', 'yourpass');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    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');
    
    Note: DO NOT USE THE SALTS IN THE EXAMPLE BELOW
    Get a new set generated here: https://api.wordpress.org/secret-key/1.1/salt/
    
    Example:
    define('AUTH_KEY',         'v6liRDKI#vhN.{kB2M(u:}M^I][}f{,(0TzlVY^pWc.b;eO=/8l}8cD%1=X{mqm^');
    define('SECURE_AUTH_KEY',  '=b}=YB^5G0>b|F0!9N`]F8Djvv({</IQHhG|R*Fa68{Op!@EudNaQb0[#@nr=?Q]');
    define('LOGGED_IN_KEY',    'U5Aab1Sxf6VJ+PkJ<0Ty+.n8S9j|-MaSou6Hr$:y|F0Uq7GIofYmKzjz*=SLg=#)');
    define('NONCE_KEY',        'Nj;FkNp-F+-.Du!:.d;r/^.&<Rw 8LV^0%A~A=dqQ5taS}+Z9ddd1d.|bO@4y%/9');
    define('AUTH_SALT',        'M.OZPT;bK%wya&RT(`/a9_Eg-.n_Lv7{[AUio?LUx aI;J${D}t6H6F|9-wd.}@1');
    define('SECURE_AUTH_SALT', 'A&&I^a}SGLEsw0+]_o}AYH(A2Y/G1jSTq2Cg~>%.g]}&YK]BbBq?&e:+N rWJ(_g');
    define('LOGGED_IN_SALT',   'A4kIk[}0=Dra{y2/DU<w}oYvI+A:W0{Lx)nMF?3-Jp~kR+|{Eax00&ddK_[AMU<-');
    define('NONCE_SALT',       '#9C{^mXT0@Ik(RQ<TYGtGLV!U|DkC)uKtHA}n@TkC|FjUc*s`xKiN~}ree}5lGe^');
  11. As root, make sure MySQL and httpd are started and and your web directories are all owned by the user/group your web server runs as (DO NOT DO THIS ON PRODUCTION SERVERS), in our case "apache". Next, browse to your first install:
  12. ]# service mysqld restart; service httpd restart
    
    (This step allows you to run 1-click automatic core/theme/plugin updates from within your admin panel without being prompted for a password or ftp credentials) Security tip: DO NOT DO THIS ON PRODUCTION SERVERS
    ]# chown -Rf apache:apache /var/www/html
    
    Next, open a web browser and go to http://wordpress1
    
    You should be presented with the default WordPress install page.
    
    You can repeat this for as many isolated instances as you want on your laptop or desktop Linux workstation.
    

Troubleshooting & Supplementary Information

How to test

Explanation troubleshooting basics and expectations.

  1. Check the running status of mysqld and httpd:
  2. ]# service mysqld status; service httpd status;
    mysqld (pid  1768) is running...
    httpd (pid  1888) is running...
    
  3. Check the virtualhosts config in httpd:
  4. ]# httpd -S
    VirtualHost configuration:
    wildcard NameVirtualHosts and _default_ servers:
    *:80                   is a NameVirtualHost
             default server wpdev (/etc/httpd/conf/httpd.conf:1004)
             port 80 namevhost wpdev (/etc/httpd/conf/httpd.conf:1004)
             port 80 namevhost wordpress (/etc/httpd/conf/httpd.conf:1015)
             port 80 namevhost wordpress2 (/etc/httpd/conf/httpd.conf:1026)
    
  5. Check the /etc/hosts file:
  6. ]# cat /etc/hosts
    127.0.0.1       yourhostname localhost.localdomain   localhost
    ::1             yourhostname localhost6.localdomain6 localhost6
    127.0.0.1       wpdev
    127.0.0.1       wordpress1
    127.0.0.1       wordpress2
    

Common problems and fixes

Describe common problems here, include links to known common problems if on another site

More Information

Any additional information or notes.

Disclaimer

We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #wordpress or #centoshelp on irc.freenode.net

Added Reading

© 2012 CentosHelp.org