LAMP is an acronym for Linux (Ubuntu), Apache2, MySQL (MariaDB) and PHP… It’s a stack of open source applications typically installed together to create dynamic and powerful websites… WordPress, Drupal and few other content management systems use LAMP…
With PHP 7.1 now readily available and supported, you can now use the LAMP stack to improve your websites and blogs… For those who are new and want to learn how to install LAMP with Ubuntu 16.04 LTS server, the steps below should be a great starting point.
This brief tutorial is going to show students and new users how to install Ubuntu 16.04 LT with Apache2, MariaDB and PHP 7.1 support, or the LAMP Stack.
To get started with installing LAMP, follow the steps below:
Step 1: Install Apache2 HTTP Server
Apache2 HTTP Server is the most popular web server in use today and member of the LAMP stack.. So, go and install Apache2 on Ubuntu by running the commands below:
sudo apt install apache2
Next, run the commands below to stop, start and enable Apache2 service to always start up with the server boots.
sudo systemctl stop apache2.service sudo systemctl start apache2.service sudo systemctl enable apache2.service
After installing Apache2, open your browser and browse to the server name or IP address…
You should see Apache2 default test page.
Step 2: Install MariaDB Database Server
MariaDB database server is a great place to start when looking at open source database server… Although MySQL was originally the default database server, MariaDB has taken over.. To install it run the commands below.
sudo apt-get install mariadb-server mariadb-client
After installing, the commands below can be used to stop, start and enable MariaDB service to always start up when the server boots.
sudo systemctl stop mysql.service sudo systemctl start mysql.service sudo systemctl enable mysql.service
After that, run the commands below to secure MariaDB server by creating a root password and disallowing remote root access.
When prompted, answer the questions below by following the guide.
- Enter current password for root (enter for none): Just press the Enter
- Set root password? [Y/n]: Y
- New password: Enter password
- Re-enter new password: Repeat password
- Remove anonymous users? [Y/n]: Y
- Disallow root login remotely? [Y/n]: Y
- Remove test database and access to it? [Y/n]: Y
- Reload privilege tables now? [Y/n]: Y
Restart MariaDB server
sudo systemctl restart mysql.service
To test if MariaDB is installed, type the commands below to logon to MariaDB server
sudo mysql -u root -p
Then type the password you created above to sign on… if successful, you should see MariaDB welcome message
Step 3: Install PHP 7.1 and Related Modules
PHP 7.1 isn’t available on Ubuntu default repositories… in order to install it, you will have to get it from third-party repositories.
Run the commands below to add the below third party repository to upgrade to PHP 7.1
sudo apt-get install software-properties-common sudo add-apt-repository ppa:ondrej/php
Then update and upgrade to PHP 7.1
sudo apt update
Run the commands below to install PHP 7.1 and related modules.
sudo apt install php7.1 libapache2-mod-php7.1 php7.1-common php7.1-mbstring php7.1-xmlrpc php7.1-soap php7.1-gd php7.1-xml php7.1-intl php7.1-mysql php7.1-cli php7.1-mcrypt php7.1-zip php7.1-curl
After install PHP 7.1, run the commands below to open Apache2 PHP default file.
sudo nano /etc/php/7.1/apache2/php.ini
Then make the changes on the following lines below in the file and save. The value below are great settings to apply in your environments.
file_uploads = On allow_url_fopen = On memory_limit = 256M upload_max_filesize = 100M max_execution_time = 360 date.timezone = America/Chicago
After making the change above, save the file and close out.
To test, create a phpinfo.php file in Apache2 root directory by running the commands below
sudo nano /var/www/html/phpinfo.php
Then type the content below and save the file.
<?php phpinfo( ); ?>
Save the file.. then browse to your server hostname followed by phpinfo.php
You should see PHP default test page…
This is how to install LAMP with Ubuntu 16.04 LTS Server
You may also like the post below: