diff --git a/resources/aliases b/resources/aliases index e2117f380..ebc8b3019 100644 --- a/resources/aliases +++ b/resources/aliases @@ -129,6 +129,19 @@ function serve-symfony4() { fi } +function serve-pimcore() { + if [[ "$1" && "$2" ]] + then + sudo bash /vagrant/scripts/create-certificate.sh "$1" + sudo dos2unix /vagrant/scripts/serve-pimcore.sh + sudo bash /vagrant/scripts/serve-pimcore.sh "$1" "$2" 80 + else + echo "Error: missing required parameters." + echo "Usage: " + echo " serve-pimcore domain path" + fi +} + function share() { if [[ "$1" ]] then diff --git a/resources/localized/aliases b/resources/localized/aliases index ddcbc27cc..e37bbd121 100644 --- a/resources/localized/aliases +++ b/resources/localized/aliases @@ -129,6 +129,19 @@ function serve-symfony4() { fi } +function serve-pimcore() { + if [[ "$1" && "$2" ]] + then + sudo bash /vagrant/vendor/laravel/homestead/scripts/create-certificate.sh "$1" + sudo dos2unix /vagrant/vendor/laravel/homestead/scripts/serve-pimcore.sh + sudo bash /vagrant/vendor/laravel/homestead/scripts/serve-pimcore.sh "$1" "$2" 80 + else + echo "Error: missing required parameters." + echo "Usage: " + echo " serve-pimcore domain path" + fi +} + function share() { if [[ "$1" ]] then diff --git a/scripts/serve-pimcore.sh b/scripts/serve-pimcore.sh new file mode 100644 index 000000000..1fad4e753 --- /dev/null +++ b/scripts/serve-pimcore.sh @@ -0,0 +1,93 @@ +#!/usr/bin/env bash + +# install apache and bzip PHP extension +export DEBIAN_FRONTEND=noninteractive +sudo service nginx stop +apt-get update +apt-get install -y apache2 libapache2-mod-fastcgi +apt-get install -y php"$5"-bz2 + +block=" + ServerName $1 + ServerAlias *.$1 + + DocumentRoot $2 + + AllowOverride All + Require all granted + + + # Force Apache to pass the Authorization header to PHP: + # required for "basic_auth" under PHP-FPM and FastCGI + SetEnvIfNoCase ^Authorization\$ \"(.+)\" HTTP_AUTHORIZATION=\$1 + + # Using SetHandler avoids issues with using ProxyPassMatch in combination + # with mod_rewrite or mod_autoindex + + SetHandler \"proxy:unix:/var/run/php/php$5-fpm.sock|fcgi://localhost\" + + + ErrorLog \${APACHE_LOG_DIR}/$1-error.log + CustomLog \${APACHE_LOG_DIR}/$1-access.log combined + +" + +blockssl=" + + ServerName $1 + ServerAlias *.$1 + + DocumentRoot $2 + + AllowOverride All + Require all granted + + + # Force Apache to pass the Authorization header to PHP: + # required for "basic_auth" under PHP-FPM and FastCGI + SetEnvIfNoCase ^Authorization\$ \"(.+)\" HTTP_AUTHORIZATION=\$1 + + # Using SetHandler avoids issues with using ProxyPassMatch in combination + # with mod_rewrite or mod_autoindex + + SetHandler \"proxy:unix:/var/run/php/php$5-fpm.sock|fcgi://localhost\" + + + ErrorLog \${APACHE_LOG_DIR}/$1-error.log + CustomLog \${APACHE_LOG_DIR}/$1-access.log combined + + SSLEngine on + SSLCertificateFile /etc/nginx/ssl/$1.crt + SSLCertificateKeyFile /etc/nginx/ssl/$1.key + + + SSLOptions +StdEnvVars + + + SSLOptions +StdEnvVars + + + BrowserMatch \"MSIE [2-6]\" \ + nokeepalive ssl-unclean-shutdown \ + downgrade-1.0 force-response-1.0 + # MSIE 7 and newer should be able to use keepalive + BrowserMatch \"MSIE [17-9]\" ssl-unclean-shutdown + + +" + +echo "$block" > "/etc/apache2/sites-available/$1.conf" +echo "$blockssl" > "/etc/apache2/sites-available/$1-ssl.conf" + +sudo a2dissite 000-default +sudo a2ensite $1 $1-ssl + +ps auxw | grep apache2 | grep -v grep > /dev/null + +sudo a2enmod ssl rewrite proxy proxy_fcgi +service apache2 restart + +if [ $? == 0 ] +then + service apache2 reload +fi \ No newline at end of file