I faced a "mkdir(): permission denied" problem when creating a new laravel project via composer by
composer create-project laravel/laravel lsapp command, so I was looking at this solution.
It said to change the group ownership by sudo chown -Rv root:$USER . but he was doing this to cd var/www/, so this make me wondering if he did this because he put his files into /var/www/ so I should execute the command on /opt/lampp/htdocs/ .
or I should execute the command on /var/www/ regardless which directory I use to put my files.
And finally what is the usual directory people used to put their laravel project into ?
update:
I try to change the ownership to both directories so now I know that the command executed to your directory, now the question still what is the best place to put my laravel project, and if I choose /var/www/ how can I open it from the browser with /localhost
You need to point your apache .conf file to where ever your files are stored. Here is an example:
<VirtualHost *:8000>
DocumentRoot "/var/www/myproject/public/"
ServerName localhost
<Directory "/var/www/myproject/">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
This project will be at "localhost:8000"
If your project is not stored in "var/www", then just change those parameters in this block of your conf file in your apache configuration. This can be found in /etc/apache2/sites-enabled/myproject.conf (on linux)
I would like to install Laravel in an AWS/EC2 instance. I first tried to install in my home directory. The laravel new command worked well, and installs the subdirectory. I changed /etc/httpd/conf/httpd.conf in the document root and directory sections (see below) to reflect the path to the public subdirectory of the laravel installation. I restarted the apache server. I changed the permissions (recursively) on the storage subdirectory of the Laravel installation to 777. I realize the eventually this change to 777 needs to change to 775 with a chown to the web user, but I would like to get this to work first.
This configuration produces a "forbidden You don't have permission to access / on this server." response.
I tried to install laravel in /var/www . I renamed the "html" directory. The "laravel new html" command produces the error
PHP Warning: file_put_contents(/var/www/laravel_42427584d5fd657ed6d5af1886e70011.zip): failed to open stream: Permission denied in /home/ec2-user/.composer/vendor/laravel/installer/src/NewCommand.php on line 114
This appears to be a permissions issue, so I tried sudo laravel new html. This produces "sudo: laravel command not found". I added ~/.composer/vendor/bin to my path.
My preference would be to install Laravel in my home directory, but installation anywhere that works would be fine.
Searches in stackoverflow (and the general web) produced solutions suggesting changing the ownership of the laravel installation directory apache:apache (produced the same forbiden error) and reviewing the apache error log (permission denied to enter /var/log/httpd even with sudo, chmod for this directory did not change result).
I have included the httpd.conf file. Thank you in advance for your help.
httpd.conf file (relevant parts)
#DocumentRoot "/var/www/html"
DocumentRoot "/home/ec2-user/laravel_dir/public"
#
# Relax access to content within /var/www.
#
<Directory "/var/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
# Further relax access to the default document root:
#<Directory "/var/www/html">
<Directory "/home/ec2-user/laravel_dir/public">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch
ExecCGI MultiViews
#
# Note that "MultiViews" must be named explicitly --- "Options All"
...
#AllowOverride None
AllowOverride All
...
Require all granted
I'm running El Capitan and trying to get my website hosted locally for development with Apache (that came with the OS). I followed the instructions here exactly. I made an anthony.conf file and put the Directory text in there, I replaced the actual directory with /Users/anthony/dev/web/unfinished-asteroids/ and then placed my web files in there. I started apache and navigated for localhost/~anthony but I get the
Not Found: The requested URL /~anthony was not found on this server.
standard 404 error. When I navigate to localhost it works fine and I get the "It works" from the index.html that is located in /Library/WebServer/Documents, I even changed that index.html file and it works fine.
Any ideas why I'm not able to see my website using apache? All I did was download this github repository and place it in my unfinished-asteroids folder, the index.html is at the root.
So it looks like there are a couple of extra steps that you need to do. There isn't really anything too special about apache that comes with OSX, so your standard apache configurations will work. but to get Userdir (~username) working on El Capitan,this is what I had to do
Edit /etc/apache2/httpd.conf
on (or near) line 166, uncomment
loadModule userdir_module libexec/apache2/mod_userdir.so
then on line 493 uncomment
Include /private/etc/apache2/extra/httpd-userdir.conf
then edit file /etc/apache2/extra/httpd-userdir.conf
uncomment line 16
Include /private/etc/apache2/users/*.conf
then in /etc/apache2/users/anthony.conf
<Directory "/Users/anthony/Sites/">
Options Indexes MultiViews
Require all granted
</Directory>
then sudo apachectl restart
That should make http://localhost/~anthony point to your sites directory.
Logs are stored in /var/log/apache2
Now if all you want is web access to say your dev directory you can do something like this.. (don't make any of the changes listed above)
in /etc/apache2/other/ create a file called mydev.conf (name doesn't really matter, save it needs to end in .conf')
and put this in that file
Alias /dev /Users/anthony/dev/
<Directory "/Users/anthony/dev">
Options Indexes MultiViews
Require all granted
</Directory>
and reload apache (sudo apachectl restart)
then you will be able to access your dev folder at http://localhost/dev and should be able to access your page at http://localhost/dev/web/unfinished-asteroids/
you can adjust the paths at will above, just need to make sure that the user or group _www has access to it, and that paths in the alias and the directory match.
I just upgraded from Yosemite to El Capitan but unfortunately forgot to copy my old httpd.conf and now i need to configure all of its settings again.
I already changed the documentroot to the previous one /users/admin/www, and also configured to release access to this folder:
<Directory "/users/admin/www">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Restarted Apache but even this way I get the 'Forbidden' error when trying to access 127.0.0.1.
What am I'm missing here?
Do the following:
Open Terminal
Run:
cd /etc/apache2/
sudo mv httpd.conf httpd.conf.OLD
sudo mv httpd.conf~previous httpd.conf
sudo apachectl restart
After spending 3 hours on the issue - this worked for me!
I just found out that the old .conf file is saved during the El Captain update, in this folder :
/private/etc/apache2/httpd.conf.pre-update
So i just copied the old definitions to the new one :)
You can navigate to /private/etc/apache2/ and then diff httpd.conf httpd.conf.pre-update to see the differences between your old conf file and the new one that's been added.
For me there was a lot of LoadModules lines commented out, and my apache user/group had been changed back to _www
I am not familiar with the changes in Apache 2.4 so this one really stumped me for about 30 minutes. I just upgraded from Mavericks to El Capitan (Apache 2.2 to 2.4) and I could not load my personal Sites directory (http://localhost/~{username}. I kept getting "Forbidden". After a good bit of research I found that I needed to modify /etc/apache2/users/{username}.conf to add "Require all granted". Since I never upgraded to Yosemite (which also uses Apache 2.4) I never stumbled across this one.
I hope this info helps somebody
Updating the directory access control worked for me:
In this example, all requests are allowed.
2.2 configuration:
Order allow,deny Allow from all
2.4 configuration:
Require all granted
Source: http://httpd.apache.org/docs/trunk/upgrading.html (under Access control)
Note: I keep my custom settings separately under /private/etc/apache2/other/.
This helped as well (after doing everything else as well):
http://coolestguidesontheplanet.com/forbidden-403-you-dont-have-permission-to-access-username-on-this-server/
Like #delphirules said, you can copy your old httpd.conf file like so:
sudo cp /etc/apache2/httpd.conf.pre-update /etc/apache2/httpd.conf
I’ve had issues with connecting to my localhost all day but finally found this: https://mallinson.ca/web-development-with-el-capitan/
Just run the copy command and then do a sudo apachectl restart
I’ve also disabled the SIP ( System Integrity Protection ) in recovery mode. I don’t know if it actually did anything though.. You can find those instructions here: https://forums.developer.apple.com/thread/3981
I had a similar issue receiving a 404 error back when trying to access pages in my local sites directory after enabling myself at the user level to serve sites after upgrading to El Capitan. The issue was that Apache reset the httpd.conf file to its default which disables the user folders to load files from. So http://localhost loaded fine but http://localhost/~username/index.html would NOT load. Here's the fix:
back up the "new" config file that was created:
sudo cp /etc/apache2/httpd.conf /etc/apache2/httpd.conf_capitan
restore the "old" config file that was renamed:
sudo cp /etc/apache2/httpd.conf~previous /etc/apache2/httpd.conf
In case you have symlinks to some of your projects in DocumentRoot directory, after upgrade to El Capitan you can get 403 for these projects, like I did.
You will need the following things to make them work again:
1) Your apache user (_www by default) should have execute access to directory that houses a directory to which you link to.
In my case in apache DocumentRoot I had:
MyProject -> /Users/Me/Documents/Aptana Studio 3 Workspace/MyProject
And for some reason access settings for
/Users/Me/Documents/Aptana Studio 3 Workspace/MyProject
were
-rw------- 1 Me staff My guess it was set during OS x upgrade.
So after sudo chmod 755 Aptana\ Studio\ 3\ Workspace error was resolved.
2) As upgrade also changes httpd.conf, make sure you have this for DocumentRoot directory, or restore from backup httpd.conf as suggested above:
Options Indexes FollowSymLinks
If you upgraded from Mavericks or earlier OS x and restored backup httpd.conf, you should, as jcfranko said, replace apache 2.2 setting for request allowance with:
Require all granted
Create a symlink in your /Users/{user name}/Sites folder
ln -s /Path/To/Target/Files /Users/{user name}/Sites/{name}
My Apache used to work fine, but I assume that problems came after upgrading OSX to 10.9.2, (anyway not certain about when the problem came) Apache was not working with the current configuration.
I tried apachectl configtest so I found out that the Apache's file structure on my machine was changed, from Library/WebServer/Documents/ to Library/WebServer/Apache Home so I edited the DocumentRoot of httpd.conf to point to the new folder.
But the problem I still cannot fix is about the permission. I got 403 Forbidden, You don't have permission to access / on this server.
Extra Information
I hosted all my web projects at /Users/myname/home_www this folder and it's sub folders belong to _www group, and has 775 access permission. I created a symlink at Library/WebServer/Apache Home (all these setup used to work fine)
I noticed some strange thing that the Library/WebServer/ and its sub folders belong to wheel group, I never paid attention to these folders before that what group they belong to.
OSX: 10.9.2
Apache: 2.2.26
As I said in my case all problems seem to come after upgrading to 10.9.2, these are steps I have done to solve my problems.
Edit DocumentRoot to DocumentRoot "/Library/WebServer/Apache Home"
Edit <Directory> to <Directory "/Library/WebServer/Apache Home">
This step may not be necessary but just in case, brew upgrade
Chenge owner and group of /usr/local/var/mysql/ to *mysql using sudo chown -R _mysql:_mysql /usr/local/var/mysql/, otherwise mysql.server start will fail