Finished Cloud Apache Container
This commit is contained in:
32
scripts/create-php-config.sh
Normal file
32
scripts/create-php-config.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
rm /etc/php-fpm.d/www.conf
|
||||
|
||||
cat <<EOF > /etc/php-fpm.d/$user.conf
|
||||
|
||||
[$user]
|
||||
|
||||
user = $user
|
||||
group = $user
|
||||
listen = /run/php-fpm/www.sock
|
||||
listen.owner = apache
|
||||
listen.group = apache
|
||||
|
||||
pm = dynamic
|
||||
pm.max_children = 50
|
||||
pm.start_servers = 5
|
||||
pm.min_spare_servers = 5
|
||||
pm.max_spare_servers = 35
|
||||
pm.process_idle_timeout = 15s;
|
||||
pm.max_requests = 500
|
||||
|
||||
slowlog = /var/log/php-fpm/www-slow.log
|
||||
request_slowlog_timeout = 6s
|
||||
|
||||
php_admin_value[error_log] = /etc/httpd/logs/error_log
|
||||
php_admin_flag[log_errors] = on
|
||||
php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache
|
||||
|
||||
EOF
|
||||
|
||||
exit 0
|
49
scripts/create-vhost.sh
Normal file
49
scripts/create-vhost.sh
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
alias_block=''
|
||||
|
||||
#Create Server Alias Block
|
||||
if [ ! -z $serveralias ]; then
|
||||
for alias in $(echo $serveralias | tr ',' ' ')
|
||||
do
|
||||
alias_block=$alias_block"ServerAlias $alias
|
||||
"
|
||||
done
|
||||
fi
|
||||
|
||||
cat <<EOF > /etc/httpd/conf.d/$domain.conf
|
||||
|
||||
<Directory "/home/$user">
|
||||
AllowOverride None
|
||||
# Allow open access:
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
<Directory "/home/$user/public_html">
|
||||
Options All MultiViews
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
<VirtualHost _default_:*>
|
||||
ServerName "$domain"
|
||||
$alias_block
|
||||
DocumentRoot "/home/$user/public_html"
|
||||
RewriteEngine on
|
||||
RewriteCond %{SERVER_NAME} =$domain
|
||||
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
|
||||
</VirtualHost>
|
||||
|
||||
<IfModule mod_ssl.c>
|
||||
<VirtualHost _default_:443>
|
||||
ServerName "$domain"
|
||||
$alias_block
|
||||
DocumentRoot "/home/$user/public_html"
|
||||
|
||||
|
||||
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
|
||||
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
|
||||
</VirtualHost>
|
||||
</IfModule>
|
||||
|
||||
EOF
|
40
scripts/entrypoint.sh
Normal file
40
scripts/entrypoint.sh
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
adduser -u $uid $user
|
||||
|
||||
mkdir -p /home/$user/public_html
|
||||
|
||||
chown -R $user:$user /home/$user
|
||||
chmod -R 755 /home/$user
|
||||
|
||||
/scripts/create-vhost.sh
|
||||
/scripts/create-php-config.sh
|
||||
|
||||
/usr/sbin/httpd -k start
|
||||
/usr/sbin/php-fpm -y /etc/php-fpm.conf
|
||||
|
||||
if [ $environment == 'DEV' ]; then
|
||||
echo "Starting Dev Deployment"
|
||||
yum install -y MariaDB-server MariaDB-client
|
||||
nohup mysqld -umysql &
|
||||
if [ ! -f /var/lib/mysql/creds ]; then
|
||||
echo "Give MySQL a chance to finish starting..."
|
||||
sleep 10
|
||||
mysql_user=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13 ; echo '')
|
||||
mysql_password=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 18 ; echo '')
|
||||
mysql_db=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 6 ; echo '')
|
||||
mysql -e "CREATE DATABASE devdb_"$mysql_db";"
|
||||
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 "MySQL User: "$mysql_user > /var/lib/mysql/creds
|
||||
echo "MySQL Password: "$mysql_password >> /var/lib/mysql/creds
|
||||
echo "MySQL Database: devdb_"$mysql_db >> /var/lib/mysql/creds
|
||||
cat /var/lib/mysql/creds
|
||||
fi
|
||||
/usr/bin/memcached -d -u $user
|
||||
fi
|
||||
tail -f /etc/httpd/logs/*
|
||||
|
||||
exit 0
|
||||
|
9
scripts/install-php74.sh
Normal file
9
scripts/install-php74.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
dnf module enable php:remi-7.4 -y
|
||||
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-xmlrpc \
|
||||
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
|
||||
php-mysqlnd php-mbstring php-ioncube-loader php-intl php-gd libzip php-cli
|
||||
sed -i 's/^php_value\[session\.save_handler\] = files$/;php_value[session.save_handler] = files/' /etc/php-fpm.d/www.conf
|
||||
sed -i 's/^php_value\[session\.save_path\] *= *\/*var\/lib\/php\/session$/;php_value[session.save_path] = \/var\/lib\/php\/session/' /etc/php-fpm.d/www.conf
|
||||
|
||||
exit 0
|
9
scripts/install-php80.sh
Normal file
9
scripts/install-php80.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
dnf module enable php:remi-8.0 -y
|
||||
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
|
||||
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
|
||||
php-mysqlnd php-mbstring php-ioncube-loader php-intl php-gd libzip php-cli
|
||||
sed -i 's/^php_value\[session\.save_handler\] = files$/;php_value[session.save_handler] = files/' /etc/php-fpm.d/www.conf
|
||||
sed -i 's/^php_value\[session\.save_path\] *= *\/*var\/lib\/php\/session$/;php_value[session.save_path] = \/var\/lib\/php\/session/' /etc/php-fpm.d/www.conf
|
||||
|
||||
exit 0
|
9
scripts/install-php81.sh
Normal file
9
scripts/install-php81.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
dnf module enable php:remi-8.1 -y
|
||||
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
|
||||
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
|
||||
php-mysqlnd php-mbstring php-ioncube-loader php-intl php-gd libzip php-cli
|
||||
sed -i 's/^php_value\[session\.save_handler\] = files$/;php_value[session.save_handler] = files/' /etc/php-fpm.d/www.conf
|
||||
sed -i 's/^php_value\[session\.save_path\] *= *\/*var\/lib\/php\/session$/;php_value[session.save_path] = \/var\/lib\/php\/session/' /etc/php-fpm.d/www.conf
|
||||
|
||||
exit 0
|
9
scripts/install-php82.sh
Normal file
9
scripts/install-php82.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
dnf module enable php:remi-8.2 -y
|
||||
dnf install -y php php-fpm php-mysqlnd php-xml php-pecl-zip php-sodium php-soap php-pecl-xmlrpc \
|
||||
php-pecl-redis5 php-pecl-memcached php-pecl-memcache php-pecl-ip2location php-pecl-imagick php-pecl-geoip \
|
||||
php-mysqlnd php-mbstring php-intl php-gd libzip php-cli
|
||||
sed -i 's/^php_value\[session\.save_handler\] = files$/;php_value[session.save_handler] = files/' /etc/php-fpm.d/www.conf
|
||||
sed -i 's/^php_value\[session\.save_path\] *= *\/*var\/lib\/php\/session$/;php_value[session.save_path] = \/var\/lib\/php\/session/' /etc/php-fpm.d/www.conf
|
||||
|
||||
exit 0
|
Reference in New Issue
Block a user