Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install lamp-stack on Ubuntu with virtual host and SSL with certbot on apache. If you are facing any issue while installing ask me. Thank you!
#install lamp-stack by tasksel
sudo apt update && sudo apt upgrade
sudo apt install tasksel
sudo tasksel install lamp-server
#install phpmyadmin
sudo apt-get install -y phpmyadmin
#create db_user and grant access
CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' IDENTIFIED BY 'password';
#install composer
sudo apt install curl php-cli php-mbstring git unzip
cd ~
curl -sS -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
#setup virtual host for the domain
sudo nano /etc/apache2/sites-available/
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
AllowOverride All
Require all granted
sudo a2ensite
#enable .htaccess on apache
<Directory /var/www/html>
AllowOverride All
Require all granted
sudo a2enmod rewrite
#setup ssl for the domain
#install certbot
sudo add-apt-repository ppa:certbot/certbot
sudo apt install python-certbot-apache
#generate ssl
sudo certbot --apache -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment