TNick.github.io

home

LAMP on Ubuntu

24 May 2014

Install

LAMP stands for Linux, Apache, MySQL, PHP. Here are the steps to install and configure it on Ubuntu:

sudo apt-get install -y apache2 mysql-server libapache2-mod-auth-mysql php5-mysql

Fast alternative:

sudo apt-get install -y tasksel
sudo tasksel install lamp-server

MySql will ask for a password that should be different from others that you use (root password for the system or user pasword).

Next, run:

sudo mysql_install_db

You can start the MySQL daemon with:

cd /usr ; sudo /usr/bin/mysqld_safe &

do this now, before proceeding to next step. Now run following interactive script, while answering Y to most of the questions:

sudo mysql_secure_installation

You can test the MySQL daemon with mysql-test-run.pl

cd /usr/mysql-test ; perl mysql-test-run.pl

Installing PHP:

sudo apt-get install -y php5 libapache2-mod-php5 php5-mcrypt phpmyadmin

Add a new line ServerName localhost to /etc/apache2/apache2.conf

sudo nano /etc/apache2/apache2.conf

Run

To display files in your home directory or other places, create a symlink

sudo ln -s /home/tnick/site /var/www/html

DO NOT DO THIS: To create a new virtual site, copy existing config file:

sudo cp  /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-enabled/test1.conf

and edit it:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /home/tnick/test1/site
        LogLevel debug
        ErrorLog /home/tnick/test1/logs/error.log
        CustomLog /home/tnick/test1/logs/access.log combined
        <Directory /home/tnick/test1/site/>
        </Directory>
    </VirtualHost>

Now enable the new one and disable the old one:

sudo a2dissite 000-default && sudo a2ensite test1

And restart apache:

sudo service apache2 restart

Other

If you need index.php file to be prefered edit dir.conf and move it inside IfModule mod_dir.c block:

sudo nano /etc/apache2/mods-enabled/dir.conf

Listing available PHP modules and installing:

apt-cache search php5-
apt-cache show $package_name
sudo apt-get install $package_name
sudo apt-get install php5-mcrypt  php5-xdebug php5-cgi php5-cli php5-json php5-sqlite php5-tidy php5-intl php5-xcache php5-xhprof

Resources

A simple solution for virtual machines in Ubuntu is LXC with virtenv.

Things that need to be installed:

sudo apt-get install -y lxc lxctl uuid btrfs-tools xserver-xephyr bridge-utils openbox

Latest package for virtenv should be downloaded from here.

and installed using:

sudo dpkg -i virtrenv_X.Y.Z_1.deb

virtenv creates a folder .virtenv inside home directory where it creates folders for each virtuasl machine. If you keep your virtual machines elsewhere you can create a symbolic link like so:

ln -s $MACHINES/.virtenv /home/tnick/.virtenv

Tagged with walkthrough

"Any sufficiently advanced troll is indistinguishable from a genuine kook." Alan Morgan