Skip to content

Instantly share code, notes, and snippets.

Embed
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 https://getcomposer.org/installer -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/yourdomain.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName yourdomain.com
ServerAlias yourdomain.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<Directory /var/www/html>
AllowOverride All
Require all granted
</Directory>
sudo a2ensite yourdomain.com.conf
#enable .htaccess on apache
<Directory /var/www/html>
AllowOverride All
Require all granted
</Directory>
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 yourdomain.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment