Skip to content

Instantly share code, notes, and snippets.

@ClaudioVarandas
Created May 30, 2017 14:04
Show Gist options
  • Save ClaudioVarandas/5dedafede964c0117a54d249a00d2ac3 to your computer and use it in GitHub Desktop.
Save ClaudioVarandas/5dedafede964c0117a54d249a00d2ac3 to your computer and use it in GitHub Desktop.
Vagrant centos lamp
#!/usr/bin/env bash
sudo yum -y update
sudo yum -y install epel-release
sudo yum -y install wget vim
setenforce 0
sed -i 's/SELINUX=\(enforcing\|permissive\)/SELINUX=disabled/g' /etc/selinux/config
###
### Apache
###
sudo yum -y install httpd
# allow overrides in /var/www/
sudo sed -i '/<Directory "\/var\/www">/,/<\/Directory>/ { s/AllowOverride None/AllowOverride All/i }' /etc/httpd/conf/httpd.conf
sudo sed -i "s#User apache#User vagrant#" /etc/httpd/conf/httpd.conf
sudo sed -i "s#Group apache#Group vagrant#" /etc/httpd/conf/httpd.conf
sudo systemctl start httpd.service
sudo systemctl enable httpd.service
###
### MariaDb
###
cat <<EOF | sudo tee -a /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.1 CentOS repository list
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF
sudo yum -y install mariadb-server
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo /usr/bin/mysqladmin -u root password 'root'
# allow remote access (required to access from our private network host. Note that this is completely insecure if used in any other way)
mysql -u root -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; FLUSH PRIVILEGES;"
# drop the anonymous users
mysql -u root -proot -e "DROP USER ''@'localhost';"
mysql -u root -proot -e "DROP USER ''@'$(hostname)';"
# drop the demo database
mysql -u root -proot -e "DROP DATABASE test;"
###
### PHP
###
sudo yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
sudo yum install yum-utils
sudo yum-config-manager --enable remi-php71
sudo yum -y update
sudo yum -y install php php-mcrypt php-common php-mysqlnd php-zip php-cli php-mbstring php-gd php-imagick php-xml php-opcache php-xdebug php-fpm
sudo sed -i "s#user apache#user vagrant#" /etc/php-fpm.d/www.conf
sudo sed -i "s#group apache#group vagrant#" /etc/php-fpm.d/www.conf
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
###
### Elasticsearch
###
cat <<EOF | sudo tee -a /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF
cat <<EOF | sudo tee -a /etc/yum.repos.d/kibana.repo
[kibana-5.x]
name=Kibana repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF
sudo yum -y install java elasticsearch kibana
sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch
sudo systemctl start kibana
sudo systemctl enable kibana
###
### Composer
###
curl -Ss https://getcomposer.org/installer | php
sudo mv composer.phar /usr/bin/composer
###
### Mailcatcher
###
sudo yum -y update
sudo yum -y install ruby ruby-devel sqlite sqlite-devel make gcc gcc-c++
sudo gem install mailcatcher --no-ri --no-rdoc
# ===================================================================
# Configure Environment
# ===================================================================
if [ ! -f /etc/httpd/conf.d/xxx.conf ]; then
cat >> /etc/httpd/conf.d/xxx.conf <<EOM
<VirtualHost *:80>
DocumentRoot /var/www/xxx/public
ServerName xxx.dev
ServerAlias xxx.dev
setenvif Authorization "(.*)" HTTP_AUTHORIZATION=$1
ErrorLog /var/log/httpd/xxxx_error.log
CustomLog /var/log/httpd/xxx_access.log combined
<Directory /var/www/xxx>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Require all granted
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
</Directory>
</VirtualHost>
EOM
fi
if [ ! -f /etc/httpd/conf.d/kibana.conf ]; then
cat >> /etc/httpd/conf.d/kibana.conf <<EOM
<VirtualHost *:80>
<Location />
ProxyPass http://localhost:5601/
ProxyPassReverse http://localhost:5601/
</Location>
</VirtualHost>
EOM
fi
sudo systemctl restart httpd
echo "##################################################"
echo " "
echo " add this line below to your /etc/hosts "
echo " 192.168.50.200 xxx.dev kibana.dev "
echo " "
echo " END! "
echo " "
echo "##################################################"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment