Install Statamic site on cPanel server
- Ask your web hosting support to enable SSH access
- Generating a public/private server keys
- Set-up SSH keys on the server
- Configuring Git repository access on Github
- Cloning a Github repository
- Set-up Statamic app and install Composer
- Check file and folder permissions
- Adding a subdomain to access Statamic website
- Setting up a SSL certificate for new subdomain
- Installing a Node.js application and configure build process
- Review PHP version and settings
- Changing default public_html folder to replace with Statamic's public folder
- Setting up environment file for production site
- Setting up a deploy file for cPanel for automation
- Setting up Git automation
- Setting up Redis connection
- Activating Statamic licenses for new site
- After all steps work, update main domain to point to public folder
- Visit main domain to confirm everything works as expected
- Configuring production users
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:
- Open a support ticket on your web hosting service
- Ask them to enable SSH access for your cPanel account
- 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
- Login to cPanel server at https://example.com:2083
- Go to SSH Access page
- Click on Manage SSH Keys
- Click on Generate a New Key
- Enter Key Name or leave the default value:
id_rsa - Set Key Password with at least 5 characters
- Leave Key Type as
RSA - Change Key Size to
4096 - Click on Generate Key
- After Key Generation is complete, click on Go Back
- Your new
id_rsakey should appear under Public Keys section - Click on View/Download button
- 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
- Login to your SSH server
- Run command
ssh-keygen -t rsa -b 4096 - Run command
cat ~/.ssh/id_rsa.pub - Copy the ssh-rsa string to your clipboard
Configuring Git repository access on Github
- This document assumes your Statamic repository is hosted on Github.
- Go to your Settings and click on SSH and GPG keys at https://github.com/settings/keys
- Click on New SSH key
- Enter Title with any name to recognize it in the future
- Leave Key type as
Authentication Key - Enter Key from your clipboard
step 1.13
Cloning a Github repository
- Go to your Github repository and click on Code button
- Select SSH and copy the repository link
- Go to cPanel main dashboard
- Click on Git™ Version Control
- Click on Create button
- Keep Clone a Repository option enabled
- Paste repository link from
step 4.2in Clone URL field - Enter your Repository Path for your Statamic install, for example
statamic-productionor leave the default value - Keep in mind this Repository Path will be useful for
step 7.xto create your cPanel domain or subdomain - Enter Repository Name to identify your project in cPanel.
- Click on Create button
- You will see a notification when cloning has started
- Your repository will appear on the list to Manage through the right button.
Set-up Statamic app and install Composer
- Using SSH console, go to your Statamic folder
cd ~/statamic-folder - Run
composer installto install your project dependencies - Copy your
.envfile from your local computer to your project folder. - Make any required changes to your server's
.envfile.
Check file and folder permissions
- Using SSH console, go to your projects folder
cd ~/statamic-folder - Run
ls -lato see if all files/folders have correct permissions. - Run
chown username:username -R *as needed.
Adding a subdomain to access Statamic website
- Go to
Domains > Domains - Click on
Create a New Domain - Enter domain or subdomain name like
stg.example.com - Untick
Share document root with example.com - Enter Document Root
statamic-project/public - Click on
Submitbutton.
Setting up a SSL certificate for new subdomain
- 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.
- In cPanel, go to
Security > SSL/TLS Status - Click on
Run AutoSSLbutton - Wait for the AutoSSL process to complete.
- Verify that your domain/subdomain has a green lock icon with status "AutoSSL Domain Validated".
Installing a Node.js application and configure build process
- Go to cPanel main dashboard
- Click on Setup Node.js App
- Click on Create Application
- Select
Node.js versionandApplication modeas you like Application rootThis is the folder name where you installed Statamic.Application URLSelect your existing sub/domain.Application startup fileEnterapp.js- Click on
Run NPM InstallThis will runnpm install- Note: In my personal experience,
npm installwere not downloading all packages so I runnpm install --include=devinstead.
- Note: In my personal experience,
- Click on
Run JS scriptIt will open a popup then click onproductionthenRun JS scriptbutton. - This everything runs successfully you should have built all assets for your website.
Review PHP version and settings
- Go to
Software > Select PHP Versionto review your server settings. - Current PHP version should be the latest version 8.x
- Check if you need to enable any extensions like
gd,imagick,redis, etc. - Review your
Optionstab 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:
- Go to
Domains > Domains - Click on
Managebutton in your desired domain. - Enable
Force HTTPS Redirectfor your sub/domain
Setting up environment file for production site
- Go to
Files > File Manager - Navigate inside your Statamic folder.
- Right-click on
.env fileand click onEdit - Modify any variables to make it work in your production server and click
Save Changesbutton
Activating Statamic licenses for new site
- Go to Statamic.com and signup/signin to your account.
- 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:
- Go to your SSH console
- Navigate to your username folder
cd ~ && ls -l - Rename your public_html by running
mv public_html public_html_backup - Create a symbolic link to your Statamic public folder by running
ln -s statamic-folder/public public_html
Addon domain:
- In cPanel, go to
Domains > Domains - Click on
Managebutton of your selected domain - Enter your
New Document Rootwith your Statamic public folder, likestatamic-folder/public - Click on the
Updatebutton - 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
- Visit your new Statamic site at https://example.com
- In SSH console, go to your Statamic folder
cd ~/statamic-folder - Open your .env file
nano .env - Update
APP_URLvariable to your production domain.
Configuring production users
Check out docs to create users https://statamic.dev/users#creating-users
- Run
php please make:usercommand - or upload local files in
local-project/users/*to your server atstatamic-folder/users/.