Skip to content

Instantly share code, notes, and snippets.

@mebens
Created January 13, 2019 07:46
Show Gist options
  • Save mebens/69e580fcc5e384c36afc1c0ac2a1547d to your computer and use it in GitHub Desktop.
Save mebens/69e580fcc5e384c36afc1c0ac2a1547d to your computer and use it in GitHub Desktop.
Setting up an up-to-date LAMP stack server on Ubuntu 18.04
# Script correlating to tutorial at http://ebens.me/post/install-lamp-stack-ubuntu
# Even though you probably could, don't run it all at once
# new user
adduser new_user
usermod -a -G sudo new_user
su - new_user
# new repos
sudo add-apt-repository ppa:ondrej/apache2
sudo add-apt-repository ppa:ondrej/php
wget https://dev.mysql.com/get/mysql-apt-config_0.8.11-1_all.deb # or whatever the latest is https://dev.mysql.com/downloads/repo/apt/
sudo dpkg -i mysql-apt-config_0.8.11-1_all.deb
rm mysql-apt-config_0.8.11-1_all.deb
# select options, defaults should be fine, but ensure mysql-8.0 (or whatever is the latest) is installed
# upgrade software
sudo apt update
sudo apt upgrade
sudo apt auto-remove
# add SSH key(s)
cd
mkdir -p .ssh
nano .ssh/authorized_keys
# paste public key(s) and save
chmod -R 700 .ssh
# secure ssh
sudo nano /etc/ssh/sshd_config
# change:
# PermitRootLogin no
# X11Forwarding no
# IgnoreRhosts yes
# PermitEmptyPasswords no
# PasswordAuthentication no # optional
# UsePAM no
sudo systemctl reload ssh # reloads rather than restarts, decreasing chance of disconnection
sudo systemctl status ssh # may need to press q to exit
# start firewall
sudo apt install ufw # if not present
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw enable
sudo ufw status verbose
# install apache2
sudo apt install apache2
sudo nano /etc/apache2/apache2.conf
# AllowOverride all
# Potentially change /var/www to new web host location
sudo nano /etc/apache2/mods-enabled/dir.conf
# Change to index.php index.html index.xhtml index.htm
sudo systemctl restart apache2
sudo systemctl status apache2 # may need to press q to exit
# install mysql
sudo apt install mysql-server
sudo mysql_secure_installation
# install php
sudo apt install php libapache2-mod-php php-mysql php-mbstring # whatever other additions needed
# to test
sudo nano /var/www/html/index.php # or whatever your web host path is
# <?php phpinfo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment