Laravel on shared hosting is possible by configuring a public directory and managing dependencies via the command line. You must have a host supporting PHP and a terminal interface. Check if your host provides SSH access and a Composer installation to manage your project dependencies.
Review Hosting Bureau walks through how to navigate the specific constraints of shared hosting when running laravel on shared hosting. Standard documentation often assumes root access, but success on a shared plan requires pointing the document root to the public folder to hide core files from the web.
The document root determines which folder the web server displays
The document root is the specific folder on a server that contains the files for your website. It works by telling the web server where to start looking for the homepage when a visitor types in your URL. You must point this to the public folder to ensure your Laravel site loads correctly.
- What it is
- Laravel is a PHP framework for building web applications using expressive syntax and modern tools
- Who it suits
- Developers building low-traffic applications or prototypes who need a structured environment without managing infrastructure
- What you need first
- PHP version 8.2 or higher and a terminal capable of executing Composer commands
- What it costs to change later
- Composer dependencies remain portable because they reside in the project folder rather than the system directory
- First thing to check
- The public_html folder path in the cPanel file manager confirms the correct directory for the public directory
Running laravel on shared hosting
To run a laravel project on shared hosting, you must move the public folder to the root directory and point your domain to it. This configuration allows the web server to access the application while keeping core files outside the public directory. You confirm your setup by checking if the index.php file sits in the main directory.
SSH access determines how you interact with the server
SSH access is a secure way to connect to your server's command line remotely. It works by allowing you to type commands directly into the server's operating system from your own computer. Having this access determines whether you can run automated tools or if you must upload files manually.
Composer requirements and folder permissions
Different laravel shared hosting plans vary based on their ability to execute the composer command. Composer is a tool that manages and installs the external code libraries that Laravel needs to function. Some hosts restrict terminal access, which means you must upload the vendor folder from a local machine. Before choosing, compare shared hosting with WordPress hosting to see if the server likely cannot read the public folder permissions.
PHP extensions and .htaccess configuration
You can resolve a laravel shared hosting 500 error by checking the logs to see if the server lacks the required PHP extensions. A 500 error is a general message indicating that the server encountered an unexpected problem while trying to load the page. Many users use an .htaccess laravel shared hosting file to redirect requests correctly. This ensures the laravel shared hosting routes function without manual path adjustments in the code.
Securing a laravel installation on a shared server
Laravel shared hosting security requires moving the .env file and other sensitive configurations to a directory above the public folder. This action isolates the configuration from public access. You should also restrict access to the storage folder and compare shared hosting with cloud hosting to prevent unauthorized file execution.
How to set the document root on shared hosting?
To set the document root to the public folder, you must change the web server configuration to point to the /public directory instead of the project root. This ensures the web server only serves files from the public folder. You can verify the change by visiting your domain and seeing the Laravel welcome page.
Shared hosting configuration
- Upload the entire laravel project on shared hosting to a directory like /home/user/public_html/laravel_project.
- Create a new .htaccess file inside the /public folder to manage laravel shared hosting routes.
- Edit the main .htaccess file in the root directory to redirect all requests to the public folder.
- Verify the best shared hosting for laravel by checking that your site loads without a 404 error.
Setting up a cron job for laravel tasks
A laravel cron job on shared hosting requires a system command to trigger the scheduler every minute. A cron job is a scheduled task that the server runs automatically at specific times or intervals. You must access your hosting control panel to add a cron job that runs the php artisan schedule:run command. This setup ensures that scheduled tasks like emails or reports execute automatically without manual intervention.
Deploying laravel to shared hosting without SSH access
You can deploy Laravel to shared hosting without SSH by manually uploading files via FTP. You must upload the entire project folder and then configure the public directory to point to the public folder. This method requires manual updates to the vendor directory because you cannot run composer commands on the server.
Laravel on shared hosting
- Upload the entire project folder to the hosting account using an FTP client like FileZilla.
- Verify the file list to ensure the vendor folder and all Laravel files transferred correctly.
- Move the project files into a subfolder to facilitate shared hosting for laravel and keep the root clean.
- Edit the .htaccess file to redirect traffic to the public folder to fix a laravel shared hosting 403 error.
Methods for manual deployment without terminal access
FTP transfers propagate all files to the server but lack the automation of a terminal. This method requires the user to run composer locally and upload the resulting vendor folder to the remote host. Users must also manually configure the database and environment files to match the shared hosting environment.
How do I handle the storage symlink if I cannot use the artisan command?
I handle the storage symlink by manually creating a symbolic link through the hosting control panel or a terminal if the artisan command is unavailable. This process connects the public folder to the storage folder so the web server can display uploaded files. This method works when a shared hosting environment restricts command line access for users.
Manual path verification for storage files
Many shared hosting plans restrict the execution of the artisan command, which usually automates this link. Without this automation, the web server might return a 404 error or a 403 error when attempting to access files in the storage directory. You must verify the pathing and compare shared hosting vs VPS to ensure the public folder correctly points to the internal directory.
Creating a manual symlink for storage
Navigate to your project root and identify the absolute paths for the public and storage directories. Use the symlink tool in your hosting dashboard to map the public directory to the storage folder. A symlink is a shortcut file that points to a different folder or file on the server. This manual link ensures the web server recognizes the correct path for your project’s assets.
Clearing the laravel cache on a shared server
Clear the Laravel cache on a shared server by running artisan commands via SSH or by manually deleting files in the storage and bootstrap folders. You must clear the application cache, configuration cache, and route cache to ensure the site reflects recent code changes or environment updates.
Shared hosting environments often restrict terminal access, so developers must verify if the hosting plan includes a command line interface. If the host denies SSH, a developer can compare reseller hosting vs shared hosting or create a temporary route or a web script to trigger the cache clearing logic.
Cache clearing commands
- Run the php artisan config:clear command to remove the compiled configuration files.
- Execute the php artisan cache:clear command to flush the application cache.
- Use the php artisan route:clear command to rebuild the route list.
- Perform the php artisan view:clear command to remove compiled blade templates.
- Run the php artisan optimize command to compile the configuration and routes simultaneously.
Commands to clear the laravel cache
Access the terminal via SSH and navigate to the project root directory. Execute php artisan config:clear, php artisan cache:clear, and php artisan route:clear to refresh the application state.
Deploying laravel on shared hosting by following these technical requirements
Choosing a shared hosting environment for Laravel requires confirming specific technical capabilities and security compliance before committing to a provider.
Implementation checklist for shared hosting
- Identify your project's required PHP version and memory limits. List the specific requirements for your Laravel version. Ensure these match the hosting environment's capabilities to prevent execution errors.
- Request a list of available Composer commands from the provider. Ask the hosting provider if they allow the execution of composer install and update commands via SSH. A positive confirmation ensures you can manage dependencies.
- Verify the server's ability to map a custom document root. Confirm the provider allows pointing the public folder to the /public directory. If they only allow the root folder, you may need a different host.
- Confirm the provider supports the required TLS certificate lifespans. Check that the host can issue certificates meeting the requirement of 200 days from 15 March 2026. Failure to do so may cause certificate expiration issues.
- Audit all third party scripts for PCI DSS compliance. Verify every script on your payment page against PCI DSS requirement 6.4.3. Each tool must be authorised, justified and integrity-checked to be compliant.
Frequently asked questions
- Why am I getting a 500 error or 403 error on my Laravel site?
- A 403 error means the server cannot read the public folder permissions. You can fix a 500 error by checking logs to see if the server lacks required PHP extensions.
- What are the best shared hosting plans for laravel?
- The best shared hosting for laravel depends on the plan’s ability to execute the composer command. You should verify if the host provides SSH access and a terminal interface.
- What happens if I cannot use the artisan command to create a storage symlink?
- You handle the storage symlink by manually creating a symbolic link through the hosting control panel. This connects the public folder to the storage folder so the web server can display uploaded files.
- How do I clear the laravel cache on a shared server without SSH?
- Cache clearing requires running artisan commands or manually deleting files in the storage and bootstrap folders. If the host denies SSH, you can create a web script to trigger the cache clearing logic.