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/
Related
I am developing a Laravel-Vue app using Laravel/Homestead. The Vue code is compiled using laravel-mix, all using fresh installs (it's a new project).
I would like to be able to test my Vue components 'outside' of the Laravel project. So I figured I just
1) Add a script in package.json like this
"devser": "cross-env NODE_ENV=development webpack-dev-server",
2) Add an entry point main.js file in which I can run my components isolated
import Vue from 'vue'
import Example from './components/Example.vue'
new Vue({
el: '#app',
render: h => h(Example)
})
3) add a webpack.config.js file to configure webpack for this isolated app. I just took it from the vuejs template: webpack-simple and changed the entry point path.
So far, running the devser script does compile the code without errors, and apparently, the code is served at (webpack output)
Project is running at http://localhost:8080/
webpack output is served from /dist/
404s will fallback to /index.html
However, opening localhost:8080 gives an error: This site can't be reached, localhost refuses to connect. So I have been searching for a while and found things about devserver proxy's and stuff like that but I don't understand what I would need to add to my webpack.config.js.
Maybe good to note: I am not interested here in calling the Laravel backend from these Vue components, it is just for testing the components in an isolated way. My next step was to add Vue-storybook to the party to do this.
To summarize, I am looking for one codebase (Laravel + Vue on Homestead) where I can separately test the components. Any help would be appreciated.
EDIT: If I am not logged in to the vagrant machine, I can navigate to the project folder and run
npm run devser
which serves the project at localhost:8080 and this URL does work. So I have a workaround for now.
It sounds like you are running webpack-dev-server inside your Homestead box. If so, you need to forward port 8080 from your host to the Vagrant box:
https://laravel.com/docs/8.x/homestead#forwarding-additional-ports
Add this to your Homestead.yaml:
ports:
- send: 8080
to: 8080
Then, run vagrant reload --provision to apply the changes.
Now you should be able to view http://localhost:8080/
Hello there we am currently developing a Laravel application. I want all my team members to work locally so we decided to use Docker for our local development environment. I did a little research and there is a project called laradock. After installing it I am supposed to go to http://localhost and the project should run. But I get this:
I am using apache2 and mysql
tl;dr
Go to ./laradock/.env and search for APACHE_DOCUMENT_ROOT then edit that line to this:
APACHE_DOCUMENT_ROOT=/var/www/public
Things to do after the change
For this change to take effect, you have to:
Rebuild the container: docker-compose build apache2
Restart the containers: docker-compose up
Explanation
As mentioned by simonvomeyser on GitHub this is a recent addition which had the same effect as rodion.arr's solution but this way you can leave the original config files untouched and use the .env file to store all your project related configurations. Obviously, since this is a docker config change, you have to rebuild and restart your container, as rodion-arr and 9bits ponted it out in the same thread.
Check you apache configuration (in my case [laradock_folder]/apache2/sites/default.apache.conf file).
You should have DocumentRoot /var/www/public/.
I suppose you have /var/www/ instead
I'd like to use nginx within a dokku/heroku setting with the ssl module enabled:
+ --with-http_ssl_module
What is the easiest way to achieve that? Cloning the php buildpack alone does not do the trick. How can I recompile the nginx binary? How can I rebuild a buildpack?
ok - i did it like this:
forked the buildpack
changed the nginx dependency to 1.10:
$require["heroku-sys/nginx"] = "~1.10.0";
in platform.php
then compiled and stored a new nginx package (based on the official heroku one)
stored the package somwhere public on amazon s3
added to the app environment the line export HEROKU_PHP_PLATFORM_REPOSITORIES='https://s3.region.amazonaws.com/your-bucket/packages.json'
If deploying an app, nginx will be loaded from your custom repository and installed within the docker image.
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/
Just installed Lumen framework.
hit the link http://localhost/lumen/public/ in my browser and got this following error, anyone got any idea about it?
Traced it back to the app.php file in bootstrap folder.
if You want to access lumen project without "php artisan serve"
$app->run(); replace with
$request = Illuminate\Http\Request::capture();
$app->run($request);
from this path yourlumenproject/public/index.php
Open your terminal in the root folder run the following command php artisan serve.
Lumen development server started on http://localhost:8000/
if you want to serve your app in local development you can do this :
php -S localhost:8000 -t public/
and it will serve in localhost in port 8000. hope this help.
Note : I'm using Laravel Framework version Lumen (5.2.4) (Laravel Components 5.2.*)
At the moment Lumen only runs in the domain root.
(I've submitted a PR that fixes this but it has yet to be merged)
You have to create a Virtual Host on your local webserver and point the document root of that to the public directory. After that you can access your app with something like: http://lumen.dev.
Guide for Virtual Hosts with nginx
Guide for Virtual Hosts with Apache
A simple alternative to setting this up manually is Laravel Homestead. It is an official Vagrant box made for Laravel, that allows you to easily get your development environment up and running.