Skip to content

Install Statamic site on cPanel server

Guidelines for installing a Statamic site on production cPanel server.

This document assumes DNS is configured on Cloudflare and domain is pointed to a shared web server with no SSH access by default.

Ask your web hosting support to enable SSH access

If you are not sure or do not have access to SSH command line, please follow these steps:

  1. Open a support ticket on your web hosting service
  2. Ask them to enable SSH access for your cPanel account
  3. If need a reason, tell them you need to run Composer and NPM commands to build your Statamic website

Generating a public/private server keys

  1. Login to cPanel server at https://example.com:2083
  2. Go to SSH Access page
  3. Click on Manage SSH Keys
  4. Click on Generate a New Key
  5. Enter Key Name or leave the default value: id_rsa
  6. Set Key Password with at least 5 characters
  7. Leave Key Type as RSA
  8. Change Key Size to 4096
  9. Click on Generate Key
  10. After Key Generation is complete, click on Go Back
  11. Your new id_rsa key should appear under Public Keys section
  12. Click on View/Download button
  13. Copy to clipboard entire string for Public SSH Key “id_rsa” Open Key

Set-up SSH keys on the server

This process cannot be executed from cPanel GUI, due to no passphrase support. https://github.com/orgs/community/discussions/40790

  1. Login to your SSH server
  2. Run command ssh-keygen -t rsa -b 4096
  3. Run command cat ~/.ssh/id_rsa.pub
  4. Copy the ssh-rsa string to your clipboard

Configuring Git repository access on Github

  1. This document assumes your Statamic repository is hosted on Github.
  2. Go to your Settings and click on SSH and GPG keys at https://github.com/settings/keys
  3. Click on New SSH key
  4. Enter Title with any name to recognize it in the future
  5. Leave Key type as Authentication Key
  6. Enter Key from your clipboard step 1.13

Cloning a Github repository

  1. Go to your Github repository and click on Code button
  2. Select SSH and copy the repository link
  3. Go to cPanel main dashboard
  4. Click on Git™ Version Control
  5. Click on Create button
  6. Keep Clone a Repository option enabled
  7. Paste repository link from step 4.2 in Clone URL field
  8. Enter your Repository Path for your Statamic install, for example statamic-production or leave the default value
  9. Keep in mind this Repository Path will be useful for step 7.x to create your cPanel domain or subdomain
  10. Enter Repository Name to identify your project in cPanel.
  11. Click on Create button
  12. You will see a notification when cloning has started
  13. Your repository will appear on the list to Manage through the right button.

Set-up Statamic app and install Composer

  1. Using SSH console, go to your Statamic folder cd ~/statamic-folder
  2. Run composer install to install your project dependencies
  3. Copy your .env file from your local computer to your project folder.
  4. Make any required changes to your server's .env file.

Check file and folder permissions

  1. Using SSH console, go to your projects folder cd ~/statamic-folder
  2. Run ls -la to see if all files/folders have correct permissions.
  3. Run chown username:username -R * as needed.

Adding a subdomain to access Statamic website

  1. Go to Domains > Domains
  2. Click on Create a New Domain
  3. Enter domain or subdomain name like stg.example.com
  4. Untick Share document root with example.com
  5. Enter Document Root statamic-project/public
  6. Click on Submit button.

Setting up a SSL certificate for new subdomain

  1. If you created a subdomain and use Cloudflare or any provider to manage DNS records, add your newly created subdomain to point to your server's IP as "A" record and "DNS only" option.
  2. In cPanel, go to Security > SSL/TLS Status
  3. Click on Run AutoSSL button
  4. Wait for the AutoSSL process to complete.
  5. Verify that your domain/subdomain has a green lock icon with status "AutoSSL Domain Validated".

Installing a Node.js application and configure build process

  1. Go to cPanel main dashboard
  2. Click on Setup Node.js App
  3. Click on Create Application
  4. Select Node.js version and Application mode as you like
  5. Application root This is the folder name where you installed Statamic.
  6. Application URL Select your existing sub/domain.
  7. Application startup file Enter app.js
  8. Click on Run NPM Install This will run npm install

    1. Note: In my personal experience, npm install were not downloading all packages so I run npm install --include=dev instead.
  9. Click on Run JS script It will open a popup then click on production then Run JS script button.
  10. This everything runs successfully you should have built all assets for your website.

Review PHP version and settings

  1. Go to Software > Select PHP Version to review your server settings.
  2. Current PHP version should be the latest version 8.x
  3. Check if you need to enable any extensions like gd, imagick, redis, etc.
  4. Review your Options tab to see if everything looks good or need any changes.

Changing default public_html folder to replace with Statamic's public folder

If you're configuring this site as your cPanel Main Domain, the GUI does not have a way to update the document root, this needs to be done through SSH

  • Run cd ~/ && ln -s statamic-production/public public_html

If you're configuring this site for an addon domain, cPanel allows to update it by:

  1. Go to Domains > Domains
  2. Click on Manage button in your desired domain.
  3. Enable Force HTTPS Redirect for your sub/domain

Setting up environment file for production site

  1. Go to Files > File Manager
  2. Navigate inside your Statamic folder.
  3. Right-click on .env file and click on Edit
  4. Modify any variables to make it work in your production server and click Save Changes button

Setting up a deploy file for cPanel for automation

Setting up Git automation

Setting up Redis connection

Activating Statamic licenses for new site

  1. Go to Statamic.com and signup/signin to your account.
  2. Buy any software licenses required for your website.

After all steps work, update main domain to point to public folder

Instructions vary if you configure as main domain or addon domain in cPanel.

Main domain:

cPanel does not provide a way to update document root from GUI so the steps are:

  1. Go to your SSH console
  2. Navigate to your username folder cd ~ && ls -l
  3. Rename your public_html by running mv public_html public_html_backup
  4. Create a symbolic link to your Statamic public folder by running ln -s statamic-folder/public public_html

Addon domain:

  1. In cPanel, go to Domains > Domains
  2. Click on Manage button of your selected domain
  3. Enter your New Document Root with your Statamic public folder, like statamic-folder/public
  4. Click on the Update button
  5. When process completes, you should see message at the top Success: You have successfully updated the document root.

Visit main domain to confirm everything works as expected

  1. Visit your new Statamic site at https://example.com
  2. In SSH console, go to your Statamic folder cd ~/statamic-folder
  3. Open your .env file nano .env
  4. Update APP_URL variable to your production domain.

Configuring production users

Check out docs to create users https://statamic.dev/users#creating-users

  1. Run php please make:user command
  2. or upload local files in local-project/users/* to your server at statamic-folder/users/.