Last active
March 9, 2016 15:27
-
-
Save dimitardanailov/760a508d325c1e66d4b8 to your computer and use it in GitHub Desktop.
Vagrant configuration for yii framework (CentOS)
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
| #!/usr/bin/env bash | |
| sudo yum -y update | |
| # Mysql | |
| # Source: https://webtatic.com/packages/mysql55/ | |
| sudo rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm | |
| # Source: http://serverfault.com/questions/588078/processing-conflict-mysql55w-libs-5-5-36-3-w6-x86-64-conflicts-mysql-libs-5-5 | |
| sudo yum install -y yum-plugin-replace | |
| sudo yum replace -y mysql-libs --replace-with mysql55w-libs | |
| sudo yum install -y mysql55w mysql55w-server | |
| # Apache 2 | |
| sudo yum install -y httpd | |
| # PHP | |
| # Source https://webtatic.com/packages/php53/ | |
| sudo rpm -Uvh http://mirror.webtatic.com/yum/centos/5/latest.rpm | |
| sudo yum --enablerepo=webtatic install -y php | |
| # Edit php.ini | |
| # Source: http://www.cyberciti.biz/faq/unix-linux-sed-match-replace-the-entire-line-command/ | |
| sudo sed -i 's/error_reporting = E_ALL & ~E_DEPRECATED/error_reporting = E_ALL/' /etc/php.ini | |
| sudo sed -i 's/display_errors = Off/display_errors = On/' /etc/php.ini | |
| sudo sed -i 's/display_startup_errors = Off/display_startup_errors = On/' /etc/php.ini | |
| sudo sed -i 's/track_errors = Off/track_errors = On/' /etc/php.ini | |
| sudo sed -i 's/html_errors = Off/html_errors = On/' /etc/php.ini | |
| # Enable mod_rewrite | |
| sudo sed -i 's/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf | |
| # http://docs.vagrantup.com/v2/getting-started/provisioning.html | |
| if ! [ -L /var/www/html ]; then | |
| rm -rf /var/www/html | |
| ln -fs /vagrant /var/www/html | |
| fi | |
| # Vim | |
| sudo yum install -y vim | |
| # Add Server name | |
| sudo sh -c 'echo "ServerName myworkstation" >> /etc/apache2/conf.d/servername.conf' | |
| # Install php mbstring library | |
| sudo yum install -y php-mbstring | |
| # Install php GD2 library | |
| sudo yum install -y gd gd-devel php-gd | |
| # Install php xml library | |
| sudo yum install -y php-xml | |
| # Install php mysql and pdo libraries | |
| sudo yum install -y php-pdo php-mysqli | |
| # Start MySQL service | |
| sudo service mysqld start | |
| # Turn on mysqld to start automatically on boot | |
| # Source: http://www.cyberciti.biz/faq/cant-connect-to-local-mysql-server-through-socket-varlibmysqlmysql-sock-2/ | |
| sudo chkconfig mysqld on | |
| #====================================== MySQL Config ======================================# | |
| # Create Database, User, set privileges and import the database | |
| DATABASE="dbName" | |
| USERNAME="dbUser" | |
| PASSWORD="dbPassword" | |
| # This is database export from production site. | |
| SQLFILE="/var/www/my_database.sql" | |
| mysql -u root -e "CREATE DATABASE IF NOT EXISTS $DATABASE | |
| CHARACTER SET utf8 COLLATE utf8_general_ci; | |
| GRANT ALL PRIVILEGES ON *.* TO $USERNAME@'%' IDENTIFIED BY '$PASSWORD'; | |
| GRANT ALL PRIVILEGES ON *.* TO $USERNAME@'localhost' IDENTIFIED BY '$PASSWORD'; | |
| FLUSH PRIVILEGES;" | |
| # Check if database is empty and import sql file | |
| QUERY="SELECT count(*) | |
| FROM information_schema.tables | |
| WHERE table_type = 'BASE TABLE' | |
| AND table_schema = '$DATABASE'" | |
| RESULT=$(mysql -u root -e "$QUERY") | |
| COUNT=`echo "$RESULT" | grep -o "[0-9]\+"` | |
| if [ "$COUNT" == "0" ]; then | |
| echo 'Import sql file. Please wait!' | |
| mysql -u root -e "USE $DATABASE; | |
| SOURCE $SQLFILE;" | |
| fi | |
| #====================================== END MySQL Config ======================================# | |
| # Finaly restart apache | |
| sudo apachectl restart |
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 : | |
| # All Vagrant configuration is done below. The "2" in Vagrant.configure | |
| # configures the configuration version (we support older styles for | |
| # backwards compatibility). Please don't change it unless you know what | |
| # you're doing. | |
| Vagrant.configure(2) do |config| | |
| # The most common configuration options are documented and commented below. | |
| # For a complete reference, please see the online documentation at | |
| # https://docs.vagrantup.com. | |
| # Every Vagrant development environment requires a box. You can search for | |
| # boxes at https://atlas.hashicorp.com/search. | |
| config.vm.box = "chef/centos-6.6" | |
| # The hostname the machine should have. Defaults to nil. | |
| # If nil, Vagrant won't manage the hostname. | |
| # If set to a string, the hostname will be set on boot. | |
| # http://docs.vagrantup.com/v2/vagrantfile/machine_settings.html | |
| config.vm.hostname = "myworkstation" | |
| # Disable automatic box update checking. If you disable this, then | |
| # boxes will only be checked for updates when the user runs | |
| # `vagrant box outdated`. This is not recommended. | |
| config.vm.box_check_update = false | |
| # 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. | |
| # http://docs.vagrantup.com/v2/getting-started/networking.html | |
| config.vm.network "forwarded_port", host: 4567, guest: 80 | |
| config.vm.network :forwarded_port, host: 6606, guest: 3306 | |
| # Create a private network, which allows host-only access to the machine | |
| # using a specific IP. | |
| # config.vm.network "private_network", ip: "192.168.33.10" | |
| # 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" | |
| # Share an additional folder to the guest VM. The first argument is | |
| # the path on the host to the actual folder. The second argument is | |
| # the path on the guest to mount the folder. And the optional third | |
| # argument is a set of non-required options. | |
| # config.vm.synced_folder "../data", "/vagrant_data" | |
| # Provider-specific configuration so you can fine-tune various | |
| # backing providers for Vagrant. These expose provider-specific options. | |
| # Example for VirtualBox: | |
| # | |
| # config.vm.provider "virtualbox" do |vb| | |
| # # Display the VirtualBox GUI when booting the machine | |
| # vb.gui = true | |
| # | |
| # # Customize the amount of memory on the VM: | |
| # vb.memory = "1024" | |
| # end | |
| # | |
| # View the documentation for the provider you are using for more | |
| # information on available options. | |
| # 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. | |
| # http://docs.vagrantup.com/v2/getting-started/provisioning.html | |
| config.vm.provision :shell, path: "bootstrap.sh" | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment