I am deploying a laravel app with dokku and it deploys the app perfectly. The only issue is the famous /public problem. I need to change the nginx configuration inside the container somehow to make it point out to the correct directory. I found this instruction about nginx configuration in dokku but it doesn't give information about changing the root directory of an app.
I needed to make a Procfile containing:
web: vendor/bin/heroku-php-nginx public/
Related
I am deploying Laravel 9 project to shared hosting (without the ability to ssh into the server so I can't npm run build in the server) and I am getting this error:
Vite manifest not found at: laravel_project/public/build/manifest.json
I am using FileZilla to upload the project to the CPanel, I uploaded the public folder into public_html and configured the index.php file.
Before uploading the project i run npm run build locally on my localhost and everything works ok there.
Does anyone have a solution for this ?
I tried changing the APP_ENV=production but it didn't work.
so I found a solution for that which is:
put all my local laravel files and folders including the public folder (of course after running composer install and npm run build locally) inside the public_html directory in the server
now inside the server in public_html directory move the two files .htaccess and index.php of the public folder one level up in way so that the index.php file and the .htaccess file are directly inside the public_html directory (this way you don't have to include /public in your url but instead access the application directly when you visit your website)
configure the content of index.php you just moved from public up to public_html in a way that its links point correctly to the content of the app inside public_html
for example:
__DIR__.'/../storage/framework/maintenance.php'
becomes
__DIR__.'/storage/framework/maintenance.php'
so that the /.. is removed
and the other links too like:
__DIR__.'/../vendor/autoload.php'
becomes
__DIR__.'/vendor/autoload.php'
and
__DIR__.'/../bootstrap/app.php'
becomes
__DIR__.'/bootstrap/app.php'
The goal:
Make newly created Laravel6 projects' bootstrap assets layout work from Docker.
Symptoms:
Bootstrap assets work properly on local Laravel development environment (XAMPP -Apache- +Win10Pro), both the js and css are loaded well. But does'not work properly from local Docker (Win10-linux containers, Nginx+PHP+MySql+Redis), app.js and app.css runs on error 404.
Apache(local xampp):
Nginx(Docker):
What I did:
New Laravel project created, auth added, bootstrap, npm and node installed
properly.
Virtual Host settings (httpd-vhosts.conf) for Apache in xampp:
nginx.conf in nginx container
Virtual Host settings (default.conf) for Nginx in nginx container:
.htaccess file in my projectfolder /a_new_app_for_test/public/
docker-compose.yml for nginx
docker-compose.yml for app
What settings should I add/change in order to make assets loaded correctly?
I suppose it could be related to nginx settings compiled into Docker.
Any help are appreciated.
Thanks in advance.
Try to copy your whole project to the container volume, this way nginx will be able to see your files from public or resources folder.
volumes:
- ./:/var/www/
I deployed a simple laravel aplication on heroku but I'm getting a lot of 403 erros on my css and js files as you can see in the image. How can I solve this? I tried a lot of stuffs like changing the way to call the files {{asset('css/app.css') }} or that way /css/app.css none of these solved the problem.
https://imgur.com/FxSZKHl
Your files are accessible if you appended public/
http://saldoprojeto.herokuapp.com/vendor/adminlte/vendor/Ionicons/css/ionicons.min.css
Doesn't work
http://saldoprojeto.herokuapp.com/public/vendor/adminlte/vendor/Ionicons/css/ionicons.min.css
Works fine
so you need to tell Heroku to use the public directory as the root directory
Procfile
web: vendor/bin/heroku-php-apache2 public/
PS: the 403 forbidden status is for trying to access a file in the composer vendor directory which is not and shouldn't be publicly accessible
Hope this helps
So I am having an issue with pushing a Laravel app to production on a dedicated server's subfolder.
Server is run on Apache.
Url I want to push my app would be subdomain.domain.com/project
The structure of my dedicated server is
.cpanel
...
-laravel
-app
-vendor
-...
-public_ftp
-public_html
-folder
-contents of laravels public directory
-ssl
I know that in order not to expose my hidden files I am required to install it in a root directory, but this is not an option because I will be having multiple projects running under subdomain.domain.com/project-1, subdomain.domain.com/project-2 and etc... and all will have a separate laravel installation.
I need a hand in order to achieve that, can anyone give me some advice?
Managed to do it myself, the problem was when i was creating a symlink, so instead i just moved contents of my public directory to public_html/project-1/ and changed index.php path to /../../laravel/
The thing was that I have done it originally but I didnt expect that permissions for storage need to be manually set, that solved my issue and laravel works.
ALWAYS CHECK ERROR LOGS :)
You can place your separate folders in your subdomain with no problem.
The important thing is that you need to point the browser to public/ folder under your laravel projects.
You can create a .htaccess file with the command below in root folder of each project and perform a redirect.
Place the following command in your .htaccess file:
RedirectMatch ^/$ /public/
I have created a laravel 5.0 project with php artisan serve, now i need to know how to run laravel 5.0 project run without start php artisan serve, i have already browse lot of websites no one help me..
You need to change "server.php" to "index.php" then copy ".htaccess" from public to root directory.
See: https://stackoverflow.com/a/30053989/3948755
Laravel sever Folder is "public". There is an index.php so you can run you project from there.
Suppose if you using UbuntuOS then you have to create your local server in public directory. Suppose your folder name is laravel_test then go in that directory and run some thing like this
php -S localhost:8000 -t public
If you using windows then access public folder from URL.
localhost/laravel/public
Actually it's bad practise to access folder from URL but for local its good. You also can go with host entry. Just make sure that your target folder is "public" directory.
Normally you would have WAMP/XAMPP installed. You can access Laravel project like below
localhost/laravel/public
But this is not recommended. You should create Virtual host for example
laravel.local that pints to server-root/laravel/public.
this is how you create virtual host.
Or even better go for a Laravel Homestead .
How is your .htaccess file configured?
Try with localhost/laravel/public/index.php
Use http://localhost/projectName/public
It will be work. but in case if you have another Route and you can not access that Route and get the error like " Page Not Found " then please use the following command
sudo a2enmod rewrite
Now open the http://localhost/projectName/public/yourRoute
This is a little late but still applicable, what I like to do (using ubuntu 14.x+) is put my laravel project (let's say Project1) in my var directory, so it would be in /var/Project1, then symlink the public folder to somewhere in /var/www(+/html depending on apache version).
Symlink can be done something like this:
ln -s /var/Project1/public /var/www/html
This keeps your internal files off the grid so to speak, this is untested so if I've missed anything just comment and I will amend this post.
EDIT:
Obviously if your http root is /var/www/html you can put your project in /var/www/Project1
If you have access to xampp or wampp on your operating system you can more or less configure your virtual host like in the instruction below:
https://bestin-it.com/creating-virtualhost-on-your-local-computer-to-start-simple-index-php/
This instruction shows how to run it locally on your PC, but it works generally the same on any hosting portals. In most case in payed portals you have any web panels to configure your public folder that reference to /public folder in laravel folder's structure.