Skip to content

Instantly share code, notes, and snippets.

@kmassada
Last active March 7, 2018 21:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmassada/73678d48dcf6b23b6f0a to your computer and use it in GitHub Desktop.
Save kmassada/73678d48dcf6b23b6f0a to your computer and use it in GitHub Desktop.
centos7 LAMP bootstrap [vagrant]
#!/usr/bin/env bash
# centos7-mamp-bootstrap.sh
# this is an end to end LAMP setup on Centos7.
# this was originally written for Bootsrap.sh on Vagrant
#DATABASE_PW: root password to you db
DATABASE_PW=''
#DOMAIN: name of domain, used for ServerName in Apache
#DOMAIN_ROOT: htdocs, used for Document Root in Apache
DOMAIN="laravel4.dev"
DOMAIN_ROOT="$DOMAIN/public"
##@@APACHE
rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
yum update
yum install -y httpd
if ! [ -L /var/www ]; then
rm -rf /var/www
ln -fs /vagrant /var/www
fi
if [ ! -d /var/www/html/ ]; then
mkdir -p /var/www/html
fi
systemctl restart httpd
##@@MARIA
cat >> /etc/yum.repos.d/mariadb.repo << EOF
# MariaDB 10.0 CentOS repository list - created 2015-02-25 20:59 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF
rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
yum install -y mariadb-server
systemctl start mysql.service
mysql -u root <<-EOF
UPDATE mysql.user SET Password=PASSWORD('$DATABASE_PW') WHERE User='root';
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
DELETE FROM mysql.user WHERE User='';
DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%';
FLUSH PRIVILEGES;
EOF
##@@PHP
yum -y install php
yum -y install php-mysql
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-mcrypt
systemctl restart httpd.service
##@@TOOLS
yum -y install curl git
cd /opt
git clone https://github.com/drush-ops/drush.git
mkdir composer
cd composer
curl -sS https://getcomposer.org/installer | php -d suhosin.executor.include.whitelist=phar #PUT IN PHP.INI
cd ../drush
php -d suhosin.executor.include.whitelist=phar /opt/composer/composer.phar install
ln -s /opt/drush/drush /usr/bin/drush
ln -s /opt/composer/composer.phar /usr/bin/composer
##@@PROJECT
DATA="<VirtualHost *>
ServerName $DOMAIN
ServerAlias www.$DOMAIN
#### This is where you put your files for that domain: /var/www/vhosts/$DOMAIN
DocumentRoot /var/www/vhosts/$DOMAIN_ROOT
<Directory /var/www/vhosts/$DOMAIN_ROOT>
# This section sets directives for the directory.
# -Indexes <-- That blocks index listings on folders that don't have a default file (index.php/index.html/default.html/etc)
# FollowSymLinks <-- This will treat symlinks like they should be treated in linux: as folders/files in the folder the symlink resides
# MultiViews <--It's easier for you to read this: http://httpd.apache.org/docs/2.0/content-negotiation.html#multiviews
Options Indexes FollowSymLinks MultiViews
# AllowOverride All <-- This is required for Apache HTTPD server to read .htaccess files. It says that you can have a per-folder override for apache directives
AllowOverride All
</Directory>
## Everything to see here. Just the log files. Good to use for troubleshooting errors.
CustomLog /var/log/httpd/$DOMAIN-access.log combined
ErrorLog /var/log/httpd/$DOMAIN-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
</VirtualHost>"
if [ ! -f /etc/httpd/conf.d/$DOMAIN.conf ]; then
mkdir -p /var/www/vhosts/$DOMAIN/public
echo "$DATA" > /etc/httpd/conf.d/$DOMAIN.conf && service httpd restart
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment