# Installation

### Step 1: Setup Development Environment

#### Install Apache 2 server, MySQL server, and PHP >= 7.1

Every developer has their own development environment preferences. Installing Apache and MySql are trivial and the ideal development environment will differ from one developer to another, so we consider it outside the scope of this tutorial.

If you are new to PHP web development, here are a few resources to point you in the right direction:

* Packaged Solutions (does everything for you, less configurable)
  * [Ampps](https://www.ampps.com/)
    * Easily change PHP versions
    * Lots of built-in features, but beware of code bloat!
  * [Wamp](http://www.wampserver.com/en/) (Recommended)
    * Smaller than Ampps
    * A little more configuration
* Packaged Virtual Machines (Easily create/destroy environments. Full control. A little more configuration.)
  * [VirtualBox](https://www.virtualbox.org/wiki/VirtualBox)
  * [VMware](https://my.vmware.com/web/vmware/downloads)
  * [Vagrant](https://www.vagrantup.com/)
    * Also requires [VirtualBox](https://www.virtualbox.org/wiki/VirtualBox)
* Do it yourself
  * [Apache 2](https://httpd.apache.org/download.cgi)
  * [MySql](https://www.mysql.com/downloads/)
  * [PHP](http://php.net/downloads.php)

#### Install Composer

Composer is PHP's package manager. Make sure it's installed before you proceeding.

```
# Verify installation
composer --version
```

[Download Composer](https://getcomposer.org/)

#### Git

We use git for source control. You'll need it installed too...

[Download Git](https://git-scm.com/downloads)

### Step 2: Configure hosts

#### Create Virtual Host

Depending on your development environment, the process of adding a virtual host will vary. Ampps offers a GUI, most other solutions will require [manually configuring apache](https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-16-04).

#### Localhost alias

Local SiteAdmin instances won't work with a url like `http://localhost/myproject` or `127.0.0.1/myproject`. You'll need to configure your operating system's `host` file to point a fake domain name to your virtual host.

**Windows**

```
# c:\Windows\System32\drivers\etc\hosts
127.0.0.1  myproject.app
```

### Step 3: Site Administrator install script

Though it's possible to manually install an instance of Site Administrator, we recommend using our installation script to simplify and speed up the process.

#### Download the install script

You can find the install script by signing into [eLink's internal Gitlab](https://git.elinkstaging.com). Click on the menu icon, then navigate to `Snippets -> Explore Snippets -> SA 3 Install`.

[Download Install Script](https://git.elinkstaging.com/snippets/8)

#### Upload the install script

Next, upload the install script to the root directory of your project.

#### Execute the script

The script is a simply PHP file. To execute it, navigate to the file from your browser. If our project's virtual host were called `myproject.app`, you would go to

```
http://myproject.app/sa.install.php
```

The install script will create a couple of directories, and install all the necessary core modules via composer.

### Step 4: Setup your database

We advise against using the `root` database user for all your SiteAdmin applications. Depending on your development environment, you can create a new database and corresponding user through a GUI (like phpMyAdmin) or directly through the command line.

**Command-Line**

If you're rusty on your SQL commands, [follow this tutorial](https://wiki.gandi.net/en/hosting/using-linux/tutorials/ubuntu/createdatabase) to create a database and user.

### Step 5: Configure SiteAdmin

Configuration files are initially created through the installer. Navigate to your project's siteadmin dashboard to complete this process.

```
http://myproject.app/siteadmin
```

### Step 6: Configure Environments

Configuration files will vary among developers, even for the same project. Copy the `{project_root}/siteadmin/config/config.php` file to `{project_root}/siteadmin/config/devConfig.php`.

Then register your custom configuration file & virtual host with the application.

{% code title="{project\_root}/siteadmin/config/environments.php" %}

```php
<?php
$environments = array(
  'production' => array(),
  'myproject.app' => array('configFile' => 'devConfig.php', 'devMode' => true, 'errorReporting' => true)
);
```

{% endcode %}

> Notice the index `myproject.app` is the same as the virtual host we configured for our project.

### Build something awesome

By now, the installation process is complete. Check out the [Getting Started](https://app.gitbook.com/s/-LB7PTje97ARlss-zn8u/getting-started/README.md#getting-started) section to learn guide you through building your next SA3 app!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.siteadministrator.com/getting-started/installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
