arfink / BISS-TEA

Beverage Industry Sign Shop - Tracking Expense Accounts
2 stars 0 forks source link

Create Development Environment #11

Closed jared-skinner closed 8 years ago

jared-skinner commented 8 years ago

After a few hours of fighting with otto, i think I am just going to set up a minimal development environment and generate a script for easy installation.

Operating System: Centos - minimal Server: Nginx RDBMS: MariaDB Server Side Scripting: PHP

jared-skinner commented 8 years ago

I have a development environment up an running, I will be posting a repo with relevant files and an install script. I just want to go through the install process a couple more times and make sure the script actually works before releasing it into the wild...

You will need to grab a copy of centos-minimal and install it via virtualbox.

jared-skinner commented 8 years ago

Dev. Environment Instructions

Please read the walk through carefully. I hope this works well :).

Prerequisites

You will need virtual box. There aren't really any other requirements...

Installation

The files development_vm.ova and dev_checksum.txt can be grabbed from:

dev_checksum.txt

development_vm.ova

1 Download and verify the download using the checksum.

2 Open up virtual box

3 Go to file -> Import Appliance

4 Browse to development_vm.ova

5 Click next then import.

6 Select the vm in the virtual box control panel.

7 Click Settings and select Network

8 make sure Attached to is set to Bridged Adapter

9 choose an adapter in the field below Attached to

OS

The OS used is CentOS

CentOS is basically a clone of fedora, so it is great for server stuff. If you need to install anything, yum is the package manager. The command works like sudo yum install <package name>

There are two users you should be aware of:

user: root
password: waterfall

user: dev
password: agile

Additional software installed:

To see what config files I added, check out /etc/php-fpm.d/

To see what config files I added, check out /etc/nginx/config.d/. nginx is pointed to /usr/share/BISS-TEA. I have an up to date copy of our repo sitting in there. root owns this folder, so it may be a pain to edit. See below for my thoughts on workflow.

I created three users and one database:

    user: root
    password: waterfall

    user: dev
    password: agile

    user: php
    password: password

    database: biss

php has access to biss already, so all you need to do is connect and use. I am working on some sql functionality. dev should be used for connecting to the sql server from the host machine, root is barred from doing that.

Also, we are going to need a way to sync databases so changes for one person don't break everything for everyone else.

Workflow

With the way things are setup, my though is as follows (not my suggestions are for linux, if anyone is using windows, let me know and I will give you instructions for that):

1 install sshfs in the host OS

2 create a dev folder where you want the project to live

3 use the following command to mount the biss folder on the host mach

    sshfs root@<vm ip addr>:/usr/share/BISS-TEA <dev folder>

Now you can make your changes locally and use git locally!

jared-skinner commented 8 years ago

@arfink @Sanjurjo7:

We has development vm!

jared-skinner commented 8 years ago

@arfink @Sanjurjo7

Upgrading to php 5.5

The newest updates to the site including using password hashing. This functionality comes with php 5.5 which centos won't grab because centos likes old stuff...

Below is the code up update the vm to use php 5.5. I gave it a try with a fresh copy of the dev environment and it worked without issue.

Please back up your vm before upgrading, just in case something goes terribly wrong!

Instructions

#!/bin/sh

# stop services
service php-fpm stop
service nginx stop

# get rid of php 5.4
yum -y remove php*

# Add rpms
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

# install php 5.5
yum -y install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_64 php55w-fpm.x86_64

# change persission on session folder so session variables keep on working
chown apache -R /var/lib/php/session
chgrp apache -R /var/lib/php/session

# switch from using sockets since those broke with the upgrade...
sed 's/\/var\/run\/php5-fpm.socket/127.0.0.1:9000/' </etc/php-fpm.d/socket.conf >/etc/php-fpm.d/socket.conf_new
mv /etc/php-fpm.d/socket.conf /etc/php-fpm.d/socket.conf_bak
mv /etc/php-fpm.d/socket.conf_new /etc/php-fpm.d/socket.conf
rm /etc/php-fpm.d/socket.conf_bak

sed 's/unix:\/var\/run\/php5-fpm.socket/127.0.0.1:9000/' </etc/nginx/conf.d/php-fpm.conf >/etc/nginx/conf.d/php-fpm.conf_new
mv /etc/nginx/conf.d/php-fpm.conf /etc/nginx/conf.d/php-fpm.conf_back
mv /etc/nginx/conf.d/php-fpm.conf_new /etc/nginx/conf.d/php-fpm.conf
rm /etc/nginx/conf.d/php-fpm.conf_back

# restart services
service php-fpm start
service nginx start