Notes

Install a LAMP stack

Edit on GitHub

System Administration
2 minutes
  • This is for a debian/ubuntu environment
  • We’re going to install PHP at the end since it’s the longest step and has more explanations

Setup details

  • PHP version 7 or greater
  • MySQL version 5.6 or greater
  • HTTPS support

Getting ready

1sudo apt update && sudo apt upgrade -y

Apache

1sudo apt install apache2 apache2-utils ssl-cert -y

MySQL

1sudo apt install mysql-server mysql-client -y

Secure the installation

1mysql_secure_installation

PHP

add repo

add repo to get the latest version of PHP

1sudo add-apt-repository ppa:ondrej/php
2sudo apt update

if you get

1sudo: add-apt-repository: command not found

then install the software-properties-common package. Depending on your Ubuntu version (Precise Pangolin, 12.04 LTS), you may also have to install the python-software-properties package:

1sudo apt-get install software-properties-common -y

Now update the sources list so it gets packages from the repo we just added

sudo apt update

install PHP and packages

at the time of this writing, the latest PHP version is 7.2

1sudo apt install php7.2 libapache2-mod-php7.2 php7.2-cli php7.2-common php-curl php7.2-curl php7.2-dev php7.2-gd php7.2-intl php7.2-mcrypt php7.2-mbstring php7.2-mysql php7.2-pspell php7.2-recode php7.2-xml php-imagick php-pear php-gettext php7.2-zip -y
  • Most of the packages are installed as dependencies for other packages. For example: installing php7.2 will also install libapache2-mod-php7.2, php-common, php7.2-cli, php7.2-common, php7.2-json, php7.2-opcache, php7.2-readline. But we’re going to manually specify them just in case.
PackagesSoftware that requires them
curlOpenCart, Magento
gdOpenCart, Magento, WordPress
gettextphpmyadmin
intlMagento
mbstringOpenCart, Magento
mcryptOpenCart, Magento
opensslMagento
xmlOpenCart
xslMagento
zipOpenCart, Magento
Magento extensions
1sudo apt-get update
2sudo apt-get install php7.0-gd php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-openssl php7.0-zip
3sudo service apache2 restart

Enable stuff

  • The mod_rewrite Apache module is required by WordPress and OpenCart. It is usually required by any software that uses pretty/SEO/custom URLs.
1a2enmod rewrite
1phpenmod -v 7.2 mcrypt

PHPMyAdmin

1sudo apt install phpmyadmin -y