Skip to content

Configuring the Document Root

ChargePanda, like all modern Laravel applications, requires that its root directory for the web server is pointed specifically to the public/ folder. This ensures that sensitive files, configuration data, and application source code remain secure and inaccessible from the web.

Here are the instructions to set the Document Root correctly based on your hosting environment.


🏗️ cPanel

If you are hosting ChargePanda on an Addon Domain or a Subdomain, you can easily define its Document Root in cPanel:

  1. Log into your cPanel.
  2. Navigate to Domains (or Addon Domains / Subdomains depending on your cPanel version).
  3. Find your domain in the list and click Manage or click the pencil icon next to the Document Root path.
  4. Update the path to include /public at the end (e.g., public_html/chargepanda/public or yourdomain.com/public).
  5. Click Update or Save.

Option B: Using .htaccess as a fallback

If you are installing ChargePanda on a primary domain (e.g. directly inside public_html) and your host doesn't let you alter the primary Document Root:

  1. Upload the entire project into public_html.
  2. Create or edit an .htaccess file inside public_html (the root of the project, not inside public/).
  3. Add the following rules to seamlessly redirect traffic to the public/ directory:
apache
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

(Note: While this approach works, Option A is more secure. Always prefer native Document Root changes if allowed by your host.)


🌍 Plesk

To change the Document Root in Plesk:

  1. Log into your Plesk Panel.
  2. Go to Websites & Domains.
  3. Locate the domain where you uploaded ChargePanda and click on Hosting & DNS > Hosting Settings.
  4. In the Document root field, append /public to the existing directory path (e.g., httpdocs/public).
  5. Click OK or Apply at the bottom of the page.

⚙️ Custom Apache Server

If you have root access to an Apache server (e.g. VPS or Dedicated Server), you need to update the VirtualHost configuration.

  1. Open your Apache configuration file (often located at /etc/apache2/sites-available/your-domain.conf or /etc/httpd/conf.d/your-domain.conf).
  2. Set the DocumentRoot directive to point to the public folder.
  3. Make sure the directory block allows overrides.
apache
<VirtualHost *:80>
    ServerName yourdomain.com
    DocumentRoot /var/www/chargepanda/public

    <Directory /var/www/chargepanda/public>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
  1. Restart Apache:
bash
sudo systemctl restart apache2 # or httpd

🚀 Custom Nginx Server

For a custom Nginx installation, locate your server block configuration (typically at /etc/nginx/sites-available/your-domain or /etc/nginx/conf.d/your-domain.conf).

  1. Update the root directive to point to the /public directory.
  2. Ensure you have the $uri/ /index.php?$query_string fallback in your location block.
nginx
server {
    listen 80;
    server_name yourdomain.com;
    root /var/www/chargepanda/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";

    index index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}
  1. Restart Nginx:
bash
sudo systemctl restart nginx

Released under the Commercial License.