When deploying a non-Laravel PHP site on Forge, you can indeed use the "public" folder as the web root, similar to how Laravel sites are structured. However, you have a couple of options for organizing your repository and deployment process:
-
Structure Your Repository with a Public Folder:
- You can structure your repository so that the main entry point files (like
index.php) and any publicly accessible assets (like CSS, JavaScript, and images) are inside apublicdirectory. This way, when you deploy, the contents of thepublicdirectory will naturally map to the web root on Forge.
Example repository structure:
my-php-site/ ├── public/ │ ├── index.php │ ├── css/ │ ├── js/ │ └── images/ ├── src/ └── vendor/ - You can structure your repository so that the main entry point files (like
-
Deploy to a Subdirectory and Symlink:
- If you prefer not to restructure your repository, you can deploy the entire repository to a subdirectory on your Forge server and then create a symbolic link from the
publicdirectory in your repository to the web root.
Steps:
- Deploy your repository to a directory like
/home/forge/yourdomain.com/source. - Create a symbolic link from the
publicdirectory in your repository to the web root:ln -s /home/forge/yourdomain.com/source/public /home/forge/yourdomain.com/public
- If you prefer not to restructure your repository, you can deploy the entire repository to a subdirectory on your Forge server and then create a symbolic link from the
-
Modify the Deployment Script:
- You can also modify the deployment script in Forge to move the contents of your repository's
publicdirectory to the web root after each deployment.
Example deployment script modification:
#!/bin/bash # Navigate to the deployment directory cd /home/forge/yourdomain.com # Pull the latest changes git pull origin main # Move the contents of the public directory to the web root rsync -av --delete source/public/ . # Run any other necessary deployment commands - You can also modify the deployment script in Forge to move the contents of your repository's
By using one of these methods, you can effectively deploy a non-Laravel PHP site on Forge while keeping your repository organized and your deployment process smooth.