2011-05-15

We start by installing dotdeb APT repository to get
easy access to the latest .deb packages for some of our components like
NginX, PHP stack etc.

Now before we proceed any further, let's make sure we have improved vi,
because we will be editing whole bunch of files and default Debian
installation only comes with classic vi, which does not understand arrow
keys in editor mode (and that personally bugs me a lot):

Install Nginx and PHP 5.3 with PHP-FPM

Let's also install xdebug via pecl (we could install Xdebug through apt,
too, but it misconfigures xdebug after install and it's a good thing to
have properly configured PECL on LAMP stack, anyway):

CAUTION: If you run into problems with installing php5-dev (e.g. an
error complaining about libtools version, which is expected if you run
these instructions on Debian newer than Lenny, e.g. Squeeze) you may
need to download appropriate .deb packages manually from:
http://mirrors.kernel.org/ubuntu/pool/main/p/php5/
and install with: "dpkg -i packagename.deb". Please make sure to pick
the correct .deb file for your CPU architecture and the version that you
need.

Please note an output at the end of the xdebug installation which looks
something like:

You need the path after "installing" because we will have to create
xdebug configuration file with that path. You php configuration files
should be in "/etc/php5/conf.d/". If that is true, please create
/etc/php5/conf.d/xdebug.ini (or create xdebug.ini under wherever your
php configuration files directory is) and insert following line there:

noting that the path provided to zend_extension instruction is the same
one we got from the xdebug pecl installation output.

Configure Nginx

Following instructions assume that you are configuring a domain:
debian.vm

create /var/www/debian.vm/html and make it readable by Nginx user (which
is probably: "www-data")\
create /var/www/debian.vm/logs and make it writable by Nginx user
(which is probably: "www-data")

Edit: /etc/nginx/sites-available/debian.vm.conf as root and enter
following configuration:

Note: if you are setting up virtualhost for Drupal, your
configuration needs to be more involved and may look something like the
following:
https://gist.github.com/1593835

Now let's link this configuration from sites-enabled foder to enable it:

Check the resulting Nginx configuration with:

Test Page

After which if the domain you configured is indeed debian.vm and it i
pointing to your server (even via hosts file record), when visiting
http://debian.vm/ via your browser you should see the PHP Info page
generated by phpinfo() in your index.php. Please note that our nginx
configuration will also cache static content for 15 days, improving
performance.

Bonus: MySQL

Note: this assumes you have already set up dotdeb repositories properly
(beginning of this post).

If you need to install MySQL for PHP, as well:

Bonus: Changing hostname

If you want to permanently change the hostname of your server (so that
it survives reboot) you need to follow following steps:

Let's assume you are changing your server hostname to ika.ge

Edit /etc/hosts as a root and next to "localhost" add "ika.ge" so
corresponding line reads something like:\

Edit "/etc/hostname" and replace existing line there with "ika.ge"

run:\

Show more