Last active
October 22, 2017 23:15
-
-
Save miguelcostero/28bc554b3d11d346943f54a4872abd22 to your computer and use it in GitHub Desktop.
Ubuntu 16.04 LTS server, Apache 2 PHP 7 MySQL 5.6
This file contains hidden or 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 : | |
VAGRANTFILE_API_VERSION = '2' | |
@script = <<SCRIPT | |
# Script Configuration | |
WEBSITENAME="WEBSITE_NAME_HERE" | |
MYSQL_PASSWORD="MYSQL_ROOT_USER_PASSWORD" | |
# Install dependencies | |
apt-get update && apt-get upgrade | |
apt-get install -y apache2 git curl php7.0 php7.0-bcmath php7.0-bz2 php7.0-cli php7.0-curl php7.0-intl php7.0-json php7.0-mbstring php7.0-opcache php7.0-soap php7.0-sqlite3 php7.0-xml php7.0-xsl php7.0-zip libapache2-mod-php7.0 rpl zsh htop | |
# Configure Apache | |
echo "<VirtualHost *:80> | |
DocumentRoot /var/www/$WEBSITENAME | |
AllowEncodedSlashes On | |
SetEnv APPLICATION_ENV "development" | |
<Directory /var/www/$WEBSITENAME> | |
Options +Indexes +FollowSymLinks | |
DirectoryIndex index.php index.html | |
Order allow,deny | |
Allow from all | |
AllowOverride All | |
</Directory> | |
ErrorLog /error.log | |
CustomLog /access.log combined | |
</VirtualHost>" > /etc/apache2/sites-available/$WEBSITENAME.conf | |
a2ensite $WEBSITENAME | |
a2enmod rewrite | |
service apache2 restart | |
# Enable Ubuntu Firewall and allow SSH & MySQL Ports | |
ufw enable | |
ufw allow 22 | |
ufw allow 3306 | |
# Install MySQL Server in a Non-Interactive mode. Default root password will be "root" | |
debconf-set-selections <<< 'mysql-server mysql-server/root_password password $MYSQL_PASSWORD' | |
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password $MYSQL_PASSWORD' | |
apt-get -y install mysql-server | |
# # Run the MySQL Secure Installation wizard | |
# mysql_secure_installation | |
# sed -i 's/127\.0\.0\.1/0\.0\.0\.0/g' /etc/mysql/my.cnf | |
# mysql -uroot -p -e 'USE mysql; UPDATE `user` SET `Host`="%" WHERE `User`="root" AND `Host`="localhost"; DELETE FROM `user` WHERE `Host` != "%" AND `User`="root"; FLUSH PRIVILEGES;' | |
service mysql restart | |
# Install composer | |
if [ -e /usr/local/bin/composer ]; then | |
/usr/local/bin/composer self-update | |
else | |
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | |
fi | |
echo "** Dependecies installed successfully" | |
echo "** Visit http://localhost:5151 in your browser for to view the application **" | |
SCRIPT | |
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | |
config.vm.box = 'ubuntu/xenial64' | |
config.vm.network "forwarded_port", guest: 80, host: 5151 | |
config.vm.network "forwarded_port", guest: 3306, host: 5252 | |
config.vm.network :private_network, ip: "192.168.10.50" | |
config.vm.synced_folder '.', '/var/www/WEBSITE_NAME_HERE' | |
config.vm.provision 'shell', inline: @script | |
config.vm.provider "virtualbox" do |vb| | |
vb.customize ["modifyvm", :id, "--memory", "1024"] | |
vb.customize ["modifyvm", :id, "--name", "Ubuntu 16.04 - LAMP"] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment