CSS not formatted correctly in vagrant environment - css

I have vagrant setup as my local dev environment. When vagrant is up and I edit my CSS file and look at its source in the browser the new CSS I have written is not in the file and the file is now appended by loads of question marks:
��������������������������
If I do vagrant halt or destroy and then bring it back up the CSS file is fine with the new code visible and formatted correctly and no sign of the question marks. As soon as I edit it again the same things happens. Obviously I don't want to destroy and create vagrant every time I make a CSS change.
Any ideas on this?
Update: I have been told this may be to do with not having NFS installed with vagrant - I am on ubuntu and my files are within an encrypted home directory so I believe NFS doesn't work - any other solutions?

I had lot of problems with not having nfs activated on my VM
What information do you have when you run a 'ls -la file.css' on the file ?

Perhaps you can disable sendfile based on this thread:
JS and CSS files in vagrant not properly encoded when saved outside of the VM
Set enableSendFile to off in httpd.conf.

Related

Local By Flywheel - Error establishing a database connection

I was working on a website for a client a week ago and I came back to make further edits, but whenever I want to access the website, it reads:
Error establishing a database connection
I checked my wp-config file and everything is untouched; I did not touch one single line of code here when setting up my new Wordpress project in Local by Flywheel.
All my other local websites work except for this one. I've provided an image of my workspace just to make it more clear.
Looking at this image, the MySQL Version is a little bit off. The version should in fact be 5.6.37, but instead it's reading an older version of MySQL.
I did try closing and reopening Local by Flywheel, but it had no effect.
Any help appreciated. Thank you!
Right click on the site name and click on “Reveal in Finder” in Local by Flywheel.
Compress the folder containing all your site in a *.ZIP file (normally there must be at least the “app” and “logs” folder, sometimes “conf”).
In Local by Flywheel, import the site manually in FILE / IMPORT SITE, choose the Zip of your site
Normally, it reinstalls the site and recreates the Database … for me it’s work (on Windows and on Mac)
Are you able to compare your wp-config.php file in the broken site to a site that is using the same MySQL server?
I know you said that the file is untouched, but check again that all of the define parameters are correct.
Next I would suggest logging into your MySQL server using the credentials you have listed in the wp-config.php file and ensure you are able to access your database.

image editor in wordpress not working

my wordpress image editor is not showing image to crop. It shows the image in media library but when i click to edit image the image is not showing. The Image url it is showing is
wordpress/wp-admin/admin-ajax.php?action=imgedit-preview&_ajax_nonce=0b98ac9553&postid=415&rand=29813
If you still need the answer, this is because your server does not have the PHP5-GD library installed. You can install using putty like this:
sudo apt-get install php5-gd
If your server is managed, ask your hosting company to install it: http://php.net/manual/en/book.image.php
This should solve your problem:
Removed all blank lines and whitespaces in /wp-content/themes/name/functions.php + the including files.
Removed all blank lines and whitespaces in /wp-config.php
Check that php5-gd is installed.
Permissions changed to 777 for testing /wp-content/upload/ + sub folders
Removed closing ?> tags in /wp-content/themes/name/functions.php + the including files.
Turned off all plugins.
Rename your and changed to default theme.
So we were having the same issue you asked above and eventually found the issue. When you install PHP on a windows machine the PHP.ini file initially points uploads, errors, etc to the Windows/Temp file. In order for things to function correctly you have to change the IIS_IUSR security level to have at minimum Read/Write on that folder, we changed it to full control. For whatever quirky reason WordPress sets the file permission from the folder it originates from (i.e. the Windows/Temp folder) when it dumps it into the WP-Content/Uploads folder. Another quirky thing is on Window's servers anytime you shut down and restart the server all the folders in the Windows folder revert back to default security settings, meaning each time the server shuts down you have to go back to that Temp folder and reassign permissions for IIS_IUSR

I add a line of text to my CSS file, garbage comes through the browser

I'm using Vagrant to manage a VirtualBox instance of Debian Wheezy with PHP 5.5 and nginx 1.4.4. My local environment is Mac OS X 10.9 with PHP 5.5 and Apache 2.2.24. I have a synced directory that points to my document root for this particular project.
My local machine has a VirtualHost setup that also points to the document root for this project. Therefore, I actually have two different URLs that I can point my browser to, and the same code will be executed. One URL hits the virtual machine, while the other URL hits my local Apache installation.
I've been able to edit several PHP files with no problems. I make the changes locally and they immediately show up on both the virtual machine and my local web server. However, whenever I try to edit CSS, things get bizarre. I'm trying to add a single line of CSS to a static CSS file. Something along the lines of:
.body {margin-top:50px}
When I make this change, the virtual machine goes nuts. I'm not sure if it's sending a corrupted file, or if it's just appending a bunch of weird characters at the end of the CSS file, but I can't even paste them here. I did a Charles dump of the request for the CSS file and the response looks like this:
I've looked at the file in vim through the virtual machine. I've looked at the file using multiple text editors. For the life of me I can't find anything wrong with it. When I load the exact same file through my local Apache installation, it works just fine:
Notice that the body declaration appears between button and footer, and there are no weird characters at the end of the document.
The other thing that I noticed is that my the whitespace is being manipulated at some point as well. The CSS file in question uses four spaces for indentation, but in the response from the virtual machine, the lines only have two spaces of indentation. You can't see it from the pictures because they're formatted by Charles, but I looked at the raw data. It's truly bizarre.
Do you have any idea what is causing the manipulation of my CSS file when it is being served via the Vagrant/nginx combo vs my local/Apache combo?
EDIT
I pasted some of the characters into a hexadecimal converter and it converted all the characters to question marks. I tried a binary to decimal conversion and they all turned into �, which from what I can find is "used to replace a character whose value is unknown or unrepresentable in unicode". I ran file --mime on the file and it returned rental-application.js: text/plain; charset=us-ascii. So...nginx settings maybe?
I'm having the exact same issue with JavaScript files. If I vagrant destroy and vagrant up is the only way I've found to resolve the issue so far. It doesn't make for quick troubleshooting when I have to reboot my VM between file saves.
Every method that I use to look at the file works. The only issue is when it is served through nginx, which makes me think I have some type of encoding setting wrong. It's a mostly stock setup.
More bizarre
If I mv rental-application.js rental-application.html and load the page in my browser, it comes across perfectly. The same applies if I change the name to rental-application.php. However, as soon as I change the name to rental-application.js or rental-application.css, my changes disappear and the � characters re-appear at the end of the document.
Even MORE bizarre
I can create a js file on the VM and it will load fine via the VM nginx server. If I subsequently modify the file I just created and reload it, the changes don't appear, just the garbage characters.
If I mv that file to a different name that ends in .js, the garbage character problem still persists. However, if I then cat the contents of the renamed file to a new file with the original name, all is well in the universe.
Just so if people end up here for the same issue, they have the solution on how to resolve this: you need to turn off sendfile() in your web server' settings.
For Apache: EnableSendfile off
For Nginx: sendfile off
Quick explanation: https://coderwall.com/p/ztskha
You can find more online if you need more details.
Now you can get a beer and enjoy your static file being transferred properly, not more corrupted files :)

vagrant/puphpet: adding a custom nginx default conf file

i use Puphpet to create a local testing vagrant /VM servers and my question is:
I ssh into the VM to change my etc/nginx/conf.d/default.conf config file, but every now and then when either i have to to or choose to i destroy the said vm to mainly re-create or because of issue, i need to repeat the above process of having to update a few config files.
Is there a way say within the vagrantfile or the comman.yaml (puphpet) file to actually add this automatically so i don't need to do this at all.
You could create a shell script in puphpet/files/exec-once[1] to replace your default.conf file.

Red filename in Ubuntu CLI (Vagrant)

I am building a FuelPHP application running on an Ubuntu VM powered by Vagrant.
I am trying to include a CSS file on the global wrapper for all my pages, but Firebug tells me it isn't there. (the file path is correct in my <_link rel...>).
The CSS file is actually a compiled from a bunch of LESS files using an app called LiveReload for Mac.
The Apache server on my VM is set to serve from a mounted folder on my Mac, anyone who has used Vagrant should know what I mean by that.
Anyway, LiveReload dumps the CSS file in the correct place, and is populated on my Mac:
However, SSHing into the VM and examining the CSS file leads me to believe that something weird is happening. Firstly, the filename is in red (but it exists!):
Secondly, opening it with a text editor (nano in this case) shows it to be blank, despite it being full on the Mac:
So my question is... wtf is going on here? Why is it showing empty on the VM? Why is it red? Why can't Apache find and serve it?
EDIT, still struggling with this.
I added my own 'test.css' file and it loads that fine. Just not the app.css generated by LiveReload. There's something wrong on the VM. Can anyone help? It's one of those annoying things thats holding up my development.
Here's the stack trace (although i'm sure it has nothing useful in it):
If I guess right than you have a wrong mod rewrite rule which redirects your request to a php script which tries to include a file which does not exists.
So check your .htaccess file
Argh, renamed the file to appcss.css instead of app.css and it works. Changed it back, it doesn't. System musn't like that name for some reason. Annoying the amount of time i wasted, but fixed now!

Resources