I’ve been researching how to install my first Laravel project on my Ubuntu 16.04 (plesk17) VPS. I’m reading that I should install Laravel in a folder outside of the httpdocs and move the public folder inside httpdocs. For security reasons.
Is this correct?
If this is correct I have a follow up question:
I am also learning how to use GIT to pull updates to my production site. I can make it deploy to a folder outside of httpdocs but how do I keep the public folder up to date when when pulling updates when it is no longer in the same folder as the rest of my Laravel files?
Here is your solution https://www.youtube.com/watch?v=hv4hwgQO9xI
And for folders like css, js, images in public folder, you may make a symbolic link to it and don't forget to update the index.php file if this app is your root app or primary domain, otherwise you can make the whole public folder as symbolic link.
Note: clone it from github as https not ssh so it doesn't prompt you the password after the webhook request, don't forget to manage .env file
It seems to work apart from the CSS and JS. The source and href paths start with a "/" so the js and css file are not found. I've been looking around on where to fix that but the only file where I can find the paths with a starting "/" is public/mix-manifest.json. Changing it there does not make a difference.
Any idea what I need to do to get the JS and CSS working?
Notice main laravel is above public_html (htdocs or www).
I'd get it properly setup (structured) first, then look at the url and other helper functions.
Otherwise you will have it working in development, but later in production things won't work.
Have your dev and production setup the same.
Yes I have the structure now, but it is different then my development version. I think I'll manage to solve that. At the moment the differences are minimal so I'm focussing on getting everything to work on my production server first. This is mainly what I'm struggling with.
Your tip with url() did the trick. I just had to work out how to use that with Laravel Mix and versioning. My app is loading the CSS and JS files as it should. This is what the stylesheet link tag looks like.
However, my routes don't seem to work. Getting 404s. The url is fine. At the moment my app only has one link available for guests, a login via Socialite and Spotify. I'm going to create a testlink to a simple page and see if that works.
I tried that but it doesn't make a difference. Works on my local dev version but not on the server. I also tried removing the leading slash from the routes but also no difference.
I don't think it's the blade template. It seems my routes file just doesn't do anything on the server.