Adding better backups and log rotation, and updating files around it
This commit is contained in:
@@ -34,6 +34,12 @@ cat <<EOF > /etc/httpd/conf.d/$domain.conf
|
||||
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
|
||||
</VirtualHost>
|
||||
|
||||
Listen 443 https
|
||||
SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog
|
||||
SSLSessionCache shmcb:/run/httpd/sslcache(512000)
|
||||
SSLSessionCacheTimeout 300
|
||||
SSLCryptoDevice builtin
|
||||
|
||||
<IfModule mod_ssl.c>
|
||||
<VirtualHost _default_:443>
|
||||
ServerName "$domain"
|
||||
|
@@ -7,26 +7,30 @@ fi
|
||||
adduser -u $uid $user
|
||||
|
||||
mkdir -p /home/$user/public_html
|
||||
mkdir -p /home/$user/logs
|
||||
mkdir -p /home/$user/logs/{apache,system}
|
||||
mkdir -p /home/$user/logs/{apache,php-fpm}
|
||||
|
||||
chown -R $user:$user /home/$user
|
||||
chmod -R 755 /home/$user
|
||||
mv /var/log/httpd /var/log/httpd.bak
|
||||
|
||||
ln -s /home/$user/logs/apache /var/log/httpd
|
||||
ln -s /home/$user/logs/php-fpm /var/log/php-fpm
|
||||
|
||||
/scripts/install-php$PHPVER.sh
|
||||
|
||||
/scripts/create-vhost.sh
|
||||
/scripts/create-php-config.sh
|
||||
|
||||
ln -s /etc/httpd/logs /home/$user/logs/apache
|
||||
ln -s /var/log /home/$user/logs/system
|
||||
if [ -f /etc/httpd/conf.d/ssl.conf ]; then
|
||||
mv /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.bak
|
||||
fi
|
||||
|
||||
/usr/sbin/httpd -k start
|
||||
/usr/sbin/php-fpm -y /etc/php-fpm.conf
|
||||
chown -R $user:$user /home/$user
|
||||
chmod -R 755 /home/$user
|
||||
|
||||
if [[ $environment == 'DEV' ]]; then
|
||||
echo "Starting Dev Deployment"
|
||||
mkdir -p /home/$user/public_html/_db_backups
|
||||
mkdir -p /home/$user/_db_backups
|
||||
dnf install -y MariaDB-server MariaDB-client memcached
|
||||
nohup mysqld -umysql &
|
||||
if [ ! -f /home/$user/mysql_creds ]; then
|
||||
@@ -39,7 +43,7 @@ if [[ $environment == 'DEV' ]]; then
|
||||
mysql -e "CREATE USER '"$mysql_user"'@'localhost' IDENTIFIED BY '"$mysql_password"';"
|
||||
mysql -e "GRANT ALL PRIVILEGES ON *.* TO '"$mysql_user"'@'localhost' WITH GRANT OPTION;"
|
||||
mysql -e "FLUSH PRIVILEGES;"
|
||||
echo "*/15 * * * * root /scripts/mysql-backup.sh $user $mysql_db" >> /etc/crontab
|
||||
echo "*/15 * * * * root /scripts/mysql-backup.sh $user devdb_$mysql_db" >> /etc/crontab
|
||||
echo "MySQL User: "$mysql_user > /home/$user/mysql_creds
|
||||
echo "MySQL Password: "$mysql_password >> /home/$user/mysql_creds
|
||||
echo "MySQL Database: devdb_"$mysql_db >> /home/$user/mysql_creds
|
||||
@@ -54,7 +58,7 @@ if [[ $environment == 'PROD' ]]; then
|
||||
sed -r -i 's/;session.save_path="localhost:11211/session.save_path="memcache:11211/' /etc/php.d/50-memcached.ini
|
||||
fi
|
||||
/usr/sbin/crond
|
||||
tail -f /etc/httpd/logs/*
|
||||
tail -f /var/log/httpd/*
|
||||
|
||||
exit 0
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Set the log directory
|
||||
LOG_DIR="/etc/httpd/logs"
|
||||
LOG_DIR="/var/log/httpd"
|
||||
|
||||
# Get current date
|
||||
DATE=$(date +%Y%m%d)
|
||||
|
@@ -7,7 +7,8 @@ if [ ! -d /home/$user/_db_backups ]; then
|
||||
mkdir -p /home/$user/_db_backups
|
||||
fi
|
||||
|
||||
/usr/bin/mysqldump $mysql_db > /home/$user/_db_backups/$mysql_db.$dt.sql"
|
||||
/usr/bin/find /home/$user/_db_backups/ -type f -mmin +360 -delete"
|
||||
/usr/bin/mysqldump $mysql_db > /home/$user/_db_backups/$mysql_db.$dt.sql
|
||||
chown -R $user:$user /home/$user/_db_backups
|
||||
/usr/bin/find /home/$user/_db_backups/ -type f -mmin +360 -delete
|
||||
|
||||
exit 0
|
Reference in New Issue
Block a user