Thursday, March 1, 2012

How to build LAPP (Linux + Apache + Postgres + PHP) easy

This LAPP is to be built based on Ubuntu (or Debian or any derivative of the Ubuntu)

Install Postgresql

sudo apt-get install postgresql-8.1 php5-pgsql

Install Apache

  • The following mod-security, ldap, and odbc libraries are optional:
sudo apt-get install apache2 libapache2-mod-php5 php5-gd
sudo apt-get install libapache2-mod-security php5-ldap php5-odbc
  • Restart Apache
sudo /etc/init.d/apache2 restart




============== below are optional or if you know what to do please skip ============== 


Install other software (optional)

sudo apt-get install openssh-server unattended-upgrades
sudo apt-get install unzip zip aspell-en aspell-fr aspell-de aspell-es
sudo apt-get install curl php5-curl php5-xmlrpc
sudo apt-get install clamav-base clamav-freshclam clamav

Configure Postgres (if you know what to do please skip)

  • Create the database user 'webuser'.
sudo -u postgres createuser -D -A -P webuser
Enter in a NewDatabasePassword here, then answer 'N' to the question.
  • Create the database 'webdb' for the user 'webuser'. Enter the password that you just created.
sudo -u postgres createdb -E utf8 -O webuser webdb
  • Secure the postgresql database with an admin password.
sudo -u postgres psql template1
# ALTER USER postgres WITH PASSWORD 'NewAdminDatabasePassword';
# \q
  • Edit the file '/etc/postgresql/8.1/main/pg_hba.conf' and on line 79 change the words ident sameuser to md5.
sudo nano /etc/postgresql/8.1/main/pg_hba.conf
  • Restart the database:
sudo /etc/init.d/postgresql-8.1 restart

1 Comments:

Anonymous said...

I spent the last two hours googling and reading to be certain of the exact right way to do this on Ubuntu (unfortunate there's no tasksel for LAPP the way there is for LAMP). This was a very good and helpful post! Thank you!

If I were to suggest anything, you might want to clarify that you only need to edit the pg_hba.conf file to md5 if you're wanting to log into the database remotely.

For many people, leaving it in the default configuration (restricted to local access only--which includes any service running on the same machine, e.g. phppgadmin) is good enough.