User Tools

Site Tools

LAMP

LAMP is an acronym for Linux, Apache, MySQL, PHP. A commonly used setup for running a web servers and also one of the preferred setups (next to MAMP) for running a thirty bees shop.

Debian/Ubuntu

Here we have the APT packaging system, which makes things easy.

Apache Setup

Just run this:

sudo apt-get install --no-install-recommends apache2

That's it already. Now one can access the server on http://localhost/ by HTTP. Web files are in /var/www/html.

Enabling HTTPS is almost as easy, the Debian folks do a great job on getting things working out of the box:

sudo a2enmod ssl
sudo a2ensite default-ssl
sudo service apache2 restart

Last not least, one likely wants the rewrite engine enabled. This gets Friendly URLs working:

sudo a2enmod rewrite
sudo service apache2 restart

Basic PHP Setup

If the task is to just set up a server for running thirty bees, this should be sufficient for a thirty bees installation:

sudo apt-get install --no-install-recommends libapache2-mod-php php-gd
sudo apt-get install --no-install-recommends php-bcmath php-xml
sudo apt-get install --no-install-recommends php-json php-zip
sudo apt-get install --no-install-recommends php-mysql php-mbstring

Multi-PHP Setup

Developers often want to test on more than one PHP version. Thanks to Ondřej Surýs great PPA, multiple versions can get installed easily in parallel:

sudo add-apt-repository ppa:ondrej/php
 
sudo apt-get install --no-install-recommends libapache2-mod-php5.6 php5.6-gd
sudo apt-get install --no-install-recommends php5.6-bcmath php5.6-xml
sudo apt-get install --no-install-recommends php5.6-json php5.6-zip
sudo apt-get install --no-install-recommends php5.6-mysql php5.6-mbstring
sudo apt-get install --no-install-recommends php5.6-mcrypt
 
sudo apt-get install --no-install-recommends libapache2-mod-php7.0 php7.0-gd
sudo apt-get install --no-install-recommends php7.0-bcmath php7.0-xml
sudo apt-get install --no-install-recommends php7.0-json php7.0-zip
sudo apt-get install --no-install-recommends php7.0-mysql php7.0-mbstring
sudo apt-get install --no-install-recommends php7.0-mcrypt
 
sudo apt-get install --no-install-recommends libapache2-mod-php7.1 php7.1-gd
sudo apt-get install --no-install-recommends php7.1-bcmath php7.1-xml
sudo apt-get install --no-install-recommends php7.1-json php7.1-zip
sudo apt-get install --no-install-recommends php7.1-mysql php7.1-mbstring
sudo apt-get install --no-install-recommends php7.1-mcrypt
 
sudo apt-get install --no-install-recommends libapache2-mod-php7.2 php7.2-gd
sudo apt-get install --no-install-recommends php7.2-bcmath php7.2-xml
sudo apt-get install --no-install-recommends php7.2-json php7.2-zip
sudo apt-get install --no-install-recommends php7.2-mysql php7.2-mbstring
# Extension mcrypt no longer exists in PHP 7.2.
 
sudo apt-get install --no-install-recommends libapache2-mod-php7.3 php7.3-gd
sudo apt-get install --no-install-recommends php7.3-bcmath php7.3-xml
sudo apt-get install --no-install-recommends php7.3-json php7.3-zip
sudo apt-get install --no-install-recommends php7.3-mysql php7.3-mbstring
# Extension mcrypt no longer exists in PHP 7.3.

These are all available versions as of Ubuntu 18.10.

Switching PHP Version for the Web Server

One can switch the PHP version used by Apache (which is not necessarily the same version as PHP command line):

sudo a2dismod php*
sudo a2enmod php7.2  # Adjust for the wanted version.
sudo service apache2 restart
Switching Command Line PHP Version

One can switch the PHP version used on the command line as well:

sudo update-alternatives --config php

This lists all available versions and allows to pick the wanted one.

setting_up_lamp.txt · Last modified: 2019/03/12 12:58 by Traumflug