Set up LAMP Environment and WordPress

What Are We Doing?

It’s best to start with a fresh Linux install. For this guide I am using RHEL (RedHat Enterprise Linux) as my distro and YUM (short for, Yellowdog Updater, Modified) as my package manager. YMMV depending on the distro you use, but it should be fairly similar. After we install the packages from the RPM (RPM Package Manager) we will install phpMyAdmin and WordPress. Lastly we’ll do some Apache Tuning (which will be detailed in a separate article).

YUM Package Installation

From the Linux command prompt, sudo to root and issue the following installation commands:

yum install httpd
yum install php
yum install mysql
yum install mysql-server
yum install php-mysql
yum install mysql-devel

The reason I did not combine them into one command (i.e. yum install httpd, php, mysql…) is, for a novice, you can spot errors easier in installations this way. If you wish to save time feel free to do so. You should add a directory to your machine and make a quick update to httpd.conf, especially if you plan on serving multiple sites, make sure you sudo to root before doing the following:

  • Navigate to /var/www/ and issue “mkdir sites”
  • Navigate to /var/www/sites/ and issue “mkdir myapp” (fill out whatever you want, I will use myapp for this article.
  • Edit httpd configuration file with nano by issuing “nano /etc/httpd/conf/httpd.conf” (feel free to use vi)
  • In httpd.conf update any references to DocumentRoot to our new DocumentRoot (DocumentRoot “/var/www/sites/myapp”)
Once you have updated httpd.conf let’s restart httpd by issuing “service httpd restart” at the command prompt.

We still need to install phpMyAdmin and WordPress, which is explained below.

Set up MySQL

Run the following command (assuming mysql installed to /usr/bin which it should have):


Follow the instructions to a tee. Some advice, though if you have an operations team to consult with, run these through them for optimal setup:

  • set root password to something very secure and make sure to write it down and only share with those who need it
  • do not allow “anonymous user”
  • disallow root login remotely (especially if production!!)
  • remove test database (especially if production!!)
  • reload the privileges table


Install phpMyAdmin

  • Go to and get the URL for the latest phpMyAdmin tarball. At the time of this writing the URL is
  • Navigate to myapp (/var/www/sites/myapp) and issue “wget URL_TO_TARBALL”
  • Issue “tar -zxvf phpMyAdmin_TAR_FILE”
  • For sanity sake rename the newly created “phpMyAdmin_TAR_FILE/” directory to phpmyadmin by issuing: “mv phpMyAdmin_TAR_FILE/ phpmyadmin”
  • Delete the tar file.

Configure phpMyAdmin

Let’s create a config file for phpMyAdmin.

  • Navigate to /phpmyadmin directory and issue:
    • mkdir config
    • chmod o+rw config
  • Navigate in a web browser to http://IPADDRESS/phpmyadmin/setup and follow all of the steps (make sure to set a blowfish password, located under Features/Security)
  • Make sure to click “Save” or config file will not be generated.
  • Once completed issue the following commands from the phpmyadmin directory:
    • mv config/ .   (Note the “.”)
    • chmod o-rw
    • rm -rf config

Create PMA User to Admin PMA (phpMyAdmin)

  • issue “mysql -u root -p < /path/to/phpmyadmin/examples/create_tables.sql” (e.g. “mysql -u root -p < /var/www/html/phpmyadmin/examples/create_tables.sql”
  • enter the password for root
  • this will create a user pma user
  • navigate back to the phpmyadmin path and issue the following command “mysql -u root -p”
    • Enter in root’s password
    • This will log you into mysql as root at the “mysql>” prompt paste the following (replace PMAPASSWORD with something secure):
      GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'PMAPASSWORD';
      Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
      Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
      File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
      Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
      Execute_priv, Repl_slave_priv, Repl_client_priv
      ) ON mysql.user TO 'pma'@'localhost';
      GRANT SELECT ON mysql.db TO 'pma'@'localhost';
      GRANT SELECT ON TO 'pma'@'localhost';
      GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
      ON mysql.tables_priv TO 'pma'@'localhost';
  • navigate back to the phpmyadmin directory (you might already be there)
  • issue “ls config*.php”
  • if “” does not exist but “” does issue the following command “cp”
  • issue the following commands:
  • “chmod 777”
  • “nano”
  • in the editor make sure to uncomment out all lines similar to:
    // $cfg['Servers'][$i]['controluser'] = 'pma';
    // $cfg['Servers'][$i]['controlpass'] = 'pmapass';
    // $cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
    // $cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
    // $cfg['Servers'][$i]['relation'] = 'pma_relation';
    // $cfg['Servers'][$i]['table_info'] = 'pma_table_info';
    // $cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
    // $cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
    // $cfg['Servers'][$i]['column_info'] = 'pma_column_info';
    // $cfg['Servers'][$i]['history'] = 'pma_history';
    // $cfg['Servers'][$i]['tracking'] = 'pma_tracking';
    // $cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
    // $cfg['Servers'][$i]['userconfig'] = 'pma_userconfig';
    // $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';
  • save and exit
  • issue “chmod 555”
  • IMPORTANT – go to your web browser and clear your browser’s cache
  • Navigate to the phpMyAdmin URL
  • Log in with root and root’s password
  • You should not see any errors on the bottom of phpmyadmin’s home screen

Create a Database for WordPress

  • Log into phpMyAdmin
  • Click “Privileges” and then on the Privileges screen click “Add a New User”
  • Fill out all of the information, this will be the WordPress database. Set a username such as “myapp”, have phpMyAdmin generate a password, set “localhost” as the host. Make sure to note the database name/username and password. (Database name and username should be the same thing)
  • Select “Create database with the same name and grant all privileges.”
  • Click “Create User”


  • Navigate to your web application’s directory (e.g. /var/www/sites/myapp)
  • Issue “wget” (verbatim)
  • Issue “tar -xzvf latest.tar.gz”
  • Issue “mv wordpress/ .”
  • Fire up your web browser and navigate to http://YOUR_IP/
  • Fill out the information including the database, username and password created in the last section
  • All done :) Pat yourself on the back!

Some Notes:

  • Remove phpMyAdmin on production sites for security sake
  • Use secure passwords!
  • Note the passwords somewhere safe, in case you forget them
  • Leave me a comment if you have any questions! Thanks!

Leave a Reply