apache2 drupal

Apache2 drupal

/etc/apache2/sites-available/do_not_change.local.conf

 

<VirtualHost do_not_change.localhost>
  DocumentRoot /var/www/do_not_change/do_not_change-manager/web
  ServerName do_not_change.localhost
  ServerAlias do_not_change.local
  ErrorLog ${APACHE_LOG_DIR}/do_not_change_error.log
  LogLevel debug
  CustomLog ${APACHE_LOG_DIR}/do_not_change_access.log combined
  <IfModule mpm_itk_module>
    AssignUserId utilisateur www-data
  </IfModule>
  <Directory /var/www/do_not_change/do_not_change-manager/web>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
  </Directory>
  <FilesMatch \.php$>
      # Apache 2.4.10+ can proxy to unix socket
      #SetHandler "proxy:unix:/var/run/php/php5.6-fpm.sock|fcgi://localhost/"
      SetHandler "proxy:unix:/var/run/php/php7.1-fpm.sock|fcgi://localhost/"
  </FilesMatch>
</VirtualHost>

 

#!/bin/bash
drupalsite=$1
origdir=`pwd`
version=8.8.1
#CHANGE THE USERNAME from j to your username.
u=`whoami`
#DEFAULT PASSWORD FOR THE MYSQL USER.
motdepasse="password";

if [[ -z "$2" ]]; then
  echo "To enable script debug mode uncomment '#set -x' (remove the # symbol)";	
  sleep 3
  #debug
  #set -x
fi

if [[ -n "$1" ]]; then
  echo "Create a website by the name of ${1}.local"
elif [[ -z "$1" ]]; then
  echo "Please specify the site name."
  echo "example: sudo ./create_drupal_site.sh sitename";
  exit;
fi


sudo cp /etc/apache2/sites-available/do_not_change.local.conf /etc/apache2/sites-available/${drupalsite}.local.autogenerated.conf
cd /etc/apache2/sites-enabled
sudo ln -s ../sites-available/${drupalsite}.local.autogenerated.conf ${drupalsite}.local.autogenerated.conf
cd /etc/apache2/sites-available
sudo sed -i -e "s/do_not_change/${drupalsite}/g" ${drupalsite}.local.autogenerated.conf
sudo sed -i -e "s/utilisateur/${u}/g" ${drupalsite}.local.autogenerated.conf
LINE="127.0.0.1 ${drupalsite}.local"
FILE='/etc/hosts'

sudo chmod 666 /etc/hosts
grep -qF -- "$LINE" "$FILE" || echo "$LINE" >> "$FILE"
sudo chmod 644 /etc/hosts

sudo service apache2 restart

echo "The script creates a db called ${drupalsite}"
echo "mysql-uroot -p #if you run this script as sudo you won't need to enter a password. "
alter="ALTER DATABASE ${drupalsite} CHARACTER SET utf8 COLLATE utf8_general_ci;"

mysql -uroot -p$motdepasse -e "create database if not exists ${drupalsite} CHARACTER SET utf8 COLLATE utf8_general_ci"
#mysql -uroot -p --database=${drupalsite} -e $alter;
creer_utilisateur="CREATE USER '${drupalsite}'@'localhost' IDENTIFIED BY '${motdepasse}';"
mysql -uroot -p$motdepasse --database=${drupalsite} -e "$creer_utilisateur";
privileges="GRANT ALL PRIVILEGES ON ${drupalsite}.* to '${drupalsite}'@'localhost';FLUSH PRIVILEGES;"
mysql -uroot -p$motdepasse --database=${drupalsite} -e "$privileges";

echo "sudo mkdir -p /var/www/${drupalsite}/${drupalsite}-manager"
[[ -d /var/www/${drupalsite}/${drupalsite}-manager ]] || sudo mkdir -p /var/www/${drupalsite}/${drupalsite}-manager

echo "A restart is necessary to pick up the new vhost"
sudo service apache2 restart
cd /var/www/${drupalsite}
sudo chown ${u}:www-data /var/www/${drupalsite} -R
if [ ! -f drupal-${version}.tar.gz ]; then
  wget https://ftp.drupal.org/files/projects/drupal-${version}.tar.gz
fi
cd /var/www/${drupalsite}/${drupalsite}-manager
tar -pxzf ../drupal-${version}.tar.gz
#drupal-${version}.tar.gz
mv drupal-${version} web
cd web
sudo chown ${u}:www-data /var/www/${drupalsite} -R
sudo chmod 775 /var/www/${drupalsite} -R
composer install


echo "sudo mkdir -p /var/www/${drupalsite}/${drupalsite}-manager/web/sites/default/files"
[[ -d /var/www/${drupalsite}/${drupalsite}-manager/web/sites/default/files ]] || sudo mkdir -p /var/www/${drupalsite}/${drupalsite}-manager/web/sites/default/files

cp /var/www/${drupalsite}/${drupalsite}-manager/web/sites/default/default.settings.php /var/www/${drupalsite}/${drupalsite}-manager/web/sites/default/settings.php
sudo chmod 775 /var/www/${drupalsite}/${drupalsite}-manager/web/sites/default/files
sudo chmod 664 /var/www/${drupalsite}/${drupalsite}-manager/web/sites/default/settings.php

sudo chown ${u}:www-data /var/www/${drupalsite} -R
#echo "Bonjour" >> /var/www/${drupalsite}/${drupalsite}-manager/web/index.html

echo "";
echo "Site ready: http://${drupalsite}.local"

cd $origdir;

 

 

Commentaires

missing composer dependency, apt-get install composer

set up .bash_aliases

edit the mysql password in the script

created scripts folder with owner:group permissions, created script with 755 execute perms

also going to need MAX_ALLOWED_PACKET at 32MB or 64MB or so

and increase php.ini memory limit and other limits.

 

drupal/core 8.8.0 requires ext-dom * -> the requested PHP extension dom is missing from your system

 

Troubleshooting: change the password from password to whatever your password is