Last active
October 19, 2015 06:41
-
-
Save fquffio/7d7adf4f2b7fd3f44c2b to your computer and use it in GitHub Desktop.
Basic LAMP setup on Vagrant.
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
#!/usr/bin/env bash | |
# Common operations | |
export DEBIAN_FRONTEND=noninteractive | |
echo -e "\n--- Setting up environment... ---\n" | |
apt-get update -qq | |
locale-gen de_DE.UTF-8 fr_FR.UTF-8 it_IT.UTF-8 > /dev/null 2>&1 | |
# Basic web server setup | |
echo -e "\n--- Installing LAMP stack... ---\n" | |
debconf-set-selections <<< 'mysql-server mysql-server/root_password password root' | |
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root' | |
apt-get install -y -qq \ | |
apache2 \ | |
libapache2-mod-php5 \ | |
mysql-server \ | |
php5 | |
mysql_install_db > /dev/null 2>&1 | |
# Apache settings | |
echo "# Vagrant configuration | |
ServerName $(hostname -f) | |
User vagrant | |
Group vagrant | |
<Directory /var/www/html> | |
Options Indexes FollowSymLinks | |
AllowOverride All | |
Require all granted | |
</Directory> | |
<Directory /vagrant> | |
Options Indexes FollowSymLinks | |
AllowOverride All | |
Require all granted | |
</Directory>" > /etc/apache2/conf-available/vagrant.conf | |
a2enconf vagrant > /dev/null 2>&1 | |
a2enmod rewrite > /dev/null 2>&1 | |
# PHP extensions | |
apt-get install -y -qq \ | |
php5-curl \ | |
php5-gd \ | |
php5-imagick \ | |
php5-intl \ | |
php5-json \ | |
php5-mcrypt \ | |
php5-mysql \ | |
php5-pgsql \ | |
php5-sqlite \ | |
php5-xdebug | |
php5enmod mcrypt > /dev/null 2>&1 | |
echo ' | |
xdebug.idekey="vagrant" | |
xdebug.remote_host=192.168.90.1 | |
xdebug.remote_enable=1 | |
xdebug.remote_autostart=1 | |
xdebug.remote_handler="dbgp"' >> /etc/php5/cli/conf.d/20-xdebug.ini | |
service apache2 restart > /dev/null 2>&1 | |
# PhpMyAdmin | |
echo -e "\n--- Installing PhpMyAdmin... ---\n" | |
debconf-set-selections <<< 'phpmyadmin phpmyadmin/dbconfig-install boolean true' | |
debconf-set-selections <<< 'phpmyadmin phpmyadmin/mysql/admin-pass password root' | |
debconf-set-selections <<< 'phpmyadmin phpmyadmin/mysql/app-pass password phpmyadmin' | |
debconf-set-selections <<< 'phpmyadmin phpmyadmin/app-password-confirm password phpmyadmin' | |
debconf-set-selections <<< 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2' | |
apt-get install -y -qq phpmyadmin | |
# Composer | |
echo -e "\n--- Installing Composer... ---\n" | |
wget -q https://getcomposer.org/composer.phar | |
chmod a+x composer.phar | |
mv composer.phar /usr/local/bin/composer | |
# Database | |
if [ -s /vagrant/vagrant/setup.sql ] | |
then | |
echo -e "\n--- Creating default databases and users... ---\n" | |
mysql -uroot -proot < /vagrant/vagrant/setup.sql | |
fi | |
# Webroot | |
echo -e "\n--- Concluding installation... ---\n" | |
rm -rf /var/www/html | |
ln -s /vagrant/webroot /var/www/html | |
service apache2 restart > /dev/null 2>&1 |
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
CREATE DATABASE `project_dev`; | |
CREATE DATABASE `project_test`; | |
CREATE USER 'project'@'localhost' IDENTIFIED BY 'project'; | |
GRANT ALL PRIVILEGES ON `project\_%`.* TO 'project'@'localhost'; | |
FLUSH PRIVILEGES; |
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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure(2) do |config| | |
# Every Vagrant development environment requires a box. You can search for | |
# boxes at https://atlas.hashicorp.com/search. | |
config.vm.box = "ubuntu/trusty64" | |
# Create a forwarded port mapping which allows access to a specific port | |
# within the machine from a port on the host machine. In the example below, | |
# accessing "localhost:8080" will access port 80 on the guest machine. | |
# config.vm.network "forwarded_port", guest: 80, host: 8080 | |
# Create a private network, which allows host-only access to the machine | |
# using a specific IP. | |
config.vm.network "private_network", ip: "192.168.90.10" | |
config.vm.hostname = "project" | |
# Create a public network, which generally matched to bridged network. | |
# Bridged networks make the machine appear as another physical device on | |
# your network. | |
# config.vm.network "public_network" | |
# Provider-specific configuration so you can fine-tune various | |
# backing providers for Vagrant. These expose provider-specific options. | |
config.vm.provider "virtualbox" do |vb| | |
vb.name = "Project" | |
vb.customize [ | |
"modifyvm", :id, | |
"--groups", "/Vagrant" | |
] | |
# Display the VirtualBox GUI when booting the machine | |
# vb.gui = true | |
# Customize the amount of memory on the VM: | |
vb.memory = "2048" | |
end | |
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies | |
# such as FTP and Heroku are also available. See the documentation at | |
# https://docs.vagrantup.com/v2/push/atlas.html for more information. | |
# config.push.define "atlas" do |push| | |
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" | |
# end | |
# Enable provisioning with a shell script. Additional provisioners such as | |
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the | |
# documentation for more information about their specific syntax and use. | |
config.vm.provision "setup", type: "shell", path: "vagrant/setup.sh" | |
config.vm.provision "composer", type: "shell", privileged: false, inline: <<-SHELL | |
echo -e "\n--- Installing PHP development tools... ---\n" | |
composer global require --no-ansi \ | |
"phpunit/phpunit=4.*" \ | |
"squizlabs/php_codesniffer" \ | |
"phpmd/phpmd" | |
echo 'PATH="$HOME/.composer/vendor/bin:\$PATH"' >> ~/.profile | |
SHELL | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment