I am trying to figure out why all the CSS and Javascript files are being display as empty files on a Laravel 5.6 project running on Ubuntu 16.04 LTS with Plesk 17.5 Server Onyx. This happened after deployment.
I was reading a couple of old questions and I've tried most of the solutions without any luck:
Note #1:
Only CSS and Javascript files are displayed as empty files, routing works fine for other files.
Attempts made so far:
Moved the file .htaccess from public to the root project folder.
Added guo+w permissions to storage and bootstrap/cache
Used mix('css/app.css') and asset('themes/default/css/style.css') to access to CSS & JS files. I've also tried relative and full-qualified paths.
Note #2:
If I access in the URL with public/path/file.css I can see the file proplery. But whenever I change from mix('css/app.css') to mix('public/css/app.css') I get Undefined Index when I set the debug=true.
Well, maybe there are more attempts that I don't remember right now. Any suggestions to solve this "issue"?
Related
So for context, the application is a portal for my company that we have hosted on the main production server. Then we have the developer version on a different server. Same exact application but on a different VM and has a different url. That was all set up before I got put in charge of it. Now we want to make an alpha server as the dev server can affect the main database. So for the alpha we need to pretty much have it be exactly like dev, but once it's built, copy the database to a separate db and disconnect it from the main one.
But right now the issue is setting it up. I got Apache2 setup and the site all put together. Now the issue I'm running into is that it's showing the site but not running any of the CSS or JS. The laravel log shows this:
[2019-02-20 11:33:51] local.ERROR: User: test Route:
https://test/app/portal/final.css File:
/var/www/laravel/bootstrap/cache/compiled.php Line: 8335
Class:
Symfony\Component\HttpKernel\Exception\NotFoundHttpException
Exception: exception
'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in
/var/www/laravel/bootstrap/cache/compiled.php:8335
The same error comes up for the js file but I don't want to post that as it is the exact same error.
And the output of my site right now is just a bunch of links and text in a left tabbed column on the left.
I assume this is due to something not being installed or a config file not reading properly. The code for the site is all just git fetched so it's exactly the same as from the other two servers. The only difference is packages installed into the actual server. It seems that the css and js files aren't loading for some reason. I tried a bunch of other threads and fixes with no luck.
PHP Version is PHP 5.6.40-1+ubuntu18.04.1+deb.sury.org+1 (cli)
Apache2 for the server.
Composer version 1.5.6
Laravel 5
Thank you for any help.
Apache Config: https://drive.google.com/open?id=1im9voo0xqlyuf48gX-JJsRu00f0ym1UX
The CSS and JS files are in the public folder under css and js folders respectively.
Like I said, everything works just fine on the two servers already in place and the filesystem and code is the exact same at this point. The only thing that can be different is apache, laravel, and php.
Are you using Laravel mix with version ? If so, you need to import the css like :
<link rel="stylesheet" src="{{mix('final.css')}}">
or use the asset function just to be safe for any CSS/JS you need to import.
Three possibilities...
Apache root folder
First, the document root in your apache config (or site-enabled) needs to be the /public folder. In which case your request wouldn't hit the .htaccess and redirect to index.php and you'd get a bad route error. So this is a less likely option.
Compile Your .css and .js
You haven't compiled the .css and .js using Webpack (or gulp or whatever if you don't webpack) on the new server. In this case, the .htacess would send the request to index.php and Laravel would look for a route (which is what your error looks like) and then you'd get an error about an invalid route. Note the .css and .js should be in the .gitignore if you use git to clone the project, making this an easy thing to overlook and to have happen. Nice thing is that if node and npm are setup and you use webpack, it should just be a:
npm run development
The sad thing is getting node and npm and webpack all working isn't always as simple as it should because of versions and such.
Missing or not reading the .htaccess
Finally, your .htaccess isn't being read or didn't get copied over, which would mean that that / route would magically work, but any other routes wouldn't... Though, in that case your .css and .js should still work -- but not likely.
I have written code in laravel and have managed it with GIT.
Now I made some changes in the homepage which is not reflecting on the server but working well on the local system.
Things I tried to fix the issue
Cleared the cache, views also manually deleted from the framework folder in storage
Changed the cache method from file to array
Created a new server and deployed the code from git but got the same issue. (Yes the code in html file has the updated code and i can see it using vi and cat).
More importantly i can change the files in other html files in admin folder and it works fine and update is reflected in the browser.
i also tried deleting the view file but it does not work also tried copying the file with new name and using the view but no change in the result.
Please provide me with solution if anyone has ever faced it.
There was a index.html file in the public folder. Which was being called
I've tried several versions of WAMP: 2.0 2.2 2.4 2.5 32 and 64,
and I've tried Apache stand alone on WINDOWS 7.
Root pages load but css, js and any other included files in sub-folders within a site do not load and Apace logs an access denied error.
It happens if the site is in the wamp/www folder or is an Apace alias.
I've tried gone through each step of the documentation, tried every config setting, install option, folder permissions, every idea found here and in every blog post Google returns in the search and nothing has worked. Allow all, vhosts, all those suggestions have failed.
What is up with WAMP/Apache on Windows 7? It worked fine right out of the box on my old XP machine.
thanks everyone hope someone has found a fix...
best, omcode
If you take a look into the source of the page (in your Browser), you'll quickly see that all your linked assets are using bad, non-resolving, or the wrong: path, domain, host, IP.
Possible walk trough's
check if rewrite_module is loaded if not check it and restart wamp.
Avoid relative path use absolute.
Check if the path & file-name is correct.
One of these will definitely be helpful for you.
For some reason when I create a project in netbeans and go to run the project it also loads the xxamp index file and not the project index file that is apart of the codeigniter installation.
http://screencast.com/t/qOSH80wPgvf
Edit:
Here is my file tree I have right now set up for my project. Why Netbeans creates an important files folder I have no idea for my CI project. I have edited the index file to have the application and system variable to both have the ../system or applicaton as its value. I have changed the Web Root inside the project properties to have a value of public_html and I have also changed the value of the Index File field to say index.php.
After doing this and running the project I would expect to get the default Welcome to Codeigniter page and I don't. I am receiving a message that shows the following. Any ideas on why this is?
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.4 (Win32) OpenSSL/0.9.8y PHP/5.4.16
Projects
- MyFirstProject
- Source Files
- application
- public_html
- assets
index.php
- system
- Test Files
- Important Files
- Include Path
I've tried doing some additional research on the topic and have yet to come up with a solution.
Edit 2:
Any ideas from anyone?
Your problem is likely related to your choice of folder layout. Which I assume you do, for "security reasons". That said, NetBeans isn't a server. Its an IDE, so you can't manipulate it the same way you would the server.
Most servers by default define your "root" folder as "public_html" or "www" as far as where it looks by default to serve files for public consumption. Through the use of PHP you can tell the index.php that comes with CodeIgniter to look up one directory outside of the defined root and have it read the file(s) accordingly.
However, to setup a project in netbeans and have all files and folder accounted for accordingly you need to tell it that all your files start in whatever folder they reside. So it can load all the files and read from them respectively. This in essence and in respect to server logic is telling it that the folder that houses
application
public_html
system
is the define root path. So inadvertantly by breaking out of the design of codeigniter and placing the core files outside of what would be your defined root on the server is breaking your project. There is not an index.php depicted in your listing above at the same level that those folders are in. If there is, its the index.php for xxamp that keeps loading for you by default.
What you need to do is stop trying to implement your "security measures" and put them in the right order. Or.. not include that folder in your project telling it the one with assets and index.php is the root path. If netbeans is smart enough it will find the files and folders outside like the server will.
Right click on your project and go to properties. Make sure that in the run configuration the URL is correct and the index file is properly set up and matches your directory in xxamp.
after downloading codeigniter open index.php file and there set your path correctly to your
application folder because i think you putted your index.php inside public_html folder so
the path which is set by default in index.php is not working and can not find application folder, try to fix it and it will work fine your problem is not with netbeans.
I have a shared hosting account in which I want to install my symfony 1.4 and deploy and application. I bumped into some issues because of the inability to change the apache config on the production server.
the structure of my web server is:
hosting_account_name
html <--- public folder
I then moved all files in symfony local app folder to my hosting_account_name and put the web folder content in html
So i got the following structure:
hosting_account_name
apps
cache
config
data
html
css
js
index.php
.htaccess
frontend_dev.php
lib
log
plugins
test
and i added the line bellow to config/ProjectConfiguration.class.php
$this->setWebDir($this->getRootDir().'/www');
I have a couple of issues though:
1. when i access the frontend_dev.php no images are due to the fact that symfony expects some files to be under a sf/ folder. Should I move the files there?
2. Index.php gives an error. Even with display errors set to yes and 500 internal server error is presented.
Also i had to set my permissions to 777 on cache and log. Their are under the folder html so that's ok for security right?
First, you said that the "public" folder is html, but you used $this->setWebDir($this->getRootDir().'/www');. Is it html or www? (Just to make sure)
Then: setting the sf_web_dir should work like you expected, so that shouldn't throw any errors.
To link the /sf Symfony folder, you will need to add something to your apache configuration. As described on the first page of the Jobeet tutorial, you will need to add an Alias to the /lib/vendor/symfony/data/web/sf.
If you don't have access to the httpd.conf, you could also add this to your .htaccess.
777 for log and cache is ok. It's what the default project:permissions task does as well.