- If you haven't before, follow these instructions to get set up in Amazon EC2.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/get-set-up-for-amazon-ec2.html
- Follow these instructions to launch a new Amazon EC2 Instance. Use the Ubuntu AMI: Ubuntu Server 14.04 LTS (HVM) and the m3.medium instance type. As part of this process, you'll download a .pem file, which you'll need to connect to the instance.
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-instance_linux.html
- Connect to the instance by opening a terminal in the same directory as the .pem file you saved in step 2 and typing this command, replacing
xxx.pem
with the name of your .pem file, andxxx.amazonaws.com
with the public DNS name of your server, which is available on the EC2/Instances dashboard page.
ssh -v -i xxx.pem [email protected]
Now refresh your package index and set up the LAMP stack (Linux, Apache, MySQL, PHP) on the new server. You will be asked to set a root MySQL password as part of this process, don't forget it!
sudo apt-get update
sudo apt-get install lamp-server^
More details are available on the Ubuntu site: https://help.ubuntu.com/community/ApacheMySQLPHP
- Install git on the new server as well:
sudo apt-get install git
- Get the application code from GitHub.
git clone https://github.com/asiafoundation/afs.git
This will pull the application code into a folder named afs. If you've already cloned the repository and just want to update the code, cd into the repository's folder and pull the new code:
cd afs
git pull origin master
- Make the default configuration files active.
cp ~/afs/app/config/app.php.default ~/afs/app/config/app.php
cp ~/afs/app/config/database.php.default ~/afs/app/config/database.php
- Log in to MySQL.
mysql -u root -p
Here's where you'll use the MySQL password you created in step 3.
- You're now logged into MySQL and should see a
mysql>
prompt. Create a database with this command.
CREATE DATABASE asia_foundation_survey;
And create a user that the application can use to connect to the database with these commands. The user's password is the string following IDENTIFIED BY.
CREATE USER 'afs_user'@'localhost' IDENTIFIED BY 'unguessable-password';
GRANT ALL ON asia_foundation_survey.* TO 'afs_user'@'localhost';
To leave MySQL, enter
QUIT;
- Add information about the database to the file afs/app/config/database.php
vi ~/afs/app/config/database.php
(I'm using vi as an example, you can use whatever text editor you like)
In that file, you'll see lines that look something like this:
'mysql' => array(
...
'database' => 'asia_foundation_survey',
'username' => 'username_here',
'password' => 'password_here',
...
),
Replace the contents of those lines with the details of the database and user you created.
'mysql' => array(
...
'database' => 'asia_foundation_survey',
'username' => 'afs_user',
'password' => 'unguessable-password',
...
),
- The app needs two directories to be writable. Make that change with these commands.
chmod -R +w ~/afs/app/storage
chmod -R +w ~/afs/app/modules
- Create a couple more directories, for PHP plug-in dependencies.
mkdir ~/afs/app/gateways
mkdir ~/afs/app/repositories/eloquent
- Confirm that you're in the application's directory and install Composer, a PHP dependency manager https://getcomposer.org/
cd ~/afs
curl -sS https://getcomposer.org/installer | php
- Install and configure Mcrypt, a required PHP extension.
sudo apt-get install php5-mcrypt
sudo php5enmod mcrypt
- Use composer to install and update the plug-ins that the application needs
php composer.phar update
- Now you can install the application using Avelca.
./avelca_install.sh
- Edit a new file called afs.conf in Apache's sites-available directory, and copy the contents of the attached file there.
sudo vi /etc/apache2/sites-available/afs.conf
- Disable the default site and enable your new site, then restart Apache.
sudo a2dissite 000-default
sudo a2ensite afs
sudo /etc/init.d/apache2 restart
- Change permissions on the storage directory so the application can write there.
chmod -R 777 ~/afs/app/storage
- Open a web browser and navigate to http://xxx.amazonaws.com/install