This will guide you through the process of setting up a Fedora 27 LAMP server with SSL (https) from Let’s Encrypt.
Installing Fedora 27
- Install Fedora 27 via Net Install ISO.
- In Software Selection, select Minimal Install.
- It may take a minute to download metadata before you can go in there.
- In Network & Host Name, set the Host Name, then click Apply and Done.
- In Installation Destination, select Custom, then click Done.
- Verify LVM is selected.
- Click “Click here to create them automatically”.
- Verify / is XFS File System.
- Under Desired Capacity for /, type “9999999999” and then click the Update Settings button.
- Click Done, then click Accept Changes in the Summary of Changes window pop-up.
- Click Begin Installation.
- Set a Root Password, then click Done.
- Wait for installation to complete, then reboot.
Post Install
- Log in as root, and verify OS is up to date:
dnf upgrade --refresh
- Fix Fedora MAC Address & DHCP Issue: (if using Windows DHCP services)
echo "send dhcp-client-identifier = hardware;" >> /etc/dhcp/dhclient.conf
- Reboot
- Create a new secure SSH key: (because the default is only 2048 bit)
ssh-keygen -t rsa -b 4096 -C "root-tgserv-key"
- Hit enter for default location and name.
- Hit enter again to skip passphrase creation.
- Now you should SSH to server to continue.
- Install the following packages, then reboot:
dnf install -y hyperv-daemons hyperv-tools cockpit policycoreutils-python-utils rsync tar unzip net-tools dnf-automatic httpd mariadb mariadb-server php php-mysqlnd php-gd php-pecl-zip php-theseer-fDOMDocument php-pecl-apcu phpmyadmin php-gettext ZipArchive
- Caution, phpmyadmin is included in the above command. If you are doing a public install, it is recommended you exclude that.
- Note: if you are not installing this on a Hyper-V hypervisor, exclude the following packages:
hyperv-daemons hyperv-tools
- Configure Services:
systemctl enable --now cockpit.socket systemctl enable --now httpd.socket systemctl enable --now mariadb.service
- Configure Firewall:
firewall-cmd --add-service=cockpit --permanent firewall-cmd --add-port=http/tcp --permanent firewall-cmd --add-port=https/tcp --permanent firewall-cmd --reload
- Reboot now
- Configure MySQL / MariaDB: (run the below command)
/usr/bin/mysql_secure_installation
- Hit enter for none (this is a new installation, so password is blank)
- Enter Y to set root password.
- Enter Y to remove anonymous users.
- Enter Y to disallow root login remotely. (okay to enter N if not publicly accessible)
- Enter Y to remove test database.
- Enter Y to reload privilege tables.
- Allow remote access to phpMyAdmin: (not advised if publicly accessible)
vi /etc/httpd/conf.d/phpMyAdmin.conf
- Add the following to the relevant 4 sections in the file above:
172.16.0.0/12
Here, you would enter the IPs that are allowed to remotely access phpMyAdmin - Restart httpd service:
service httpd restart
- Add the following to the relevant 4 sections in the file above:
- Configure automatic update settings, set the following in the below file:
vi /etc/dnf/automatic.conf
- apply_updates = yes
- emit_via = email
- email_from = serveralerts@email.com
- email_to = IT@email.com
- email_host = yourSMTPserver.com
- Configure automatic update schedule, change the following in below file:
vi /usr/lib/systemd/system/dnf-automatic-install.timer
- OnUnitInactiveSec=6h
- Enable automatic update system timer:
systemctl enable dnf-automatic-install.timer && systemctl start dnf-automatic-install.timer
- Verify timer is showing up after a reboot by the following command:
systemctl list-timers
- Verify timer is showing up after a reboot by the following command:
- Set SELinux httpd_t to permissive:
semanage permissive -a httpd_t
Implementing SSL
If you want to use SSL on your LAMP server so your website can be accessed via HTTPS, you’ll need a cert.
In this section, I’ll guide you through setting this up for free via Let’s Encrypt, on Fedora 27 with Apache installed.
Certbot-apache will automatically configure Apache for SSL if you follow below:
- Create an Apache config file named appropriately for your domain:
vi /etc/httpd/conf.d/tgserv.timothygruber.com.conf
- Paste the following into the above file, changing it to fit your needs, then save:
<VirtualHost *:80> ServerAdmin your@email.com DocumentRoot /var/www/html ServerName tgserv.timothygruber.com ErrorLog /etc/httpd/logs/tgserv.timothygruber.com-error_log CustomLog /etc/httpd/logs/tgserv.timothygruber.com-access_log common </VirtualHost>
- Paste the following into the above file, changing it to fit your needs, then save:
- Restart the web server:
service httpd restart
- Install Certbot:
dnf install certbot-apache
- Set up Certbot:
certbot --apache
- Certbot should automatically find your domains so long as you have a working DNS entry for your domain. Let’s Encrypt uses this to verify your domain.
- Test the renewal process:
certbot renew --dry-run
- Set up a cronjob to run renewal. Certs expire every 90 days, but this script will try twice daily to prevent any down time should a situation arise such as your certificates being expired or revoked.
- Edit root cronttab:
crontab -e
- Paste in the following, then save:
0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew
- Edit root cronttab:
- Test your website using https://sitename.com