> For the complete documentation index, see [llms.txt](https://docs.spurtcommerce.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.spurtcommerce.com/api-deployment-and-setup/deployment-from-source-code.md).

# Deployment From Source Code

## Single Server Deployment in Ubuntu

{% hint style="info" %}
In order to begin with Single Server deployment, you need to have the prerequisites ready in the Server .&#x20;
{% endhint %}

If you have not installed required prerequisite software please install now following the [<mark style="color:blue;">Set up development environment</mark>](/getting-started/prerequisites/set-up-development-environment.md) link

Now, follow the steps to begin the deployment process:

* **Step 1 -**  Set up API following the link [<mark style="color:blue;">**API Setup**</mark>](/getting-started/development-and-setup/api-setup.md).
* **Step 2 -** After building the source code in your local development machine, move the required folders listed below

&#x20;                                                    demo/&#x20;

&#x20;                                                    dist/&#x20;

&#x20;                                                    sitemap/

&#x20;                                                    package.json

&#x20;                                                    views/&#x20;

&#x20;                                                    .env

<figure><img src="/files/oyuGV6qN2Uet4LIEpEbs" alt=""><figcaption></figcaption></figure>

* **Step 3-** You have to edit your ENV file based on your infrastructure. please follow [<mark style="color:blue;">**Environment Configuration**</mark>](/getting-started/development-and-setup/environment-configuration.md) link to edit your env file.
* **Step 4-** To install Node packages use the command &#x20;

```
 npm i
```

* **Step 5-** Change apache configuration and specify ProxyPass rules inside virtual host in <mark style="color:green;">**000-default.conf.**</mark>&#x20;

&#x20;Run the following commands from system's root directory

```
 cd /etc/apache2/sites-available/



```

```
sudo nano 000-default.conf
```

```
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>


<Location /backend>
ProxyPass http://127.0.0.1:8000 ProxyPassReverse http://127.0.0.1:8000
</Location>
```

{% hint style="info" %}

```
The port number that has been set up in .env has to entered in place of {PORT}

"ProxyPass http://127.0.0.1:{PORT} ProxyPassReverse http://127.0.0.1:{PORT}"
```

{% endhint %}

Then restart apache with below command&#x20;

```
sudo service apache2 restart
```

* **Step 6-** Click the link given below to install PM2. Skip if it is already installed.

> <https://www.npmjs.com/package/pm2>
>
> Check whether you are having <mark style="color:green;">**`ecosystem.config.js`**</mark> in api folder. If it does not exist, then create the file and copy and paste the following code in that file

```javascript
module.exports = {
  apps : [
      {
        name: "spurt",
        script: "dist/src/app.js",
        instances: "max",
        exec_mode: "cluster",
        env: {
            "PORT": 8000,
            "NODE_ENV": "production"
        }
      }
  ]
}

```

{% hint style="info" %}
"PORT" : {your port number}

"NODE\_ENV": {your env type}
{% endhint %}

* **Step 7-** To run Api use pm2 command `pm2 start`

```
pm2 start
pm2 status
```

{% hint style="info" %}

#### For additional PM2 commands follow the  referral  link <https://www.npmjs.com/package/pm2>

{% endhint %}

* **Step 7-** After having followed the above steps correctly, you have successfully setup the API server. You can now open the browser and give this URL —&#x20;

&#x20;\- http\://\<YOUR\_IP\_ADDRESS>/backend/api

&#x20;check the API documentation with the URL

* http\://<**YOUR\_IP\_ADDRESS**>/backend/apidoc&#x20;
