Enable to add new repositories

Install PHP 7.1

Install Apache 2.4

After successfully installation, lets begin installing Apache 2.4. Use the following set of commands to install Apache2 on your Ubuntu system available in default apt repositories.

Install MySQL 5.7

Use the following commands to install or upgrade MySQL 5.7 on your Ubuntu systems. At the last update of this tutorial MySQL 5.7.4 is latest available MySQL version in series of MySQL 5.7.X.

Issues

UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xc5

This happens due to encoding issue in repo author name. Fix below:

 

  • Create an SSH key
  • Login and adjust sshd_config file
    • Set PermitRootLogin no
    • Set PasswordAuthentication no
    • Restart SSH systemctl restart sshd.service
    • View status of SSH systemctl status ssh.service
  • Create a user: adduser user
  • Add user to sudo group: usermod -aG sudo user
  • Setup user’s .ssh directory and authorized_keys file
    • mkdir ~/.ssh
    • chmod 700 ~/.ssh
    • sudo cp /root/.ssh/authorized_keys ~/.ssh/
    • chown user:user ~/.ssh/authorized_keys
    • chmod 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
  • 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 Off in /etc/apache2/apache2.conf
    • Disable mpm_event module: sudo a2dismod mpm_event
    • Enable mpm_prefork module: sudo a2enmod mpm_prefork
    • Enable mod_rewrite module: sudo a2enmod rewrite
    • Add ServerName directive to /etc/apache2/apache2.conf using 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
  • 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
  • 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.html in /etc/apache2/mods-enabled/dir.conf