unable to read and write htdocs folder in XAMPP - laravel

I am creating a laravel project within /Applications/XAMPP/htdocs.
I used following to apply the read and write privilege to htdocs folder in XAMPP folder
sudo chmod -R 777 htdocs
Then I create the project within /Applications/XAMPP/htdocs
create-project laravel/laravel [Project Name]
It shows error
Installing laravel/laravel (v5.6.12)
[ErrorException]
mkdir(): Permission denied
Does anyone know how to solve this problems?
Appreciate for the help
Updated:
I solved this problem by installing the lower version of XAMPP.

Change document root of the server.
I assume your xampp installation folder is
/opt/lampp
Run sudo gedit /opt/lampp/etc/httpd.conf on the terminal to edit httpd.conf file.
You have to change these two lines.
DocumentRoot "/opt/lampp/htdocs"
<Directory "/opt/lampp/htdocs">
Then change /opt/lampp/htdocs directory to any directory in your home folder for example /home/yourUserName/htdocs
Note: Replace "yourUserName" with your username.
After that, those two lines should look like
DocumentRoot "/home/yourUserName/htdocs"
<Directory "/home/yourUserName/htdocs">
After saving the changes run sudo /opt/lampp/lampp restart to restart apache
Now create local projects in your /home/yourUserName/htdocs directory without any permission problem.

sudo chmod 777 htdocs
You should use -R if you are allowing a file. You shouldn't use -R if you are allowing a folder.

Related

Laravel 8 is not working correctly, error "file_put_contents"

I'm having some weird problem with Laravel 8.
I installed the framework and started working with it, but when I try to edit / delete some controller, my Ubuntu asks for a password.
Another problem. My controller displays records on a page with paginate(15) pagination, but instead of the usual numbers, I get the Previous & Next direction, and when I try to change something in the html template, I get an error file_put_contents(/var/www/storage/framework/views/c6d615eb91fe3a0edd449165e94d034703bbb84d.php): failed to open stream: Permission denied and this problem can only be cured by clearing the cache, but this should not be the case.
Error #1: Your user does not have write permissions for those files/directories. Did you use sudo while installing or copying anything? Do you have these files outside of your home directory? (/home/username/)
Error #2: Your webserver (nginx, apache, etc.) probably does not have access to the application's /storage/ directory.
SSH into the server.
Navigate to the projects root folder.
Run the following commands to make the directories writable:
sudo chmod -R gu+w storage/
sudo chmod -R guo+w storage/
sudo chmod -R gu+w bootstrap/cache/
sudo chmod -R guo+w bootstrap/cache/

Mac Laravel file_put_content fail permission problem

I have a project work in laravel (Mac) but I have a problem:
file_put_content fail () Permission denied.
I try below command
cd /path to htdocs
sudo chgrp -R _www storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
but it's not working
anyone know how to solve this problem. I use XAMPP, is that possible to set my XAMPP htdocs folder permission read&write, so I don't need to worry about this anymore
It's coming from cache. Delete bootstrap > cache > config.php file.
Then use php artisan config:cache.
you need to provide write access to your storage folder too.
try running :
sudo chmod -R 777 storage bootstrap
It will provide read & write and execute permissions to both storage and bootstap folder.

Set CHMOD 777 for all folder and subfolder in catalog/view/theme/machiko/skins! (Windows)

I'm newbie in opencart and I'm trying to install a theme in opencart 3.0.3.2 I was following their instructions and there is a step to add skin. Whenever I try to add skin it gives me error :
You need to set CHMOD 777 for all folder and subfolder in catalog/view/theme/machiko/skins!
I've also tried to setup opencart on server using cPanel and get the same error (In cPanel I've given 0777 permissions to all required folders). Can anyone please help me Figure out where is the problem and how to solve it.
I've provided a screenshot where I'm getting error.
You don't have permission for install new theme at this folder, with this command you set the permission for read, write and execute the all files in the current directory
chmod 777 -R ./
-R will recurse through the whole file system

How to install Laravel as Apache user

First off: I'm very familiar with Composer and also Symfony and some other MVC frameworks.
I tried the following installation documentation, but I'm stuck on how to properly install a laravel project as "apache:apache" under "/var/www/html" on a CentOS 6 virtual machine.
I ran the composer global require "laravel/installer" command, and it says to put "~/.composer/vendor/bin" in your PATH. So I presume this command (laravel install) is done as a normal user (not root), and the folder will exist in your home directory when run.
I added to my path by editing my /etc/profile to include this. But when I try to run laravel new laraveltest in the /var/www/html folder (owned by apache), I get:
[abunk#Alvin-CentOS6 html]$ laravel new laraveltest
Crafting application...
PHP Warning: file_put_contents(/var/www/html/laravel_572e877d514bacbb7381860b8307a067.zip): failed to open stream: Permission denied in /tmp/.composer/vendor/laravel/installer/src/NewCommand.php on line 122
PHP Warning: ZipArchive::extractTo(): Permission denied in /tmp/.composer/vendor/laravel/installer/src/NewCommand.php on line 140
PHP Warning: ZipArchive::close(): Invalid or uninitialized Zip object in /tmp/.composer/vendor/laravel/installer/src/NewCommand.php on line 142
Composer could not find a composer.json file in /var/www/html
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Application ready! Build something amazing.
So then I copied the folder /home/abunk/.composer to /tmp/.composer; and then I ran su -s /bin/sh apache -c "laravel new laraveltest" from the /var/www/html folder (this should run as apache).
But instead I get this:
[abunk#Alvin-CentOS6 html]$ su -s /bin/sh apache -c "laravel new laraveltest"
Password:
Crafting application...
PHP Warning: proc_open(/dev/tty): failed to open stream: No such device or address in /tmp/.composer/vendor/symfony/process/Process.php on line 290
[Symfony\Component\Process\Exception\RuntimeException]
Unable to launch a new process.
new [--dev] [--] []
So my question is (or maybe this is really a bug): How do install as the apache user? Any recommendations?
I could do this as root user, but I think it's a bad idea to run Composer as root user.

Laravel 5 - ErrorException failed to open stream: Permission denied

I've just git clone a repository of mine containing a Laravel 5.1 project. I've gone through the normal steps to get it up and running (setup the webserver, db, etc). I've now gone to the web address I configured and i'm getting the following error message:
ErrorException in compiled.php line 6648:
file_put_contents(/3c7922efc24ab13620cd0f35b1fdaa61): failed to open stream: Permission denied
Any idea's what folder it's trying to access?
I solved the problem with this solution, clarifying that if you have Windows, you apply lines 1 and 3 and it works the same.
php artisan cache:clear
chmod -R 777 storage/
composer dump-autoload
To solve this problem I needed to create a few folder's that were missing from my install. You require the following folders to be readable and writable by your www user:
/storage
/storage/cache
/storage/framework
/storage/framework/sessions
/storage/framework/views
/storage/framework/cache
/storage/logs
Also, set the folder permissions to 775. From the root directory run the command: sudo chmod -R 755 storage
If nothing help you and if you work on windows with docker it can be the issue that wrong symlink you have, you can try:
ln -s /var/www/storage/app/public /var/www/public/storage
And after that:
chown -R $USER:www-data storage
chmod -R 777 storage
on docker bash.
If you're using ubuntu, most likely you have to give permissions to that folder storage
cd into the project and
use the command -> sudo chmod 755 storage/*
I had similar problem in my localhost and the problem was that I was trying to upload a file larger than upload_max_filesize in my php.ini file .
just updating this to greater value and restart my server solved the problem ,, if you having similar problem this might be the case
If you are on a Linux distribution with SELinux enabled, here is what you need to do:
sudo chcon -R -t httpd_sys_rw_content_t /var/www/html/my-app/storage
sudo chown -R nginx /var/www/html/my-app/storage
sudo chmod -R u+w /var/www/html/my-app/storage
This should set the proper context for the storage directory, allowing the web server to write to it.
I had this problem lately with my tests, and resolved it through: composer dump-autoload
This is how I solve a similar issue since I don't have access to the terminal to run sudo chown -R www-data:www-data /thedirectory
in
config/filesystem.php
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
Then in my uploader controller
use Illuminate\Support\Facades\Storage;
$file_path= Storage::path('public/importable');
if (!is_dir($file_path)) {mkdir( $file_path,0775, true);}
This is a permission issue. I used few hours to resolve this problem. I found only 3 lines to give permissions. So first go to root folder f your Laravel application and run these 3 lines.
php artisan cache:clear
chmod -R 777 storage/
composer dump-autoload
For me it was because the single file was owned by root...written at some point when I setup the files, and the app couldn't read it. Solution could be to change ownership, get rid of it, etc.
For me solution was to change folder owner of laravel project. Ensure that is your own user and not root:www-data.
sudo chown -R username:group directory
Run the following command in the directory that is being triggered to check the permissions:
ls -lah
Then if there was any issue you can correct it with:
sudo chown -R username:group directory

Resources