Run a Laravel app on cPanel by linking public_html
Serve a Laravel project on shared cPanel hosting without exposing the whole app folder.
From the archive: first published on mohamedsharaf.net in December 2018. Rewritten and checked in 2026; some details may be out of date.
Laravel expects the web server to point at its public folder, while cPanel serves whatever is in public_html. Copying the whole project into public_html would expose your .env file and source code. A safer trick is to keep the project outside the web root and make public_html a link to its public folder:
cd /home/USER
mv public_html public_html.old
ln -s /home/USER/myapp/public public_html
Replace USER and myapp with your own names. Renaming the old folder first, instead of deleting it, leaves you a way back if something goes wrong.
After that, deploying is just updating /home/USER/myapp (for example with git pull), and only the public folder is ever visible on the web.