How to setup LAMP stack on Ubuntu VPS

I’m no linux guru and I had to get a whole bunch of resources together to compile this list on how to set up LAMP (linux apache mysql and php).

You must run these as root:

  1. apt-get update
  2. apt-get upgrade
  3. apt-get dist-upgrade
  4. aptitude install build-essential
  5. apt-get install ubuntu-standard
  6. apt-get install lamp-server^
  7. apt-get install php5-cli
  8. apt-get install php5-curl
  9. (rest and/or go take a dump)
  10. apt-get install curl
  11. apt-get install wget
  12. apt-get install imagemagick
  13. apt-get install emacs
  14. apt-get install ufw (uncomplicated firewall)
  15. apt-get install sendmail (if you need php mail() function)
  16. apt-get install g++ libmysql++-dev (for sphinx)

Change apache’s memory usage setting ..

If you want imagemagick (latest), you need PECL to install (do not run apt-get install php5-imagick => outdated version)

  1. apt-get install php-pear
  2. apt-get install imagemagick libmagickwand-dev
  3. pecl install imagick
  4. Open your php.ini (/etc/php5/apache2/php.ini)  and add this line:
    extension=imagick.so

Then

12. a2enmod rewrite

13. a2enmod mod_headers (if you have wordpress blogs and want to have caching)

14. a2endmod mod_expires (same as #13)

15. a2endmod auth_basic (basic apache security)

16. a2endmod auth_digest

15. /etc/init.d/apache2 restart

16. /etc/init.d/mysql restart

17. chgrp -R www-data /path/to/your/www” (so PHP can read/write to ur directory)

18. chmod -R 775 /path/to/your/www (so PHP can read/write to ur directory)

Some things to change

  • Change maxclients on apache2.conf to something small… like 10 or 15
  • Change keepalive to off unless your site gets pounded (ex. high traffic site).. or time to live on keep alive connections to something small like 2
  • PHP.ini upload limit – if you have high image site (like PawshPal.com), change it to smoething more suitable like 10m

PS:If your VPS provider doesn’t give you access to their nameservers (cuz they’re doosh bags), you can always go with EveryDNS. Set it up there and point to EveryDNS dns servers on your registrar.

PPS: If your Ubuntu distro doesn’t respond to this command:

apt-get install libapache2-mod-security

You need to manually download from here then run “dpkg -i libapache-mod-security_2.5.12-1_i386.deb”.

===============

Update 9-11-2011

If you want to add sphinx search feature for your app, follow this direction instead of using apt-get:

  1. wget http://sphinxsearch.com/files/sphinx-2.0.1-beta.tar.gz (or whatever the latest  is)
  2. cd sphinx
  3. ./configure
  4. ./make
  5. ./make install

You need to build sphinx index for your mysql tables. Good tutorials here and here.

Once that’s done

1. build index (might want to add this to crontab)

/usr/local/bin/indexer pawshpal_content_index –config /usr/local/etc/sphinx.conf

2. test out the index w/command line interface search

/usr/local/bin/search –config /usr/local/etc/sphinx.conf “wtf”

3. start the search server (might want to run this command as service on startup)

/usr/local/bin/searchd –config /usr/local/etc/sphinx.conf

4) copy the sphinxapi.php from the tar.gz you downloaded and implement in PHP
Voila!
aptitude install build-essential

Related posts:

  1. MaxMind GeoIP.js blocked on your site? Make your own GeoIP locator service

Leave a Reply

Your email address will not be published. Required fields are marked *

*


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>