[vc_row][vc_column][vc_column_text]
[vc_row][vc_column][vc_column_text]
Steps to Install Linux, Apache, MySQL, PHP (LAMP) in Ubuntu
About LAMP:
A “LAMP” stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database (using MariaDB), and dynamic content is processed by PHP.
Step 1 -Installing Apache and Updating Firewall
Apache HTTP Server is a free and open-source web server that delivers web content through the internet. It is commonly referred to as Apache and after development, it quickly became the most popular HTTP client on the web.
Install Apache
sudo apt update
sudo apt install apache2
Change firewall for allowing Web Traffic
Make UFW enable, Confirm your firewall allows HTTP and HTTPS traffic. You can check that UFW has an application profile for Apache like so:
sudo ufw app list
Output Available applications: Apache Apache Full Apache Secure
sudo ufw app info "Apache Full"
Output Profile: Apache Full Title: Web Server (HTTP,HTTPS) Description: Apache v2 is the next generation of the omnipresent Apache web server Ports: 80,443/tcp
Allow Apache full to Enable HTTP, HTTPS traffic to this profile:
sudo ufw allow in "Apache Full"
http://your_server_ip
Now see the default Ubuntu 18.04 Apache web page By using your IP address.
To Find your Server’s Public IP Address
The following command helps to find the server’s public IP address is
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
You can also use Curl command to find the server’s public IP address
sudo apt install curl
curl http://icanhazip.com
Step 2 – Installing MySQL
MySQL is a freely available open source Relational Database Management System (RDBMS) that uses Structured Query Language (SQL). SQL is the most popular language for adding, accessing and managing content in a database.
sudo apt install mysql-server
After the installation is complete, run a simple security script that comes pre-installed with MySQL which will remove some dangerous defaults and lock down access to your database system. Start the interactive script by running:
sudo mysql_secure_installation
Answer Y for yes, or anything else to continue without enabling.
If you answer “yes”, you’ll be asked to select a level of password validation
open up the MySQL prompt from your terminal:
sudo mysql
Next, check which authentication method each of your MySQL user accounts uses with the following command:
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
In this example, you can see that the root user does in fact authenticate using the auth_socket plugin.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Then, run FLUSH PRIVILEGES
which tells the server to reload the grant tables and put your new changes into effect:
mysql> FLUSH PRIVILEGES
Check the authentication methods employed by each of your users again to confirm that root no longer authenticates using the auth_socket plugin:
mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
You can see in this example output that the root MySQL user now authenticates using a password. Once you confirm this on your own server, you can exit the MySQL shell:
mysql> exit
Step 3 — Installing PHP
PHP is a server side scripting language. that is used to develop Static websites or Dynamic websites or Web applications. PHP stands for Hypertext Pre-processor, that earlier stood for Personal Home Pages.
sudo apt install php libapache2-mod-php php-mysql
In most cases, you’ll need to alter the way that Apache serves records when a catalog is asked. Right now, in case a client demands a registry from the server, Apache will to begin with search for a record called index.html. We need to tell the net server to lean toward PHP records over others, so make Apache explore for an index.php record to begin with.
To do this, type this command to open the dir.conf file in a text editor with root privileges:
sudo nano /etc/apache2/mods-enabled/dir.conf
It will look like this:
Move the PHP index file to the first position after the DirectoryIndex
specification, like this:
When you are finished, save and close the file by pressing CTRL+X. Confirm the save by typing Y and then hit ENTER to verify the file save location.
After this, restart the Apache web server in order for your changes to be recognized. Do this by typing this:
sudo systemctl restart apache2
You can also check on the status of the apache2 service using systemctl:
sudo systemctl status apache2
Press Q to exit this status output.
To improve the usefulness of PHP, you’ve got the choice to introduce a few extra modules. To see the accessible alternatives for PHP modules and libraries, pipe the comes about of able look into less, a pager which lets you scroll through the yield of other commands:
apt search php- | less
Use the arrow keys to scroll up and down, and press Q to quit.
The results are all optional components that you can install. It will give you a short description for each:
To memorize more almost what each module does, you’ll look the web for more data around them. Then again, see at the long description of the package by typing:
apt show package_name
There will be a lot of output, with one field called Description which will have a longer explanation of the functionality that the module provides.
apt show php-cli
Along with a large amount of other information, you’ll find something that looks like this:
If, after researching, you decide you would like to install a package, you can do so by using the apt install command like you have been doing for the other software.
If you decided that php-cli is something that you need, you could type:
sudo apt install php-cli
If you want to install more than one module, you can do that by listing each one, separated by a space, following the apt install command, like this:
sudo apt install package1 package2 ...
Step 4 — Testing PHP Processing on your Web Server
In order to test that your system is configured properly for PHP, create a very basic PHP script called info.php. In order for Apache to find this file and serve it correctly, it must be saved to your web root directory.
Create the file at the web root you created in the previous step by running:
sudo nano /var/www/html/info.php
This will open a blank file. Add the following text, which is valid PHP code, inside the file:
<?php phpinfo(); ?>
When you are finished, save and close the file.
Now you can test whether your web server is able to correctly display content generated by this PHP script. To try this out, visit this page in your web browser. You’ll need your server’s public IP address again.
The address you will want to visit is:
http://your_domain or IP Address/info.php
The page that you come to should look something like this:
[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text][/vc_column_text][/vc_column][/vc_row]