Every now and again, you get the urge to try something new. Drupal is the project for today. The goal is to create an automated script to install Drupal on a fresh and minimal install of CentOS 6. Here is an automated scripted install for Drupal and drush, a command line supplement, on CentOS6/RHEL6 Linux.
The script is not all exhaustive and doesn’t take into accounts a MySQL password or MySQL hardening. Just a quick script to get things running rather quickly, preferably on a development environment. It does take into consideration SELinux. There are many scripts offered on the net that do not incorporate SELinux, however, requires changing file and directory permissions to 666 and 777 respectively. After repeated testing of this script with minor adjustments made throughout the process, I have removed the chmod commands and added the chcon command to adjust the SELinux context. A permanent resolution to chcon does not appear to be needed as the initial goal of installation has been achieved without error or warning. Without further ado, here is that script.
#!/bin/bash # Install Drupal and drush # Minimal requirements: MySQL 5.015 PHP 5.2.5 Apache 2.x # Drupal needs: php-mbstring php-gd php-xml # drush needs: php-pear yum -y install mysql-server httpd php php-mysql php-mbstring php-gd php-xml php-pear chkconfig mysqld on && service mysqld start # Clean URLS pre-requisite sed -i "/^<Directory \"\/var\/www\/html\">/,/^<\/Directory>/{s/AllowOverride None/AllowOverride All/g}" /etc/httpd/conf/httpd.conf chkconfig httpd on && service httpd start # MySQL Consider changing values from drupaldb, drupaluser, and password echo "CREATE DATABASE drupaldb CHARACTER SET utf8 COLLATE utf8_general_ci;" | mysql echo "CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY 'password';" | mysql echo "GRANT ALL PRIVILEGES ON drupaldb.* TO 'drupaluser'@'localhost';" | mysql echo "FLUSH PRIVILEGES;" | mysql # Drupal cd /var/www/html curl -O http://ftp.drupal.org/files/projects/drupal-7.39.tar.gz tar --strip-components=1 -zxvf drupal-7.39.tar.gz /bin/rm drupal-7.39.tar.gz # Drupal Configuration /bin/cp /var/www/html/sites/default/default.settings.php /var/www/html/sites/default/settings.php #chmod 666 settings.php #chmod 777 $(pwd) # Drupal Permissions and Context chown -R apache:apache /var/www/html chcon -R -t httpd_sys_rw_content_t /var/www/html/sites/ # Firewall Rules iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT service iptables save service iptables restart # Install Drush pear channel-discover pear.drush.org pear install drush/drush
Source(s)
https://www.rosehosting.com/blog/how-to-install-drupal-on-centosfedora/
https://www.drupal.org/project/drupal
https://www.drupal.org/documentation/install/download#drush
https://www.digitalocean.com/community/tutorials/how-to-install-drupal-on-a-virtual-server-running-centos-6–2
https://www.rosehosting.com/blog/how-to-install-drupal-7-on-centos-7-with-nginx-mariadb-and-php-fpm/
https://www.drupal.org/node/2132447