====== Install Apache web server, PHP5, and MySQL ======
===== Install and Configure Apache2 =====
# apt-get update
# apt-get install apache2 apache2-utils
Add the server's domain name at the end of /etc/apache2/apache2.conf
=== Note that sites-enabled now expects files with the extension .conf to load ===
Restart the server with either of the following commands:
# service apache2 restart
# /etc/init.d/apache2 restart
===== Install and Configure PHP5 =====
To install PHP5 package and all related package dependencies run the following command below. by default ubuntu server 16.04 LTS will install PHP 7.0.
==== Remove all the stock php packages ====
List installed php packages with the first command, then remove unneeded packages with sudo aptitude purge your_packages_here or if you want to directly remove them all use the second command:
dpkg -l | grep php| awk '{print $2}' |tr "\n" " "
sudo apt-get purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
==== Add the PPA ====
sudo add-apt-repository ppa:ondrej/php
If you get add-apt-repository: command not found run the following command first :
sudo apt-get install software-properties-common
==== Install your PHP Version ====
sudo apt-get update
sudo apt-get install php5.6
sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-gd php5.6-curl
==== Verify your version ====
sudo apt-get install php5.6-cli
sudo php -v
===== Install and Configure PHP7 =====
# apt-get install php libapache2-mod-php php-mcrypt php-mysql php-pear php-gd php-curl
===== Install and Configure MySQL Server =====
To install Mysql Server package and all related package dependencies run the followong command:
# apt-get install mysql-server
# apt-get install phpmyadmin
During the installation, you’ll be asked to setup the MySQL root user password. This is an administrative account in MySQL that has increased privileges, Enter the password and select [OK].
==== Configuration for phpmyadmin ====
Enter the following to your virtual host configuration to restrict access to phpmyadmin to a specific ip address or a browser signature:
# Allow access without password
BrowserMatch "Mozilla" webmaster
Require env webmaster
Require ip 8.8.8.8
==== Restore existing databases ====
- Find the MySQL config file:
# find / -name my.cnf
- Find datadir = /var/lib/mysql in the file, which points to where databases are stored on the server.
- Copy the folder with the existing database files into the datadir path
- Stop mysql server, set file permissions, and restart the server
# /etc/init.d/mysql stop
# chown -R mysql:mysql /var/lib/mysql/
# /etc/init.d/mysql start
- If you restore existing joomla databases over restoring the joomla code, restore the code first including db, stop the mysql server, replace the db, and restart the mysql server
See [[http://ubuntuserverguide.com/2014/06/how-to-install-lamp-in-ubuntu-server-14-04-lts.html|How to Install LAMP in Ubuntu Server 14.04 LTS]]
===== Links =====
* [[https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-16-04|How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 16.04]]
* [[https://askubuntu.com/questions/756181/installing-php-5-6-on-xenial-16-04|Installing PHP 5.6 on Xenial (16.04)]]