Created
January 19, 2015 22:47
-
-
Save ivanbarlog/8f9c5960b40251e040a1 to your computer and use it in GitHub Desktop.
Set up Symfony project in Ubuntu linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$EUID" -ne 0 ]; then | |
echo "Please run as root" | |
echo "Provide first argument which is path to project relative to /var/www/src/ folder" | |
echo "Provide second argument which is domain which will be added to hosts file (.dev is added automatically)" | |
exit | |
fi | |
#path | |
if [ -z "$1" ]; then | |
echo "Provide first argument which is path to project relative to /var/www/src/ folder" | |
exit | |
fi | |
#domain | |
if [ -z "$2" ]; then | |
echo "Provide second argument which is domain which will be added to hosts file (.dev is added automatically)" | |
exit | |
fi | |
# go to src | |
cd /var/www/src/ | |
if [ ! -d "./$1" ]; then | |
echo "Path '$1' not exists."; | |
exit | |
fi | |
mkdir -p $1/app/cache | |
mkdir -p $1/app/logs | |
HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1` | |
setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX $1/app/cache $1/app/logs | |
setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX $1/app/cache $1/app/logs | |
cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/$2.conf | |
sed -i -e "s/#ServerName www.example.com/ServerName $2.dev/g;s/\/var\/www\/html/\/var\/www\/http\/$2/g;s/.log/_$2.log/g" /etc/apache2/sites-available/$2.conf | |
a2ensite $2.conf | |
service apache2 reload | |
if ! grep -q $2 /etc/hosts; then | |
echo "127.0.0.1 $2.dev" >> /etc/hosts | |
fi | |
mkdir -p /var/www/http | |
cd /var/www/http | |
if [ -L $2 ]; then | |
rm $2 | |
fi | |
ln -s ../src/$1/web/ $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment