CentOs Vagrant Configuration file

  1. # -*- mode: ruby -*-
  2. Vagrant.configure("2") do |config|
  3.   config.vm.box = "centos/7"
  4.   config.vm.box_check_update = true
  5.  
  6.   # Any Port you want to forward
  7.   config.vm.network "forwarded_port", guest: 80, host: 8000
  8.   config.vm.network "forwarded_port", guest: 3306, host: 3307
  9.  
  10.   # Folder Mappings
  11.   # config.vm.synced_folder "../data", "/vagrant_data"
  12.   config.vm.synced_folder "/Users/janaki/MyApplications/Research", "/home/vagrant/public_html/apps"
  13.  
  14.   #Custom VM Settings
  15.   config.vm.provider "virtualbox" do |vb|
  16.   #   # Display the VirtualBox GUI when booting the machine
  17.   #   vb.gui = true
  18.   #
  19.   #   # Customize the amount of memory on the VM:
  20.      vb.memory = "3072"
  21.   end
  22.   #
  23.   #Shell Install
  24.   config.vm.provision "shell", inline: <<-SHELL
  25.    
  26.     # Install Apache Server
  27.     sudo yum install httpd -y
  28.     sudo systemctl start httpd.service
  29.     sudo systemctl enable httpd.service
  30.  
  31.     # Install common tools
  32.     sudo yum install nano -y
  33.     sudo yum install wget -y
  34.     sudo yum install net-tools -y
  35.    
  36.     cd /home/vagrant
  37.     mkdir public_html
  38.    
  39.     # Install PHP
  40.     sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  41.     sudo rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
  42.     sudo yum install php70w php70w-cli php70w-opcache
  43.  
  44.     # Install Webmin for GUI
  45.     cd /opt
  46.     sudo wget http://www.webmin.com/jcameron-key.asc
  47.     sudo wget  http://www.webmin.com/download/rpm/webmin-current.rpm
  48.     sudo yum -y install perl perl-Net-SSLeay openssl perl-IO-Ttysu
  49.     sudo rpm –import jcameron-key.asc
  50.     sudo rpm -Uvh webmin-*.rpm  
  51.  
  52.     # Configure home folder for apache
  53.     sudo setsebool -P httpd_enable_homedirs 1
  54.     sudo chown -R vagrant:apache public_html
  55.     sudo chmod -R 775 /home/vagrant/public_html
  56.     sudo chmod -R a+rX /home/vagrant/public_html
  57.     sudo chmod a+rx ~
  58.     sudo systemctl restart httpd.service      
  59.   SHELL
  60. end
0

About the author

Janaki(http://janakiranjan.com) - A Software developer with 9+ years of experience in multiple technology projects across web, mobile, and cloud applications with expertise in PHP, C#, MySQL, Web services and open source platforms.

Similar Posts

Comments are closed.