How to install LAMP on Ubuntu 18.04
What is a LAMP stack?
LAMP is an acronym that traditionally means "Linux, Apache, MySQL, and PHP", it is a popular software for many web applications or websites. The LAMP stack is quite powerful, but it is relatively simple and easy to use.
In recent years, various variations of the LAMP stack have gained popularity. for example, Python or Perl are used instead of the PHP programming language, and PostgreSQL is used instead of the MySQL DBMS.
On ServerSpace virtual servers, the Linux operating system, namely Ubuntu 18.04, is already installed, so the instructions will describe how to install the remaining components.
In the Serverspace you can create a server with already installed app "LAMP".
Installing Apache
The very heart of the LAMP stack is a server software called Apache. The web server works by processing HTTP requests that are used to send information over the Internet.
Apache is the world's most popular web server software, it is extremely stable, and it is completely open-source.
To install Apache, we will use the following command:
sudo apt-get install apache2
Before checking, do not forget to open the HTTP port, for example, using the iptables utility:
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
Go to the following address in your browser:
http://IP-adress-of-server/
As a result, you will see this page:
Installing MySQL
Next, you need to install a database management system. MySQL is the most common DBMS, and it is relatively easy to install and get started. This is quite a fast system due to the fact that it does not implement the full SQL standard and as many data types as in other DBMSs (in particular, PostgreSQL). This makes MySQL a great tool to use when writing simple applications that are fast and easy to set up but do not require a too complex operation.
To install MySQL, we will use the following command:
sudo apt-get install mysql-server
After installation, we recommend running the security script:
sudo mysql_secure_installation
To check the installation, you need to connect to MySQL. when connecting, you need to enter the password:
mysql -u root -p
Installing PHP
PHP is a configuration component that is designed to display dynamic content. It runs scripts and scripts, connects to MySQL databases for information, and sends the processed content to a web server for viewing.
To install PHP,we will use the following command:
sudo apt install php
This will install the latest version of PHP available in Ubuntu repositories (currently PHP 7.2) and some additional components, such as: libapache2-mod-php7.2 libsodium23 php-common php7.2 php7.2-cli php7.2-common php7.2-json php7.2-opcache php7.2-readline
You often need to install additional PHP components. to find them, use the following command:
apt-cache search php7
As a result, you will see a list of available components and a brief description of them. You can use the following command to install it:
apt install module-name
Checking the LAMP stack installation
Use a text editor to create a php verification file:
vi /var/www/html/info.php
Add the following content to it and save your changes:
<!--?php phpinfo();?-->
Restart the Apache server:
service apache2 restart
Go to the following address in your browser:
http://IP-adress-of-server/info.php
If everything was set correctly, you will see an information page.