Mar 18

The most popular use of linux servers: LAMP! It stands for Linux Apache MySQL PHP and is a very stable and well known configuration of a web server. Let’s install it then!

Install required packages:

aptitude install mysql-server mysql-client apache2 php5 php5-cli php5-curl php5-gd php5-imap php5-mcrypt php5-mhash php5-mysql libmysqlclient-dev phpmyadmin libapache2-mod-auth-mysql

The annoying PHP configuration bug in ubuntu. Edit /etc/apache2/mods-available/php5.conf and ensure that it has exactly the following contents:

<IfModule mod_php5.c>
  AddType application/x-httpd-php .php
  AddType application/x-httpd-php-source .phps
</IfModule>

I normally enable all modules that I will use in this tutorial. You might want to do the same:

a2enmod alias
a2enmod auth_basic
a2enmod auth_mysql
a2enmod authn_file
a2enmod authz_default
a2enmod authz_groupfile
a2enmod authz_host
a2enmod authz_user
a2enmod autoindex
a2enmod cgi
a2enmod dir
a2enmod env
a2enmod mime
a2enmod negotiation
a2enmod php5
a2enmod proxy
a2enmod proxy_http
a2enmod rewrite
a2enmod setenvif
a2enmod status
a2enmod suexec

Now edit /etc/apache2/sites-available/default and replace the contents with this (it will configure our default site that we will use later for monitoring and dspam websites):

NameVirtualHost *:80
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName example.com
        ServerAlias www.example.com
        DocumentRoot /var/www/example.com
        ErrorLog /var/log/apache2/example.com-error.log
        LogLevel warn
        # can change to debug, info, notice, warn, error, crit, alert, emerg
        CustomLog /var/log/apache2/example.com-access.log combined
</VirtualHost>

And let’s create the web root and open the firewall:

mkdir /var/www/example.com
iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 443 -j ACCEPT
iptables-save > /etc/iptables-rules

One Response to “Configure LAMP (linux-apache-mysql-php)”

  1. [...] Install LAMP – linux apache mysql php Tagged as: apache, apache2, bind dns, bind9, clamav, courier, dspam, linux, maildrop, monit, monitoring, munin, MySQL, perfect, php, postfix, proftpd, sasl, server, setup, squirrelmail, tls, ubuntu, virtual Leave a comment Comments (0) Trackbacks (0) ( subscribe to comments on this post ) [...]

Leave a Reply

*
preload preload preload