Homestead laravel projects suddenly no write access - vagrant

I have a couple of projects on a homestead box.
last week i cloned a project from git and i noticed that when the logger was called the logfile was created and written to but the second time it complained it had no write access.
I didnt pay attention to it much because i was in a hurry, so i just deleted the log everytime.
But now, returning to a laravel 6 project i worked on previously i see the same problem suddenly occur.
This time is different, instead of not being able to write to existing logs, this time its also not able to create the logs.
I did a 777 on the storage dir and the log file error went away but now it complains it cant write session files?!
ErrorException
file_put_contents(/home/vagrant/code/laravel6_project/storage/framework/sessions/hA3459VveGgYn761YijeEBcQgNylx0mToIRyLhkR):
failed to open stream: Permission denied
Why would something that worked fine suddenly break in regard to permissions.
I dont want to go on and chmod 777 everything everytime over and over again.
All files have owner: vagrant:vagrant and this is what it always was as far as i can tell.
anyway, i figured perhaps something changed with an update or something so now in the vagrant machine i tried
sudo chmod -R vagrant:www-data
but its being ignored... folder is still vagrant:vagrant.
stumped...
There are lots of questions on this exact problem with many more times of different suggested solutions but none work for me.
Im starting to suspect the virtual machine is corrupted or something..
any ideas?
someone suggested to check if perhaps the wrong user was specified in:
/etc/php/7.3/fpm/pool.d/www.conf
perhaps it said user = www-data instead of user = vagrant
all the other versions like:
/etc/php/7.1/fpm/pool.d/www.conf
/etc/php/7.2/fpm/pool.d/www.conf
/etc/php/7.4/fpm/pool.d/www.conf
indeed all had: user = vagrant but the /var/log/php7.3-fpm.log says:
user = www-data
so i was very confident i had found the problem but after changing it to user=vagrant and restarting apache still the same error.
going nuts...

So,
editing the /etc/php/7.3/fpm/pool.d/www.conf and setting:
user = vagrant
group = vagrant
fixed it , but only after restarting the VM!
simply doing:
sudo apachectl restart
somehow didn't cut it.

Related

Unable to modify permissions of folders on Mac (Mojave)

I am new to Macs and I am trying to run some interesting stats on my iMessages using the code runner extension on VSCode. I've been following this post: https://towardsdatascience.com/heres-how-you-can-access-your-entire-imessage-history-on-your-mac-f8878276c6e9
However, when I run the line conn = sqlite3.connect('/Users/<username>/Library/Messages/chat.db')
I get the error sqlite3.OperationalError: unable to open database file
Based off what I can tell my issue is that VScode doesn't have the right permissions to access the ~/Library/Messages folder and possibly the chat.db as well. First, I ran ls -l on Library and the result is drwx---rwx for Messages. So I tried to use both chmod a+rwx Messages and sudo chmod a+rwx Messages to open permissions to everything but got the error chmod: Unable to change file mode on Messages: Operation not permitted both times.
Am I doing something wrong and/or is there a better way to do this? Or is it just not possible to change the permissions of this folder?
After some more creative searching I discovered that it was an Issue with Mojave's System Integrity Protection (SIP) and can be solved by giving the desired apps full disk access in Settings>Security&Privacy>Privacy>FullDiskAccess.
Solution found here

Homestead.test default file gives [No input file specified] Ubuntu

I just installed Ubuntu 17.10 and I want to try create a website using Laravel, but I hit a rock, I followed the instructions. step by step on the official website. But I think something is missing,
Because I haven't touch / edit anything in Homestead.yaml, so basically it would working right?
I already use vagrant up --provision. already create the ssh key. I already googled it and try several ways but it doesn't fix it, I already turn on my XAMPP as well
Sorry but I never touched Ubuntu before, so I'm very blind using this OS
Here is my Homestead.yaml file
Homestead.yaml
and the directories of /home/workspace/ and /home/workspace/Homestead/
~ Dir
Homestead Dir
my Hosts file
Hosts File
EDITED:
I just create a new project in ~/Homestead/Projects/[it goes here] because the default laravel installation is working already, so now I want to create a new project in Projects folder inside Homestead, but why it redirect the url to https?
The folders
in this screenshot: https://i.stack.imgur.com/4cxGy.png Your ~/code folder appears to not exist, which means Homestead will not map it. Create that folder in your Host OS (Ubuntu 17) and then run vagrant destroy && vagrant up If you still have issues post the entire output here for us to check.
For my last question, why when I tried to open my new projects is always giving me this error your internet connection is not private. it's because I'm using .app or .dev in the of the site name, the problem is from google chrome, so I need changed it to .test then it's working perfectly.
I got the answer from this site
https://laracasts.com/discuss/channels/laravel/chrome-blocked-localhost-with-error-your-connection-is-not-private

Users and groups for NetBeans and Laravel 5

I'm trying to work with Laravel 5 on NetBeans.
Now, I'm trying to var_dump through Laravel 5 to understand how the application works, and I keep getting 500 errors when I have even a simple syntax error in my code, and it doesn't output the error log like normally. From what I understand by research is that it's caused by Laravel not being able to write into /storage/ folder in Laravel.
I created a new group netbeans and added www-data user to it, so right now I'm trying to figure out how do you install it so that Laravel 5 and NetBeans could 'recognize' each other. Right now I have NetBeans installed with apt-get install, and now that I've changed the Laravel 5 project rights with:
chown -R www-data:netbeans laravel5/
Now I can't access Laravel's project files with NetBeans because of right issues. All this is sort of confusing to me, so my question is:
How do I properly setup NetBeans and Laravel so I could edit my Laravel project folders files and somehow have Laravel access /storage/ folder inside Laravel, so I would not see 500 error and a blank page on every syntax error I make?
P.S: I tried to be as precise and explanatory as I could be
Check write permissions on storage folder!
Try:
sudo chmod -R 777 storage/
(i known that 777 is a bad thing to do, only do this to test).
After reading enter link description here it could also be a problem of permissions to write to the log folder. See the last comment from shiny

Vagrant SSH Permissions

I am new to Vagrant and get the following error on vagrant up or vagrant ssh:
The private key to connect to this box via SSH has invalid permissions
set on it. The permissions of the private key should be set to 0600, otherwise SSH will
ignore the key. Vagrant tried to do this automatically for you but failed. Please set the
permissions on the following file to 0600 and then try running this command again:
[...]/.vagrant/machines/default/virtualbox/private_key
I have run:
$ sudo chmod 666 [...]/.vagrant/machines/default/virtualbox/private_key
I also tried (600, 777) but still get the same error.
Please can someone tell me what is wrong and how to fix it?
I just had this issue, and I worked around it moving the private_key file to another place, changing its permission, and then creating a symbolic link at the original place.
So,
$ mv [...]/.vagrant/machines/default/virtualbox/private_key /some/path/where/you/can/change/permissions
$ ln -s /some/path/where/you/can/change/permissions [...]/.vagrant/machines/default/virtualbox/private_key
If you're using the Windows Subsystem for Linux (WSL), this error can occur when you're trying to vagrant up in a directory that is outside the user's home directory.
From the Vagrant docs:
If a Vagrant project directory is not within the user's home directory on the Windows system, certain actions that include permission checks may fail (like vagrant ssh). When accessing Vagrant projects outside the WSL Vagrant will skip these permission checks when the project path is within the path defined in the VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH environment variable.
Changing the VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH to the current working directory (or a directory above it) can fix this. For example, if your project is in /mnt/c/www, then set the environment variable accordingly:
export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH="/mnt/c/www"
I got the same error now. The problem happened because i was trying to do vagrant up in an NTFS partition, just like the error message tell me.
So i created an directory link in my ext4 partition and an simbloc link in my NTFS to solve this. Works Fine now!
Thanks!
I had this same problem and turns out chmod seems to be working fine but is not actually changing permissions, my files where at an NTFS partition, try changing them to an ext4 or similar.
Got this error using otto (which layers on vagrant)
It is def filesystem related, have a fat partition to allow use with windows (used to, no longer). When the permissions couldn't be set on the partition I just copied the whole directory over to my user directory (as I always should have).
Was using git so I just reset to head to get back to my starting place... re-ran:
otto compile
otto dev
up and running now.

Enabling CodeIgniter logging in Ubuntu

I'm trying to enable logging for CodeIgniter in Ubuntu. However, nothing seems to be written in my application/logs directory. Here's what I've done so far...
In the controller login.php, I have the following lines:
public function index(){
log_message("error", "Logging sanity check.");
}
I set it to error just to make sure it gets logged no matter what. Then, in my config.php, I set log_threshold to 3 (just to be safe).
Then, in the terminal running as superuser, I do chmod 666 logs and chown root logs.
Now no matter how many times I visit index.php/login, nothing seems to get logged. I've tried that both in a browser ran as superuser and as normal user. All I get in application/logs is an index.html which displays "Directory access is forbidden." I've even tried resetting XAMPP. What have I missed?
Apache on ubuntu doesn't run as root, that's for one. Secondly, directory permissions must be rwx, which equals to 7. So you have two options:
1) Relax writing permissions for everyone on the logs dir with chmod 777 logs, or
2) chown the directory to the user that's running apache (apache)

Resources