To Find Out Version of LAMP (Linux, Apache, MySQL, PHP) Via the Command Line

I am running a LAMP server on Slicehost. I always have to look up how to determine the version of each component of the LAMP server I am running. I am using Ubuntu Linux 8.04.4 (Hardy). In my case, here are the command-line instructions I use. I hope this helps you too. Btw, the command "whereis" is very helpful in locating programs (i.e. whereis apache2). Linux

> more /etc/issue


> lsb_release -a

Apache 2

> /usr/sbin/apache2 -V

Note: Apache 2 doesn't have "httpd" anymore. It was changed to "apache2" instead.


First log into your MySQL database from the command line, using something to the effect of:

> mysql -u username -p


mysql> select version();


> php -v


> php5 -v

Note: This assumes you have PHP 5 installed and that you have installed the Command Line Interface (CLI) to PHP via "sudo aptitude install php5-cli". Alternatively, you can find out the version of PHP via instruction "< ? phpinfo() ?>" within a .php file.

Installing LAMP and Wordpress on Slicehost (or elsewhere) Redux

[Disclaimer: I am not responsible for any mishaps that may occur by following these steps or advice because you follow them out of your own free will.] — I figure I better put that up-front, again.

My original post on installing a LAMP (Linux, Apache, MySQL and PHP) server with Wordpress seems to have helped at least a few people.

I have since come up with a few more random, but I think helpful, tidbits since writing that post. I will list them here.

Basic Commands

'ls -alR' for a recursive look at all owners and groups, etc.

Transferring your Blog to

If you are importing your blog from somewhere else and the upload doesn't seem to be working (e.g., when you click the "Import" button you see no screen changes and/or you the browser is just "spinning"):

  • create uploads directory in wp-content
  • you may have to set wp-content to chmod 777 permissions for import
    - first try 755 on uploads. If it doesn't work, then
    - then try 777 on uploads. If it doesn't work, then
    - then try 777 on wp-content
  • revert everything back to 755, or what you had it before

If you are moving from to and you need your blogroll, you need to export this separately (it is not included as part of the normal export from You go to and save the XML you see and then import via the blogroll/import capability (or you can just enter the link to the opml I mentioned before right in the blogroll import). Note the export only seems to work in Firefox and IE. Safari gave me a blank page.


If you want SSL for Apache - sudo a2enmod SSL (see article)

If you want SSL for your Wordpress administration areas, enable SSL for wp-admin (See documentation)

For SSL resolution -- if you are only using SSL on one site and you have other sites, see this forum post.

Final Setup Steps for Wordpress

Make sure www-data has write access to the following --- Do a 'chmod -R g+w' on wp-content/themes,wp-content/uploads

For final permissions:

  • find public -type d | xargs chmod 0755
  • find public -type f | xargs chmod 0644 (files)
  • find public -type d | xargs chown username:www-data
  • find public -type f | xargs chown username:www-data

If testing your somewhere besides the live domain, make sure to remember this article before going live.

If you find images to be funky after going live -- like still pointing to your old domain or testbed site, you can manually do a search and replace in the database or use a plug in from here.

If file types should be working that aren't working (xsl, html), maybe add to the sites-available vhost the allowed file types for the certain directory in question. For example, I added xsl because of Google Sitemaps and wanting to view my sitemaps in the browser.

Google Analytics

Google Analytics code goes above the tag in the footer file of your Wordpress theme (see article)

WP Super Cache

If you are looking for a plugin that might speed up your blog by serving static, cached HTML instead of processing PHP constantly, then look to WP Super Cache. If you set up your LAMP server with Worpdress like I explained in my original post, then instead of using .htaccess, you will be putting any rules in the vhost -- especially in steps 7 and 8 in the installation instructions.


Maybe replace exim with an external smtp server.

'sudo /usr/sbin/exim4' to get access to exim commands (like seeing message queue -- exim4 -bp)

If exim4 is not working for Google Apps for some reason, check this out.

Installing a LAMP Server, with Wordpress, on Slicehost (and maybe elsewhere)

[UPDATE: April 19, 2009: I added a follow-up post to this article with some more tidbits]

[Disclaimer: I am not responsible for any mishaps that may occur by following these steps or advice because you follow them out of your own free will.] -- I figure I better put that up-front. :-)

Someone wrote me an email today asking me how to get a LAMP server up and running on a Slicehost VPS ( Slicehost land, your VPS is called a "slice").

During the time when I was setting up my slice, I made a little personal document on how to set up a LAMP server with Wordpress (I used Ubuntu Hardy as my base Linux installation).

While this is by no means anything official or 100% complete, I figure when I need to set up a LAMP server again, it will serve as a great starting point for me.

Like I insinuated in my disclaimer, I cannot guarantee the accuracy  or the 100% "foolproof"-ness of these steps. I am by no means an expert at this stuff, but, hey, they worked for me.

Below are the contents of that document in its raw form. Feel free to ask any questions, although I cannot guarantee I will know the answer. Feel free to correct any mistakes in comments, although I cannot guarantee I will fix them.

Ubuntu Linux (Server): Setup @ Slicehost

Basic Commands and Instructions

  • sudo aptitude install <package1> [package2]
  • sudo aptitude purge|remove <package>
  • whereis <program> (to find out where something is located)
  • root shell: sudo –s (get out of the root shell by ctrl+d)
  • ps aux (to find out processes running) (ps aux | grep <process name> to narrow --- e.g., ps aux | grep httpd)
  • apache2ctl configtest (to make sure your Apache configurations are ok)
  • Apache logs are at /var/log/apache2 (Must be in a sudo shell -- see above)
  • sites-enabled is a symlink; make vhost changes to sites in /etc/apache2/sites-available
  • Don’t worry about .htaccess and httpd.conf files. Use vhost config files instead.


  1. Get bare bones install
  2. Log on as root via ssh ( ssh root @ <ip address> )
  3. Use provided password and immediately change it via passwd.
  4. Change time zone
    • sudo ln –sf /usr/share/zoneinfo/US/Pacific /etc/localtime (replace US/Pacific with what your timezone is)
  5. Follow these instructions for security
  6. Backup the private (and public if you want, but especially private) key from your local machine! (preferably in a couple different places)
  7. Continue with these security instructions (add \u@\ before \h\ to add user name in front of hostname in PS1)
  8. A good package to install would be unzip for downloads (only tar is available at this point): sudo aptitude install unzip ( )

Setup Domain via DNS Manager

  1. Log into the slice manager:
  2. To configure the DNS records for your domain, go here:
    • Make sure you have set the nameservers properly on your registrar (e.g.

Setup Domain Email via DNS Manager

  1. I use Google Apps for email. The next steps are specific to that. If you don’t use Google Apps, just make sure you set the MX records properly in the Slicehost DNS manager, otherwise you may be without email if you have completed the “Setup Domain via DNS Manager” step.
  2. If you haven’t done so already, set up Google Apps for your domain (
    • For verification, you can use the HTML method since you can control your website
  3. Set up the MX records like described here:


  1. Start here: (making sure you use your own server name and user names)
  2. Read to understand enabling/disabling sites and modules
  3. Follow these instructions:, and at least change the Timeout and KeepAliveTimeout to something much lower.
  4. Follow these instructions:
  5. Read these articles about virtual hosts before setting things up:,
  6. Read this article to understand how you are going to layout your directory structure for the domains you are going to host:
  7. Secure virtual host permissions and create skeleton virtual host directory:
    • For all new domains, just follow the following command:
      • cp –a /home/<user>/public_html/skeleton /home/<user>/public_html/<new domain>
  8. Create your first virtual host: (remember to change, to your own domains in the examples AND 'demo' to your username) (note: search and replace in nano is “ctrl-\”)
    • Remember that if they navigate to the IP Address, they will most likely get the “It Works!” message for the default Apache site. You can change this.
    • Change DirectoryIndex to “index.php index.html” if you are going to be using WordPress
  9. Change and add settings in your domain virtual hosts file:
    • Make sure you set some directory options – one I would for sure do is turn off directory browsing


  1. Follow the instructions here: Only do the MySQL part and make sure you do not put the Ruby option in the install string (unless you want Ruby of course)
  2. Follow post setup instructions here: to secure your initial mySQL accounts
  3. After I am done, I like to clear the mySQL console history. Exit mySQL and at the command prompt do 'rm ~/.mysql_history'
  4. Setup DNSUtils (for dig especially): sudo aptitude install dnsutils 

Set Up Sending Mail From Slice

  1. You need to change “exim” settings on server to send email from Wordpress
  2. For Google Apps, see this thread: Follow the instructions all the way down to Run # chown. I didn’t have to do this.
    • Also, accept all defaults for questions after the DNS-queries minimal question. There are more than the thread instructions let on.
  3. See this thread for more general info: (don’t need sendmail after all, exim is already installed so try that first, see page 2 of thread for meat)
  4. Now for multiple email addresses (when you have more than one blog, for example, each representing a different domain), you will need to follow some different steps. This might be a good place to start:


  1. Load mod_rewrite for Apache
    • Sudo a2enmod rewrite
    • Sudo /etc/init.d/apache2 reload
  2. Follow instructions here: (especially Detailed instructions)
    • DB Name: wordpress (or whatever)
    • DB UserName for wordpress: wordpress (or whatever)
    • Append table names if (1) you want more security (2) going to have more than one Wordpress blog using the same database
  3. Probably don’t want to put on google and technorati until you are done with the blog design
  4. Make sure to change admin password after first log in
  5. Change the “admin” user in MySQL to something else:
    • Mysql> use wordpress;
    • Mysql> UPDATE <wpTableName>users SET user_login=’admin’, user_login=’<new admin name>’;
  6. NOTE: Many instructions say to add things to “.htaccess” or “httpd.conf”. Since you have root access, don’t worry about these files. Make your configuration changes to the vhost file (or maybe, sometimes, the master apache2.conf file).
  7. Add Rewrite Log to vhost file
  8. Turn off directory in “public” browsing in the vhost
    • <Directory /home/<user>/public_html/<domain>/public>
      • Options –Indexes
    • </Directory>
  9. Put wp-config.php database and key info into another file and put that new file in /home/<user> (outside the public_html). Then put an include to hat file in wp-config.php. This is for security ( )
  10. Log into the Wordpress admin panel (http://<domain>/wp-admin/) and go to Settings/Permalinks. Set the permalinks to something like “Day and name” and click on Save Changes
    • Then, assuming you don’t have an .htaccess file, go to the bottom of the page and copy the code in the text area and paste in your vhost file (within the <Directory></Directory> for the top level directory (usually /home/<user>/public_html/<domain>/public)
  11. Do some security around the wp-content, wp-includes and wp-admin directories.
    • Only allow access to images and javascript to wp-includes and wp-content
      • <Directory /home/<user>/public_html/<domain>/public/wp-includes>
        • Options –Indexes
        • AllowOverride None
        • Order Allow, Deny
        • Deny from all
        • <Files ~ “.(css|jpg|jpeg|png|gif|js)$”>
          • Allow from all
        • </Files>
      • </Directory>
      • ….and do the same for wp-content
    • Either restrict access to wp-admin by adding a password layer or by IP address
    • You might also want to do the same as you did for wp-asmin for wp-login.php at the file level since going to http://<domain>/wp-admin redirects there (see:
      • <Files /home/<user>/public_html/<domain>/public/wp-login.php>
        • …..
      • </Files>
  12. Install login plug-in @ Copy the download link and use ‘wget’ to get it from the command line (instead of FTP)
  13. Activate the akismet plugin in the admin panel.
    • You need a account so you can get an API key. This key is found in Settings/Your Profile
  14. Install WP-Super-Cache plug-in



This is a MySQL front-end that is more user friendly than the default mySQL client

  1. sudo aptitude install phpMyAdmin
    • IMPORTANT: Make sure you press the space bar when selecting the web server you are using
  2. Go to /etc/apache2/conf.d/ and edit phpmyadmin.conf
    • Change Alias from phpMyAdmin to something more obscure for security purposes
  3. Change the /etc/phpmyadmin/ file to support https:
  4. Then go to