This is a guide that will show you how to install Laravel Nova in a subfolder of a domain.
Clone the repository in the home directory of the cPanel user.
cd /home/user
git clone https://github.com/your/project.git /home/user/folder
This is just like you usually do, run the commands you need to make your Laravel install work. For example:
cd folder
composer install
cp .env.example .env
php artisan key:generate
php artisan migrate
Make a symbolic link with the newly created folder on your public_html
folder.
cd /home/user/public_html
ln -s ../folder/public folder
This will give us access to https://domain.com/folder. At this point, you should be able to see your Laravel application.
This will tell Nova to use the subfolder domain for the /nova-api/
requests. Open vendor/laravel/nova/resources/js/util/axios.js
and add a base url to the config.
const instance = axios.create({
baseURL: 'https://domain.com/folder'
})
cd /home/user/folder/vendor/laravel/nova && yarn
Rename the webpack.mix.js.dist to webpack.mix.js to be able to make a production build.
mv webpack.mix.js.dist webpack.mix.js
yarn production
Now that you've compiled the scripts, you have to move them to them into /home/user/folder/public/vendor/nova
.
mv /home/user/folder/vendor/laravel/nova/public/* /home/user/folder/public/vendor/nova/
Now at this point, your Nova should be loading properly, but once you login, you will notice a 404 page.
Open /home/user/folder/vendor/laravel/nova/resources/views/layout.blade.php
and look for window.config = @json(Nova::jsonVariables(request()));
to add the following on the next line:
window.config.base = '/folder' + window.config.base;
This will tell Nova that the base url of the admin is located under the subfolder.
Awesome guide, thanks!!!