“I always say, 'This will be my last 'Metal Gear.'” Hideo Kojima

LAMP server with Postgresql on Archlinux

Hi again!

In this post I’m going to show how to configure a LAMP webserver with Postgresql support on an Archlinux system. It has no secret, but it may be a bit confusing if you are a PHP newbie (as myself :P)

Why should I need this

Well, if you use Heroku anytime soon you’ll find this is a great way to test your code :)

So, follow Archlinux’s wiki to install a LAMP server as normal. Install apache, php, mariadb, php-apache and so. Configure httpd.conf as stated in the wiki. Then make a test.php page at /srv/http and test it going to http://localhost/test.php.

I have a blank page! I did it!

Not really. A blank page means php is not working. I solved this installing and configuring php-fpm following the wiki again. After restarting apache, my web started parsing php as expected; and test.php was showing PHP info.

Nice, I can see PHP info now!

Wonderful! Now, if you are testing a Heroku app you may find yourself trying to connect to a Postgresql database (no sqlite on heroku :/). And at this moment you may find yourself, as I did, with an error like “could not find driver”.

What to do? Well, you have to uncomment some lines in /etc/php/php.ini depending if you are using PDO or not:

extension pdo_pgsql.so
extension pgsql.so

If you still get a “could not find driver” its because Archlinux packages are modular! You just need to install php-pgsql:

sudo pacman -S php-pgsql

And that’s it! :) Feel free to ask anything or comment whatever.

Happy coding!

Jordi

Links: