Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Pimcore #634

Merged
merged 2 commits into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions resources/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions resources/localized/aliases
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
93 changes: 93 additions & 0 deletions scripts/serve-pimcore.sh
Original file line number Diff line number Diff line change
@@ -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="<VirtualHost *:$3>
ServerName $1
ServerAlias *.$1

DocumentRoot $2
<Directory $2>
AllowOverride All
Require all granted
</Directory>

# 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
<FilesMatch \.php$>
SetHandler \"proxy:unix:/var/run/php/php$5-fpm.sock|fcgi://localhost\"
</FilesMatch>

ErrorLog \${APACHE_LOG_DIR}/$1-error.log
CustomLog \${APACHE_LOG_DIR}/$1-access.log combined
</VirtualHost>
"

blockssl="<IfModule mod_ssl.c>
<VirtualHost *:$4>
ServerName $1
ServerAlias *.$1

DocumentRoot $2
<Directory $2>
AllowOverride All
Require all granted
</Directory>

# 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
<FilesMatch \.php$>
SetHandler \"proxy:unix:/var/run/php/php$5-fpm.sock|fcgi://localhost\"
</FilesMatch>

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

<FilesMatch \"\.(cgi|shtml|phtml|php)$\">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>

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
</VirtualHost>
</IfModule>
"

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