Skip to content

Instantly share code, notes, and snippets.

@junibrosas
Last active November 22, 2022 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junibrosas/5e6da98add506f1c0342966b3844a8d9 to your computer and use it in GitHub Desktop.
Save junibrosas/5e6da98add506f1c0342966b3844a8d9 to your computer and use it in GitHub Desktop.
Installing LAMP Stack

Installing Apache and Updating the Firewall

sudo apt update

sudo apt install apache2

sudo ufw app list

sudo ufw allow in "Apache"

How To Find your Server’s Public IP Address

curl http://icanhazip.com

sample output: 54.197.67.116

Installing MySQL

sudo apt install mysql-server

sudo mysql_secure_installation

sudo mysql

— Installing PHP 8.1

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

php -v

Creating a Virtual Host for your Website

sudo mkdir /var/www/your_domain

sudo chown -R $USER:$USER /var/www/your_domain

sudo nano /etc/apache2/sites-available/your_domain.conf

<VirtualHost *:80>
    ServerName your_domain
    ServerAlias www.your_domain 
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/your_domain
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

sudo a2ensite your_domain

sudo a2dissite 000-default

nano /var/www/your_domain/index.html

sudo apache2ctl configtest

sudo systemctl reload apache2

Create a sample index html file

nano /var/www/your_domain/index.html

<html>
  <head>
    <title>your_domain website</title>
  </head>
  <body>
    <h1>Hello World!</h1>

    <p>This is the landing page of <strong>your_domain</strong>.</p>
  </body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment