Install LAMP stack on Debian

LAMP stack is used for hosting Websites and Apps. LAMP stack is a set of packages such as Linux, Apache, MySQL, and PHP. In this tutorial, you are going to learn How to install LAMP stack on Debian.

Prerequisites

Before you start to install LAMP stack on Debian 9. You must have the non-root user account on your server/desktop with sudo privileges.

1. Install Apache

Update the apt package manager index by running following command

sudo apt update

Now install Apache web server by typing following command

sudo apt install apache2

Confirm the installation of Apache by using the following command

sudo systemctl status apache2

If you have UFW firewall enabled then you should open port 80 for HTTP and 443 for HTTPS to Apache Web Server. Enter the following commands to enable ports.

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload

Now you can verify your Apache installation by visiting http://YOUR_DOMAIN_NAME/ or http://localhost/

2. Install MariaDB

Update apt package manager index by typing following command

sudo apt update

Now you can install MariaDB by running following command

sudo apt install mariadb-server mariadb-client

Check the status and confirm installation by typing following command

sudo systemctl status apache2

To secure MariaDB run following command.

sudo mysql_secure_installation

Once you execute above command you will be asked to enter current password (Press ENTER for none) then you will be asked following questions, enter y for following questions:

  • Set root password? : y
  • Remove anonymous users? : y
  • Disallow root login remotely? : y
  • Remove test database and access to it? : y
  • Reload privilege tables now? : y

3. Install PHP

To install PHP you should first update package manager index. Update apt package manager index by typing

sudo apt update

Install PHP and some of its common extensions by typing

sudo apt install php php-common php-mysql php-gd php-cli

After installing PHP you can confirm installtion by creating info.php file. Run following command to create info.php file.

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Now visit http://YOUR_DOMAIN_NAME/info.php or http://localhost/info.php in your browser to confirm installation.

Conclusion

You have successfully learned how to install LAMP stack on Debian 9. If you have any queries regarding this please don’t forget to comment below.

Install LAMP stack on CentOS

LAMP stack stands for the set of packages such as Linux, Apache, MySQL, and PHP. LAMP stack is widely used for hosting Websites and Apps. In this tutorial, you are going to learn How to install LAMP stack on CentOS.

Prerequisites

Before you start to install LAMP stack on CentOS 7. You must have the non-root user account on your server with sudo privileges.

1. Install Apache

In CentOS and RHEL Apache service is known as httpd. As Apache repository is available if CentOS core repositories, installation is pretty easy.

To install Apache on CentOS enter following command

sudo yum install httpd

Once You install Apache start and enable service by typing following in terminal.

sudo systemctl start httpd
sudo systemctl enable httpd

Confirm the status of Apache service by running following command

sudo systemctl status httpd

Enter CTRL+c to exit.

2. Install MariaDB

Now you are going to install MariaDB on your server. To install type following:

sudo yum install mariadb-server

After installing MariaDB you should start and enable MariaDB service by running the following command.

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Check the status of MariaDB service by typing

sudo systemctl status mariadb.service

The Installer generates the temporary password for MariaDb and saves it inside a file to check the password inside file enter following command

grep "A temporary password" /var/log/mysqld.log  | tail -n1

[Some text hidden] A temporary password is generated for [email protected]: Eif;=GPCD88#

To secure MariaDB run following command.

sudo mysql_secure_installation

Once you execute above command you will be asked to enter current password (Press ENTER for none) then you will be asked following questions, enter y for following questions:

  • Set root password? : y
  • Remove anonymous users? : y
  • Disallow root login remotely? : y
  • Remove test database and access to it? : y
  • Reload privilege tables now? : y

Enter CTRL+c to exit

3. Install PHP

CentOS does not ship with PHP 7.2 in its core repositories. Here we are going to use the Remi repository to install PHP 7.2.

Enter the following command to add Remi repository on CentOS

sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Now you should enable remi-php72 repository, to do so type:

sudo yum install yum-utils
sudo yum-config-manager --enable remi-php72

Install PHP and some of its required extensions by typing

sudo yum install php php-common php-gd php-curl php-mysql

Now restart Apache by using the following command

sudo systemctl restart httpd

Test PHP

Now you should create info.php file to test php to do so type following.

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Now visit http://YOUR_DOMAIN_NAME_OR_IP_ADDRESS/info.php or http://localhost/info.php in your browser.

Conclusion

You have successfully learned to install LAMP stack on CentOS 7. If you have any queries regarding this please don’t forget to comment below.

Install LAMP stack on Ubuntu

LAMP stack is a set of packages such as Linux, Apache, MySQL, and PHP. LAMP stack is used for hosting Websites and Apps. In this tutorial, you are going to learn How to install LAMP stack on Ubuntu.

Prerequisites

Before you start to install LAMP stack on Ubuntu 18.04. You must have the non-root user account on your server/desktop with sudo privileges.

1. Install Apache

First, you will need to update the package manager index by typing

sudo apt update

Now install Apache by running following command

sudo apt install apache2

Confirm the installation of Apache by using the following command

sudo systemctl status apache2

If you have UFW firewall enabled then you should open port 80 for HTTP and 443 for HTTPS to Apache Web Server. Enter the following commands to enable ports.

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload

Now you can verify your Apache installation by visiting http://YOUR_DOMAIN_NAME/ or http://localhost/

2. Install MariaDB

Update apt package manager index by typing following command

sudo apt update

Now you can install MariaDB by running following command

sudo apt install mariadb-server mariadb-client

Check the status and confirm installation by typing following command

sudo systemctl status apache2

To secure MariaDB run following command.

sudo mysql_secure_installation

Once you execute above command you will be asked to enter current password (Press ENTER for none) then you will be asked following questions, enter y for following questions:

  • Set root password? : y
  • Remove anonymous users? : y
  • Disallow root login remotely? : y
  • Remove test database and access to it? : y
  • Reload privilege tables now? : y

3. Install PHP

To install PHP you should first update package manager index then you will install PHP.

Update apt package manager index by typing

sudo apt update

Install PHP and some of its common extensions by typing

sudo apt install php php-common php-mysql php-gd php-cli

After installing PHP you can confirm installtion by creating info.php file. Run following command to create info.php file.

echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Now visit http://YOUR_DOMAIN_NAME/info.php or http://localhost/info.php in your browser to confirm installtion.

Conclusion

You have successfully learned how to install LAMP stack on Ubuntu 18.04. If you have any queries regarding this please don’t forget to comment below.

Install PHP on Ubuntu 18.04

PHP is one of the most popular programming language currently in the world. PHP has different versions 5.6, 7.0, 7.1 and 7.2. Currently, PHP 7.2 is the latest version of PHP which supports different frameworks like WordPress, Laravel, Code-Igniter etc. Ubuntu 18.04 ships with default PHP 7.2 support, We can easily install PHP 7.2 on Ubuntu 18.4. Ubuntu 18.04 is the current latest version of Ubuntu. This tutorial outlines how to install PHP 7.2 on Ubuntu 18.04.

Prerequisites

Before you start installing PHP 7.2 on Ubuntu 18.04. You must have a non-root user account on your server with sudo privileges

1. Install PHP With Nginx

Nginx does not support native PHP processing. You will need to Install “fastCGI process manager” which is known as php-fpm

Run the following command to install php-fpm on your server. The following command will install php-fpm7.2

sudo apt install php-fpm

You can check the status where it is correctly installed or not by following command

systemctl status php7.2-fpm

After installing php-fpm package you will need to restart Nginx server. To restart Nginx server run following command

sudo systemctl restart nginx

You can check PHP version by running following command

php -v

2. Installing PHP With Apache

If you have Apache running at backend then we need to install PHP and Apache PHP module on the server. To install PHP 7.2 and Apache module type following command and press enter.

sudo apt install php libapache2-mod-php

After installing PHP and apache-php module you will need to restart Apache server by typing following command

sudo systemctl restart apache2

3. Install PHP Extensions

You will need to install some basic PHP extensions to run WordPress , Laravel like frameworks on the server. To install any of the PHP extensions on the server following is the basic format.

sudo apt install php-[name_of_the_extension]

You can install curl extension for PHP by running following command

sudo apt install php-curl

Following are some basic PHP extensions needs to be installed on your server

sudo apt install php7.2-curl php7.2-mysql php7.2-common php7.2-cli php7.2-gd php7.2-opcache

To install more extensions you can use the above format.

4. Testing PHP processing

To test whether PHP is configured on your server properly or not you should create a file test.php inside directory var/www/html/ with following code.

<?php

phpinfo();

If you see the following output then you have installed PHP successfully.

Conclusion

In this tutorial, you have learned how to install PHP 7.2 on Ubuntu 18.04 successfully with some of its basic extensions useful for frameworks and tested successfully. If you have any of the queries regarding this then you can comment below.

Related Tutorials

  1. How to install Nginx on Ubuntu 18.04
  2. How to Secure Nginx with Let’s Encrypt SSL on Ubuntu 18.04