LAMP installation

parent 7a48c120
LAMP installation on ubuntu 18.04
LAMP is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP.(https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-ubuntu-18-04)
Step 1- Installing Apache and Updating the Firewall
sudo apt update
sudo apt install apache2
Adjust the Firewall to Allow Web Traffic
$ sudo ufw app list
Output
Available applications:
Apache
Apache Full
Apache Secure
OpenSSH
$ 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
$ sudo ufw allow in "Apache Full"
http://your_server_ip
Find your Server’s Public IP Address
$ ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
$ sudo apt install curl
$ curl http://icanhazip.com
Step 2- Installing MySQL
$ sudo apt install mysql-server
$ sudo mysql_secure_installation
$ sudo mysql
$ SELECT user,authentication_string,plugin,host FROM mysql.user;
$ ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
$ FLUSH PRIVILEGES;
$ SELECT user,authentication_string,plugin,host FROM mysql.user;
$ exit
Step 3-Installing PHP
$ sudo apt install php libapache2-mod-php php-mysql
$ sudo nano /etc/apache2/mods-enabled/dir.conf
$ sudo systemctl restart apache2
$ sudo systemctl status apache2
$ apt search php- | less
$ apt show package_name
$ apt show php-cli
$ sudo apt install php-cli
$ sudo apt install package1 package2 …
Step 4 - Setting Up Virtual Hosts (Recommended)
$ sudo mkdir /var/www/your_domain
$ sudo chown -R $USER:$USER /var/www/your_domain
$ sudo chmod -R 755 /var/www/your_domain
$ nano /var/www/your_domain/index.html
Inside, add the following sample HTML code:
<html>
<head>
<title>Welcome to Your_domain!</title>
</head>
<body>
<h1>Success! The your_domain server block is working!</h1>
</body>
</html>
$ sudo nano /etc/apache2/sites-available/your_domain.conf
Paste in the following configuration block, which is similar to the default, but updated for our new directory and domain name:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName your_domain
ServerAlias www.your_domain
DocumentRoot /var/www/your_domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
$ sudo a2ensite your_domain.conf
$ sudo a2dissite 000-default.conf
$ sudo apache2ctl configtest
Output
Syntax OK
$ sudo systemctl restart apache2
http://your_domain
Step 5 - Testing PHP Processing on your Web Server
$ sudo nano /var/www/your_domain/info.php
http://your_domain/info.php
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment