Setting-up-new-instance

From VPOIDS Documentation

Creating a new AFIDS instance

Set up the domain

In the domain registrar, set up a subdomain for vpoids .org to point to the new virtual host on this server, e.g. afw.vpoids.org.

Create a directory for the code

Create a directory in /var/www for the organization. Name the group using a reasonable abbreviation for the organization, e.g. Angel Flight West would be afw.

  • Command: mkdir /var/www/xxx

Create a virtual host

Do this through the Webmin control panel.

  • Create directory root using command shell (Other > Command Shell)

Execute command:

mkdir /var/www/xxx
mkdir /var/www/xxx/web
  • Servers > Apache Web Server > create virtual host
    • Any address
    • Document Root: /var/www/xxx/web
    • Server Name: domain.org

Edit the directives for the new virtual host:

DocumentRoot /var/www/xxx/web
DirectoryIndex index.php
ServerName domain.org
<Directory /var/www/xxx/web>
 Options FollowSymLinks
 AllowOverride All
 allow from all
 Options +Indexes
</Directory>
Alias /sf /var/www/xxx/web/sf
<Directory /var/www/xxx/web/sf>
 Options FollowSymLinks
 AllowOverride All
 Allow from All
</Directory>

After completing the host setup, reload the apache config. You can do this using the link in the webmin UI at the top right labeled Apply Changes.

Create database

Do this through the Webmin control panel (Servers > MySQL Database Server), or using the command line.

The database should be named xxx_afids using the abbreviation used above for the user, etc.

Create database user and add permissions (User Permissions > Create new user).

The user should be named xxx_afids_app using the abbreviation used above for the user, etc.

This will be the user which the AFIDS application uses to connect.

The user needs to have the following database permissions: localhost Select | Insert | Update | Delete | Show View | Execute

GRANT SELECT, INSERT, UPDATE, DELETE, SHOW VIEW, EXECUTE ON  xxx_afids.* TO 'xxx_afids_app'@'localhost';

Create the afids database schema

Load the new database with the schema. There is a schema file on the server which can be used for this purpose. Best to run this command from the command line:

mysql database_name < /var/www/import_data/afids_schema_ordered.sql -uroot -p
mysql database_name < /var/www/import_data/afids_schema_views.sql -uroot -p
mysql database_name < /var/www/import_data/afids_schema_routines.sql -uroot -p

Note: You will need the root password for the database to complete this command.

Import the data from common reference tables

Now, load in the data from the reference tables which are common to all organizations. This file is also located on the server and can be loaded from the command line.

mysql database_name < /var/www/import_data/ref_tables_1.sql -uroot -p
mysql database_name < /var/www/import_data/ref_tables_2.sql -uroot -p
mysql database_name < /var/www/import_data/ref_tables_3.sql -uroot -p
mysql database_name < /var/www/import_data/afw_afids_aircraft.sql -uroot -p
mysql database_name < /var/www/import_data/afw_afids_airport.sql -uroot -p
mysql database_name < /var/www/import_data/afw_afids_zipcode.sql -uroot -p
mysql database_name < /var/www/import_data/afw_afids_page_content.sql -uroot -p

Copy the application files

Copy symfony and app files. Using the AFW file set is a good choice of source.

  • Command: cp -r /var/www/afw/* /var/www/target

Change the owner of the directory to webmaster:

  • Command: chown -R webmaster /var/www/xxx

Create a user group

Create a group for each organization so that we can assign organization users to the group and permissions to their directory by group so they only have access to that folder.

Name the group using a reasonable abbreviation for the organization, same as for the directory so they match.

  • Command: groupadd afw

Add the www-data user to this group, which gives the application access to the directory.

Create linux user

Create a user and add them to the group. Note that this is not necessary unless an actual person is identified from the organization who will be accessing the system by ftp or ssh. No need to have more users on the system than necessary for security reasons.

Precede the name of the user with the abbreviation for the organization so we can easily see who belongs to what organization.

  • Command: useradd -G afw afw_joeblow
  • Command: passwd afw_joeblow

Change the user’s home directory

  • Command: usermod -d /path/to/new/homedir/ username

Set group permissions for the directory

This gives this user access to the directory with the instance files, but no others.

  • Command chgrp -R afw /var/www/afw

Modify permissions

Set the permissions for the directory. This allows the group to read, but no one else.

sudo chmod -R 0771 /var/www/xxx

Set permissions for subdirectories that require write access

  • sudo chmod -R 0777 /var/www/log
  • sudo chmod -R 0777 /var/www/cache
  • sudo chmod -R 0777 /var/www/web/uploads
  • sudo chmod -R 0755 /var/www/web/images

Leave the subdirectory structure, but remove the files from these directories:

  • bulk-email-attachments
  • mission_photo
  • mission_report
  • user_uploads

Update the organization specific files

Immediately: The most important file to update IMMEDIATELY is the /config/databases.yml. Until you change that, anything that's done in this instance will update the wrong database.

And complete the other customizations specified in the customization-checklist

Database updates

Run these statements against the database.

First, create a user so you can log in:

/* add the first person */
/* the password is test1234 */
insert into person (first_name, last_name, username, password)
VALUES ('Test', 'User', 'admin','16d7a4fca7442dda3ad93c9a726597e4');

Add the new roles to the system:

/* add the new roles */
INSERT INTO role (id, title, description) VALUES (26, '@Admin', 'Afids Administrator');
INSERT INTO role (id, title, description) VALUES (27, '@Pilot', 'Member');
INSERT INTO role (id, title, description) VALUES (28, '@Staff', 'Normal staff');
INSERT INTO role (id, title, description) VALUES (29, '@Coordinator', 'Coordinator');
INSERT INTO role (id, title, description) VALUES (30, '@Volunteer', 'Volunteer');
INSERT INTO role (id, title, description) VALUES (31, '@Member', 'Member');

/* alternative */
INSERT INTO role (id, title, description) VALUES (26, '@Admin', 'Afids Administrator'),(27, '@Pilot', 'Member'),(28, '@Staff', 'Normal staff'),(29, '@Coordinator', 'Coordinator'),(30, '@Volunteer', 'Volunteer'),(31, '@Member', 'Member');

Add the admin for the new user:

/* add roles for the new people */
insert into person_role (person_id, role_id) VALUES (1, 26);

Add a first mission to prevent errors when the application creates its first mission.

/* There needs to be a first mission to increment the external ID) */
insert into mission (mission_type_id, external_id) VALUES (1, 1000);

Add a member record with an external id, again so problems are not created when the application tries to create its first member

/* There needs to be a first member to increment the external ID) */
insert into member (person_id, member_class_id, external_id) VALUES (1,1,1000);