Skip to content

Instantly share code, notes, and snippets.

@linuxdevhub
Last active December 7, 2019 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save linuxdevhub/e652fa6ae0eab151b912131b617a675e to your computer and use it in GitHub Desktop.
Save linuxdevhub/e652fa6ae0eab151b912131b617a675e to your computer and use it in GitHub Desktop.
# YouTube: https://www.youtube.com/watch?v=ymE3h8CzBXQ
# What is a LAMP Stack?
# LAMP (Linux, Apache, MySQL, PHP) stack is a common, free, and open-source web stack used for
# hosting web content in a Linux environment.
# Step 0: Before we install the LAMP stack, it’s a good idea to update repository and software packages:
sudo apt update
sudo apt upgrade
############## APACHE ##############
# Install Apache from the Ubuntu repository
sudo apt install apache2
# Some Basic apache commands
# version check
apache2 -v
# status Check
systemctl status apache2
# start apache
systemctl start apache2.service
# stop apache
systemctl stop apache2.service
# restart apache
systemctl restart apache2.service
# visit apache localhost
firefox http://localhost/
# Enable the firewall to allow web traffic
#To view UFW firewall application profile list:
sudo ufw app list
#Check the ports that are enabled for Apache Full Profile:
sudo ufw app info "Apache Full"
#Ports 80 and 443 should be listed as enabled.
#To allow incoming HTTP and HTTPS traffic for Apache Full profile:
sudo ufw allow in "Apache Full"
############## MYSQL ##############
# Step 2: Install the mysql-server package:
sudo apt install mysql-server
sudo mysql_secure_installation
#Basic MySql Commands
mysql --version
service mysql start
service mysql stop
service mysql restart
# Access MySql From Terminal
sudo mysql -u USERNAME -p
# Show Database List
show databases;
# create new user
CREATE USER 'newusername'@'localhost' IDENTIFIED BY 'user_password';
# Create Database
CREATE DATABASE databasename;
#Grant all database permission to that user
GRANT ALL PRIVILEGES ON *.* TO 'newusername'@'localhost';
############## PHP ##############
# Step 3: Install PHP and additional support libraries
# Install PHP, PHP Extension and Application Repository, Apache support,and MySQL support
sudo apt install php libapache2-mod-php php-mysql
# Install PhpMyAdmin
sudo apt install phpmyadmin php-mbstring php-gettext
# PHP Version Check
php --version
# Open apache2.conf file with any text editor like nano, gedit, nano etc
sudo nano /etc/apache2/apache2.conf
# Then add the following line to the end of the file and save that file
# Include /etc/phpmyadmin/apache.conf
# Then restart apache:
sudo service apache2 restart
# Visit phpmyadmin page
firefox http://localhost/phpmyadmin/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment