# Installation Guide

> Install Advanzo CRM on your own server: requirements, PHP and database setup, document root, cron and queues. For Enterprise on-premise deployments.

Advanzo CRM comes with a built-in, user-friendly web installer. It makes the installation simple: you do not need to modify code or change files, so you can install it even with little technical experience.

## Key Installation Aspects

- **Built on Laravel**: Advanzo CRM is developed using Laravel.
- **Subdomain Installation**: The best way to install Advanzo CRM is on a subdomain, because Laravel requires the application's root to point to the `/public` path. When you set up your subdomain, make sure it points directly to the `/public` folder.

> **Warning:** Before you start the installation, review the [system requirements](https://www.advanzo.ch/docs/sections/basics) to make sure that your server environment is compatible with Advanzo CRM.

## Create a Subdomain

> **Danger:** Important: Make sure that the document root path of your subdomain is set to the `/public` directory. The application does not work correctly otherwise.

Your Advanzo CRM installation requires a dedicated subdomain. Here is how to create it, using the domain `crm.example.com` and cPanel as an example:

1. **Access cPanel**:

    - Log in to your cPanel dashboard on your hosting provider's login page.
2. **Locate Subdomains**:

    - In the cPanel interface, find and click the `Subdomains` section.
3. **Create Your Subdomain**:

    - In the **Subdomain** field, enter `crm`.
    - **Crucial Step**: For the Document Root, enter the path to the `public` directory. The application needs this to work properly.
    - Click the `Create` button to create your subdomain.

## Upload Files

> **Danger:** Important: Advanzo CRM requires a correctly set up subdomain, as explained in the previous step. Installation in a subfolder without a proper virtual host configuration will not work. If you are installing in a subfolder, ask your hosting provider to create a virtual host with the root path set to `path/to/subfolder/public`.

Before you can start the Advanzo CRM web installer, you need the application files:

1. **Download Release Archive**:

    - Use the release archive you received from the Advanzo team for your Enterprise licence.
2. **Prepare for Upload**:

    - Assume you have a subdomain named "crm" with the path `public_html/crm/`.
    - Make sure you know the correct path to which the files must be uploaded.
3. **Upload Files to Server**:

    - Using your preferred FTP client or the cPanel File Manager, upload the Advanzo CRM files to the `public_html/crm` directory on your server.

## Create Database

> **Info:** 

Create a dedicated database for your Advanzo CRM installation. Here is how to create it, using cPanel as an example:

1. **Access cPanel**:

    - Go to `www.example.com/cpanel` and log in.
2. **Navigate to Databases**:

    - In the cPanel dashboard, locate the `Databases` section and click on **MySQL Databases**. Note:
    - The location of this option might differ depending on your hosting provider.
3. **Create a New Database**:

    - Click **Create Database**. Once created, the database is listed in the `Current Databases` section.
4. **Create a Database User**:

    - Create a new user and assign a secure password. Note down the username and password, as you will need them during the installation.
5. **Assign User to Database**:

    - Link the new user to your database by selecting both the database and the username. Make sure you grant **All Privileges** to this user.

## Perform Install

Once you have created the subdomain, set up the database and uploaded the files, you are ready to install. Follow these steps to install Advanzo CRM:

1. **Access Installation URL**:

    - Open `https://crm.example.com/install` in your web browser. Replace `crm.example.com` with your actual domain name.
2. **Check Server Requirements**:

    - The installer automatically checks whether your server meets all requirements.
    - If no message tells you that the requirements check failed, click **Next** to proceed.
    - If there are any issues, ask your hosting provider to resolve them before you continue.
3. **Verify Permissions**:

    - The installer also checks the file and folder permissions.
    - If the permissions are set correctly, click **Next** to enter the application data.
    - If there are permission issues, set **755 permissions** for the specified folders. If you manage the server yourself, see the [Permissions, User and Group](https://www.advanzo.ch/docs/sections/installation#permissions-user-and-group) section for detailed instructions.

### General Config

1. **App Url**:

    - Advanzo CRM automatically tries to detect the URL at which the application is installed. In this example, the URL is **[https://crm.example.com/](https://crm.example.com/)**. If the URL is wrong, correct it.
2. **Application Name**:

    - Leave the default or enter your own name, for example **"My Company CRM"**.
3. **Country**:

    - Select your country.
4. **Currency**:

    - If it is not selected automatically, select the default currency to be used in Advanzo CRM.

### Configure Database

**Enter the database configuration in the installer**

1. **Hostname**

    - Enter the database hostname. In most cases, the default hostname is **localhost**; if yours is different, make sure to enter the correct hostname.
2. **Port**

    - In most cases, this value is `3306`, the default MySQL port. If you are not familiar with this option for your server, leave it as it is and continue to the next fields, where you enter the database name and the user you created in the previous step.
3. **Database Name**

    - Enter the database name.
4. **Database User**

    - Enter the database username.
5. **Database Password**

    - Enter the password of the database user. For local installations and database users without a password, leave it empty.
6. **Test Connection & Configure**:

    - Click "Test Connection & Configure". If the database connection is successful, you move on to the last step; otherwise, check your credentials and hostname again.
7. On the next page, configure the administrator user and run the installation.

### Installation Finished Page

After you finish all the installation steps, a success screen appears. It explains [how to configure the cron job](https://www.advanzo.ch/docs/sections/cron) and shows the suggested **command** and **path** for the cron job.

Do not forget to **copy the command/path** so that you can **configure a cron job** as explained [here](https://www.advanzo.ch/docs/sections/cron).

> **Info:** The **installation success page is available for 1 hour after installation**. After 1 hour, the same URL shows a 404 error.

On this screen

- All installation stages are marked complete: Requirements, Permissions, Setup, User and Finish.
- A confirmation that Advanzo CRM was installed successfully, together with the cron job command to schedule: `* * * * * php /path/to/advanzo/artisan schedule:run >> /dev/null 2>&1`
- Your admin credentials (the email and password you chose during setup) and a **Login** button to enter the CRM.

## Nginx Config

If you manage the server yourself and are already familiar with Laravel, you probably know that Nginx needs a separate configuration file to serve Advanzo CRM.

The example below is for an installation on the root domain. Adjust the paths if you want to install on a subdomain.

```php
server {     listen 80;     server_name example.com;     root /example.com/public;      add_header X-Frame-Options "SAMEORIGIN";     add_header X-XSS-Protection "1; mode=block";     add_header X-Content-Type-Options "nosniff";      index index.html index.htm index.php;      charset utf-8;      location / {         try_files $uri $uri/ /index.php?$query_string;     }      location = /favicon.ico { access_log off; log_not_found off; }     location = /robots.txt  { access_log off; log_not_found off; }      error_page 404 /index.php;      location ~ \.php$ {         fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;         fastcgi_index index.php;         fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;         include fastcgi_params;     }      location ~ /\.(?!well-known).* {         deny all;     } }
```

## Permissions, User and Group

If you manage the server yourself, make sure that the proper permissions are applied to all files and folders, and that the files and folders belong to the user and group that run the web server, in most cases `www-data`.

Keep in mind that **you do not need to run the commands below if your server is managed by your server provider**, for example on shared hosting, because the permissions and the group are already configured for you.

**Change all the directories to 755 (drwxr-xr-x):**

```bash
find /var/www/example.com -type d -exec chmod 755 {} \;
```

**Change all the files to 644 (-rw-r--r--):**

```bash
find /var/www/example.com -type f -exec chmod 644 {} \;
```

**Change the user and group of the files and folders:**

```bash
sudo chown www-data:www-data -R /var/www/example.com
```

> **Info:** Do not forget to adjust the values in the **example commands** to your setup.

## Next Steps

### Update/Patch Installation

After a successful installation, we strongly recommend checking whether any [patches](https://www.advanzo.ch/docs/sections/installation) or [updates](https://www.advanzo.ch/docs/sections/installation) are available, so that you have the latest features and fixes. You can do this in **Settings -> System -> Update**.

### Configure Cron Job

Advanzo CRM requires a properly configured cron job for all features to work as expected. [Learn how to configure the cron job](https://www.advanzo.ch/docs/sections/cron).

### Configure System Email Account

Configure a system email account. The system uses it as a general email account to send system-related emails such as password resets, "user assigned to contact" notifications and activity due reminders.

See the [system email account](https://www.advanzo.ch/docs/sections/settings/general#system-email-account) configuration page for more information.

### Configure Brand

The Advanzo CRM installation creates a default brand, which is used for the [documents](https://www.advanzo.ch/docs/sections/documents) feature. Make sure that the brand information and settings match your brand.

Read more about brands [here](https://www.advanzo.ch/docs/sections/settings/brands).
