Setting Up Apache 2.4, MariaDB, and PHP 7 with Ubuntu 16.04 on a Digital Ocean VPS
PHP LAMP web development Apache MariaDB Ubuntu
- Setup Digital Ocean droplet
- Create an SSH key
- Login and adjust
sshd_configfile- Set
PermitRootLogin no - Set
PasswordAuthentication no - Restart SSH
systemctl restart sshd.service - View status of SSH
systemctl status ssh.service
- Set
- Create a user:
adduser user - Add user to
sudogroup:usermod -aG sudo user - Setup user's
.sshdirectory andauthorized_keysfilemkdir ~/.sshchmod 700 ~/.sshsudo cp /root/.ssh/authorized_keys ~/.ssh/chown user:user ~/.ssh/authorized_keyschmod 600 ~/.ssh/authorized_keys
- Test ability to login via SSH using newly created user
- Setup firewall using
ufw- Allow SSH:
sudo ufw allow 22 - Allow Web Server:
sudo ufw allow proto tcp from any to any port 80,443 - Enable:
sudo ufw enable - Check status:
sudo ufw status
- Allow SSH:
- Download, install, and setup Apache 2.4
- Install:
sudo apt-get install apache2 - Start after reboot:
systemctl enable apache2 - Check status:
systemctl status apache2 - Set
KeepAlive Offin/etc/apache2/apache2.conf - Disable
mpm_eventmodule:sudo a2dismod mpm_event - Enable
mpm_preforkmodule:sudo a2enmod mpm_prefork - Enable
mod_rewritemodule:sudo a2enmod rewrite - Add
ServerNamedirective to/etc/apache2/apache2.confusing public IP or FQDN - Check config syntax:
apache2ctl -t - Disable default
VirtualHost:sudo a2dissite 000-default.conf - Remove default web page:
sudo rm /var/www/html/index.html - Restart Apache:
sudo systemctl restart apache2.service
- Install:
- Download, install, and setup MariaDB in place of MySQL
- Install:
sudo apt-get install mariadb-server - Check status:
systemctl status mysql - Start after reboot:
sudo systemctl enable mysql - Secure the service:
sudo mysql_secure_installation
- Install:
- Download, install, and setup PHP 7
- Install:
sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql php-gd php-json php-cli php-curl php-mbstring php-xml php-xmlrpc - Set
DirectoryIndex index.php index.htmlin/etc/apache2/mods-enabled/dir.conf
- Install:
Comments