I have a VPS running WHM and Cpanel. I have multiple domains hosted there. Say one of them is example.com
What I am intending to do is have two versions of the application.
Production: example.com
> /public_html/
Development: staging.example.com
> /public_html/staging/
Right now, I am trying to deploy my application to the development environment, i.e to the staging folder.
Envoyer, with a lot of struggle with my hosting provider, is working fine. It's uploading the files as expected. The only issue now is the symbolic link current
Right now the folder structure is:
-staging
- releases
-release1
-release2
- current
My subdomain clearly points out to the staging folder, which will lead it to display all the contents of the folder rather than the application.
Since the application is inside the release folder, how do I make sure that my application runs when we hit the subdomain.
Do I have to modify my virtual hosts file in Apache?
Laravel requires the root for the domain (configured in the relevant apache vhost conf file) to be it's 'public' folder. This is where it's entry point index.php is.
Edit the apache vhosts conf file as per below
For example.com you install your laravel application into /home/user/public_html folder.
As part of the laravel install it will create the 'public' folder.
For staging.example.com you install your laravel application into /home/user/public_html/staging folder.
Don't forget to restart the web server so it picks up the new configuration.
If you do not have the ability to change the vhost configuration mentioned above, you can use .htaccess file in your public_html folder (note the leading full stop which makes it a hidden file). The following is dependant on your hosting provider allowing .htaccess overrides.
Add the following to the .htaccess file:
If domain has been set up correctly by the host to point to /home/username/public_html when entering http://example.com then it should automatically call public/index.php.
You will need to do the same in public_html/staging folder.