Skip to content

Instantly share code, notes, and snippets.

@EmpireWorld EmpireWorld/README.md
Last active Apr 12, 2019

Embed
What would you like to do?
Easy to use Bash Script to Install LAMP stack on Ubuntu.

Installation

Automatic

Run the below command in terminal:

wget --no-cache -O - https://gist.github.com/EmpireWorld/737fbb9f403d4dd66dee1364d866ba7e/raw/install-lamp.sh | bash

➡️ Go to next steps

Manual

First off, run the below command to update package index:

sudo apt update

Then run these commands in terminal separately to install each component:

Apache

sudo apt install apache2

MySQL

sudo apt install mysql-server

PHP

sudo apt install php php-mysql libapache2-mod-php php-cli

Adjust Firewall

sudo ufw allow in "Apache Full"

Adjust permissions

sudo chmod -R 0755 /var/www/html/

Allow running Apache on boot up

sudo systemctl enable apache2

Start Apache server

sudo systemctl start apache2

Test Apache

xdg-open "http://localhost"

Create sample PHP script file

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

Run sample PHP script file

xdg-open "http://localhost/info.php"

➡️ Go to next steps

Next Steps

Install phpMyAdmin

Run the below command in terminal to install phpMyAdmin and it's prerequisites:

sudo apt install phpmyadmin php-mbstring php-gettext

And then enable required extensions:

sudo phpenmod mcrypt
sudo phpenmod mbstring

Then restart Apache server:

sudo systemctl restart apache2

Now navigate to the phpMyAdmin:

xdg-open "http://localhost"

All done. now you have Apache2, MySQL, PHP installed.

Made with ❤️ by Bayat

#!/bin/bash
# Update Package Index
sudo apt update
# Install Apache2, MySQL, PHP
sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php php-cli
# Allow to run Apache on boot up
sudo systemctl enable apache2
# Restart Apache Web Server
sudo systemctl start apache2
# Adjust Firewall
sudo ufw allow in "Apache Full"
# Allow Read/Write for Owner
sudo chmod -R 0755 /var/www/html/
# Create info.php for testing php processing
sudo echo "<?php phpinfo(); ?>" > /var/www/html/info.php
# Open localhost in the default browser
xdg-open "http://localhost"
xdg-open "http://localhost/info.php"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.