#Make Directory
mkdir /var/www/domain-name.com
#Make apache user the owner of this folder
chown apache:apache /var/www/domain-name.com/
#Apache works with all files with the .conf extension from the /etc/httpd/conf.d/ folder. Create a configuration file for your site.
nano /etc/httpd/conf.d/domain-name.com.conf
#Insert the following lines there. Replace domain-name.com with your domain name.
<virtualhost *:80>
ServerName domain-name.com
ServerAlias www.domain-name.com
DocumentRoot /var/www/domain-name.com
ErrorLog /var/log/httpd/domain-name.com-error.log
CustomLog /var/log/httpd/domain-name.com-access.log combined
</virtualhost>
#If you want multiple domain names to work with the same content, just list them separated by a space in the ServerAlias line.
ServerAlias www.domain-name.com domain-name2.com domain-name3.com
#Restart
systemctl restart httpd
#URL
https://serverspace.io/support/help/apache-virtual-hosts-on-centos-8/
#Fix 404 in react deployed app
#Modify /etc/httpd/conf/httpd.conf and AllowOverride All to fix .htaccess file not working issue Directory "/var/www" used because the build folder eg. perp-dev.plugend.com placed directly under /var/www
nano /etc/httpd/conf/httpd.conf
<Directory "/var/www">
AllowOverride All
Require all granted
</Directory>
#htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
#refer
https://stackoverflow.com/questions/27928372/react-router-urls-dont-work-when-refreshing-or-writing-manually?page=2&tab=oldest#tab-top
#Make Sure to https service
#Check existing services
firewall-cmd --permanent --list-all
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
#Install
sudo dnf install epel-release
sudo dnf install certbot python3-certbot-apache mod_ssl
sudo certbot --apache -d example.com
sudo certbot renew --dry-run
#add Cron
echo "0 0,12 * * * root python3 -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew -q" | sudo tee -a /etc/crontab > /dev/null
#Delete
certbot delete
#then manually delete ssl related files in conf.d/
#refer https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-centos-8