Skip to content

Instantly share code, notes, and snippets.

@ericmagnuson
Last active August 29, 2015 14:12
Show Gist options
  • Save ericmagnuson/25343646145d5f39e960 to your computer and use it in GitHub Desktop.
Save ericmagnuson/25343646145d5f39e960 to your computer and use it in GitHub Desktop.
LAMP Stack from Scratch
##############
# Basic LAMP #
##############
## Set root password (generate random password with `openssl rand -hex 5`)
passwd
## Update package sources
aptitude update
## Apache
aptitude install apache2
## Set ServerName in apache2 config by adding 'ServerName [servername]' to end
pico /etc/apache2/apache2.conf
## PHP
aptitude install php5 libapache2-mod-php5
## MySQL
aptitude install mysql-server php5-mysql
mysql_install_db
mysql_secure_installation
##########################
# LAMP config and extras #
##########################
## Set correct timezone
dpkg-reconfigure tzdata
## Colorize the bash prompt (when you are SSHing in)
## (Do again later for deployer user)
## Uncomment force_color_prompt=yes
pico ~/.bashrc
## Add index.php to beginning
nano /etc/apache2/mods-enabled/dir.conf
## Enable apache mods
a2enmod expires headers
## Install PHP extensions (get list by running `apt-cache search php5-`)
aptitude install php5-mcrypt php5-cli php5-gd php5-curl php5-dev
php5enmod mcrypt # Enable the mods
## Install git
aptitude install git
## Install node & npm
aptitude install nodejs npm
## Reboot apache2
service apache2 restart
#######################
# Deployer user setup #
#######################
## Set up "deployer" user for deploying
adduser deployer
adduser deployer sudo
## Set up SSH keys for deployer (add your public key to authorized_keys)
login deployer
ssh-keygen -t rsa
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
## Set up MySQL user so that root isn't used
mysql -u root -p
CREATE DATABASE [name of DB];
GRANT ALL PRIVILEGES ON [name of db].* To 'deployer'@'localhost' IDENTIFIED BY '[password]';
exit
##################
# Security setup #
##################
## Disable root SSH login by changing `PermitRootLogin yes`
## to `PermitRootLogin no`.
sudo pico /etc/ssh/sshd_config
sudo service ssh restart
## Setup ufw firewall
sudo ufw default deny
sudo ufw allow [port number] # (22 for SSH/SFTP, 80 for HTTP)
sudo ufw enable
sudo reboot now
##################
# Laravel set up #
##################
## Install composer
cd ~ && curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment