Symfony2 permission issue in OSX local environment - php

I wanted to try out the local apache environment that comes with OSX Mountain Lion.
I did the basic setup and placed a project in the root directory
/Library/WebServer/Documents/
Jumped over too localhost in my browser and everything was working as expected.
However I then decided to follow this guide in order to use the Sites folder in my home directory, for simplicity sake.
http://osxdaily.com/2012/09/02/start-apache-web-server-mac-os-x/
I then reset apache and added this to my browser
http://127.0.0.1/~bengibson/PracTest/
The browser shows a list of a few of the files and directories in the project folder but not all of them :S.
I tried to navigate to one of the missing folders
http://127.0.0.1/~bengibson/PracTest/web/app_dev.php
But I get a forbidden message :(
Anyone know what this needs?
Just for reference here is the project folder
Heres the detailed view in of the folder in terminal
And here is what shown in the browser

I ran into this problem before on OS X when I downloaded the archive file for the Symfony 2 Standard Edition directly in the browser.
The # symbol at the end of the permissions table indicates that the file has additional attributes.
You can see these additional attributes by typing the following command in Terminal as an example, explained here.
$ xattr -l ~/Sites/PracTest/web/app_dev.php
The result returned is com.apple.quarantine.
This is the way OS X protects potentially malicious files downloaded from the internet from being readily available, which is why in Finder you get the warning box alerting you about opening a file downloaded from the internet.
In your case, to remove these extended attributes, run
$ xattr -rd com.apple.quarantine ~/Sites/PracTest
IF you wanted to know what this command does:
The -d flag removes the extended attribute specified after it, followed by the path.
The -r flag acts recursively, on all subfolders and files.
You should now be able to access both app.php and app_dev.php in the browser.
I'd also like to take the opportunity to recommend creating a new Symfony2 project with Composer rather than downloading it directly. It's hard to look back.

For anyone else who may happen on this blog, I had a similar issue and after a bit of looking around I found that I had forgotten the 'FollowSymLinks' Option in the username.conf file

sounds like permissions.
right click folder, get info, unlock with admin password bottom right and make all users able to read and write. then click the gear looking menu below it and tell it to apply to all contents within as well.

Related

Configuring php-cs-fixer and PATH variable

A while ago, I successfully configured Atom to beautify my PHP using php-cs-fixer, but now I need to go through the same process on another Mac and can't remember exactly how I did it.
As a front-end dev, I'm not a PHP expert, but I understand that the Atom plugin is merely the middleman facilitating the actual fixing using php-cs-fixer, which, by default, it doesn't have access to. Once I installed the fixer, I had to add its location to my PATH variable. The confusing part is that I don't have the fixer installed via Atom (checked ~/.atom/packages) nor Homebrew (confirmed with brew list), however, the file is present in /usr/local/bin. If I move it, Atom returns the original error, so it's definitely using this file:
See https://github.com/FriendsOfPHP/PHP-CS-Fixer for program installation instructions.
Your program is properly installed if running 'which php-cs-fixer' in your Terminal returns an absolute path to the executable. If this does not work then you have not installed the program correctly and so Atom Beautify will not find the program. Atom Beautify requires that the program be found in your PATH environment variable.
Note that this is not an Atom Beautify issue if beautification does not work and the above command also does not work: this is expected behaviour, since you have not properly installed your program. Please properly setup the program and search through existing Atom Beautify issues before creating a new issue. See https://github.com/Glavin001/atom-beautify/search?q=php-cs-fixer&type=Issues for related Issues and https://github.com/Glavin001/atom-beautify/tree/master/docs for documentation. If you are still unable to resolve this issue on your own then please create a new issue and ask for help.
Hide Stack Trace
Error: Could not find 'php-cs-fixer'. The program may not be installed.
at PHPCSFixer.module.exports.Beautifier.commandNotFoundError (/Users/ourcore/.atom/packages/atom-beautify/src/beautifiers/beautifier.coffee:204:14)
at /Users/ourcore/.atom/packages/atom-beautify/src/beautifiers/beautifier.coffee:304:22
at tryCatcher (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:510:31)
at Promise._settlePromise (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:567:18)
at Promise._settlePromise0 (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:612:10)
at Promise._settlePromises (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:687:18)
at Async._drainQueue (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:138:16)
at Async._drainQueues (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:148:10)
at Async.drainQueues (/Users/ourcore/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:17:14)
at process._tickCallback (internal/process/next_tick.js:103:7)
which php-cs-fixer returns /usr/local/bin/php-cs-fixer and my PATH variable currently contains /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/ourcore/.atom/packages/php-cs-fixer.
I guess my questions are, how is the fixer working if the PATH variable seems to be pointing to it in a different location, and how did it end up where it is? Does the location in my PATH matter at all, or does the Atom plugin know to look in /usr/local/bin? I just want to fully understand the entire process before repeating it.
EDIT: On further testing, I removed the Atom directory from my PATH and it didn't affect the plugin, so then I copied the file into the same directory onto the second Mac and it ran without issue, without needing to edit the PATH. Does the fixer file someone inform the OS?
Well first test "which php-cs-fixer" or "where php-cs-fixer" (depending on what os you're running) and if nothing is returned in the terminal then there actually is something wrong on the installation and the best thing to do is to manually install it.
Head to https://github.com/FriendsOfPHP/PHP-CS-Fixer and download it from there and follow the installation steps, after that it should all be good

Local xampp wordpress installation - cannot find wp-blog-header.php

I'm working locally with XAMPP and Wordpress and I'm struggling with what is probably a very basic config issue. I'm not a professional IT guy, just a hobbyist hacker so I apologise in advance if I'm being a bit dumb but hopefully somebody can kindly offer some assistance here.
I've installed xampp locally on my iMac. I've then installed wordpress using the xampp wordpress installation package. Both seem to be working fine. To test the web server I created a simple .php test file and this generated the expected output when I entered "localhost/hello.php" into my browser. As far as wordpress is concerned entering "localhost/wordpress" gives me access the local wp interface to create and edit posts, change display settings etc etc. So far so good...
Now I want to create a new .php file that includes the instruction:
require('XXX/wp-blog-header.php')
where the "XXX" is obviously the relevant directory path for the wp header file.
I cannot find this file, or indeed local wordpress files, anywhere (and I've searched extensively). In the "home" location for "localhost" (which I know from my "hello.php" test) there isn't even a wordpress directory so I'm totally puzzled as to how typing "localhost/wordpress" in my browser is accessing the local wp installation or how to go about determining the correct directory path for the wp header file I'm looking for?
I do understand that with this stack a great deal of info will either be generated on the fly, or stored in the local mysql database as opposed to the file structure, but I thought I would find some reference or alias somewhere to help me trace this through and determine what path to include in my .php file for wp-blog-header.php.
I've searched this forum and while there are several related questions I haven't found anything that helps me with this particular issue.
Thanks vm,
Ian
The location of your Wordpress files is:
/Applications/XAMPP/xamppfiles/apps/wordpress
Ok I found the path I needed and (partially) understand why I couldn't locate it. As Scriptonomy helped me identify the Wordpress files are held at:
/Applications/XAMPP/xamppfiles/apps/wordpress
While my test.php file is held at:
/Applications/XAMPP/xamppfiles/htdocs/test.php
The reason I couldn't locate either wp-blog-header.php or wp-load.php is because these there is an another "htdocs" sub-dir under the wordpress install location i.e.:
../apps/wordpress/htdocs
However I (as user "admin") don't have access to read this directory and so couldn't see the contents and therefore couldn't find the files. The permissions on the directory belong to "daemon" which I guess was the XAMPP installer package? Setting the directory path in my test.php file to:
../apps/wordpress/htdocs/wp-load.php
somehow the web server (?) can read the file (even though I can't see it myself via the Finder application) and so the code is now giving the expected result.
So problem solved even if I don't quite understand the solution!
Thanks for replies which helped me eventually get to a solution!
Cheers,
Ian

Styles not loading in magento due to wrong url path, how to solve this?

I have installed magento on my local system, everything is working fine except that the styles are not loading..
I observed that the problem was due to incorrect style sheet url when the request is being sent (found using net in firebug)..
The request url:
http://se.com/var/www/se.com/skin/frontend/default/jm_wall/css/layout.css
The request url should be:
http://se.com/skin/frontend/default/jm_wall/css/layout.css
How could I solve this problem?
Additional Info:
I have migrated from ubuntu 12.04 (fresh install) from ubuntu 10.04 (it was working fine on 10.04)
I have configured apache virtual hosts
I have set web/unsecure/base_url & web/secure/base_url to http://se.com/ in core_config_data table in the database
I have give full permissions to var, skin and media folders
Magento cache is disabled and cleaned (for safety)
Friends i have solved the problem..
i redid all the steps that i have done before, like getting all the files from svn, re-importing the database, and changing the web/unsecure/base_url & web/secure/base_url, configuring apache virtual hosts etc..
but i think what solved the problem was changing the ownership of media and var directories to www-data instead of kaushik and giving those folders full permissions.
I have done this step because in the main server, the those directories were owned by www-data user..
Also, i observed that the css was loading from se.com/media/css folder, which was automatically created once the media directory was setup properly, which did not happen earlier, the directory has css files like 0a039da6028e6d636132ecd5e235f417.css etc..
the request url was something like this (from net window in firebug)...
http://se.com/media/css/0a039da6028e6d636132ecd5e235f417.css
and not like the one i mentioned how it should be above (http://se.com/skin/frontend/default/jm_wall/css/layout.css), nor like how the request was sent (http://se.com/var/www/se.com/skin/frontend/default/jm_wall/css/layout.css)
Hope this helps someone else...
Need go to sql manager and do this:
SELECT * FROM `core_config_data` WHERE `path` LIKE '%merge%'
Then change values from 1 to 0
Clear cache and all will be ok
I faced the similar problem when I used a script to clear the cache and Re-indexing.
My friend, #brucekaushik , gave the perfect answer. I wanted to give upvote to him but could not.
Simply do the following..
change directory to Magento Root
RUN the following:
sudo chown -R www-data:www-data media/ var/
Thanks brother !
The reason that the css is coming from the below url is that the css merge options is set to "YES" in the admin panel.. http://se.com/media/css/0a039da6028e6d636132ecd5e235f417.css
if u want to get this(http://se.com/skin/frontend/default/jm_wall/css/layout.css) please set css merge option to "NO" and clear cache and check it again.....
I think this will help....

PHP mkdir Permission Denied running on Windows Server 2008 IIS 7 due to Read Only Attribute?

I'm having a problem with a PHP website running on IIS 7 on Windows Server 2008.
There is one line of code calling mkdir which is erroring and the error log reads:
"... permission denied ..."
I have ruled out anything to do with folder permissions (I have tried multiple groups: Everyone, Users, IUSR, Network Service etc. with no luck).
I need to know how mkdir works, does it check the read-only attribute of the parent folder?
If so, then this could be the root of the problem as all folders in Windows Server 2008 are marked as "Read Only" and the checkbox is greyed-out - Microsoft say it is "by design" but I think it is really "bad design".
Please help.
P.S. The line of code which errors can be found here https://github.com/LimeSurvey/LimeSurvey/blob/070d255ba381d7abcd231d7c9e0c7d11f5578c97/admin/templates.php#L1182 it is line 1182.
SOLUTION:
It was a permissions issue after all!
We were applying permissions to the wrong folder (smacks hand to forehead)
There are two "Templates" folders: /Templates and /Uploads/Templates
/Template is for default templates whereas /Uploads/Templates is for user-created ones
We gave the "Users" group r/w/execute/modify permissions to /Uploads/Templates folder
Whereas previously we were applying permissions to /Templates
To debug this I used echo to output the $target value
LESSONS LEARNT:
Always read the error message - it said "permission denied" and I didn't believe it
Don't assume the obvious to be true - /Templates wasn't the right folder
If the code is erroring then debug the code and don't try to guess the problem
Debug the code using simple techniques such as outputting variable values - e.g. echo
Listen to the majority - most people here were right in saying IT IS A PERMISSIONS ISSUE!
Most errors have a simple fix - don't go looking for something complex
Bounty awarded to #BOMEz because of the useful quote from mkdir() documentation which indicated that I should double-think the permissions. #BOMEz also provided a tailored answer and interacted with me via comments which helped.
As a test (preferably in a development environment) give the IIS user full access to the parent folder. If this makes it work, slowly start taking away privileges to see which ones you need.
Try changing:
if(mkdir($target,0777))
to:
if(mkdir($target))
Windows ignores the mode option. Might be some weird bug causing it to fail.
Additionally for your $target variable could you try forcing it to link to the full Windows path? Such as C:\Program Files\ IIS\...
I've ran into situations with windows before where access was denied attempting to use a relative path, but the full path works just fine.
EDIT:
Looking at the comments on the documentation for mkdir() one commenter mentions that you might also need to add execute permissions to the user:
If you're getting a Permission Denied error, but are certain the
permissions and ownership where you are trying to create the directory
are correct, check again:
The location where you are trying to create the directory in must have
the Execute permission for the owner trying to create it, regardless
of if the folder is Readable, or Writable.
This may be obvious to some, but was not to me at first. Hopefully
this will save you the trouble I went through.
Since you didn't mention a control panel of any sort I'm going to assume you have access to the server either physical or remote desktop. I'm also going to assume you checked your php.ini settings.
That being said, there is a work around for some of these permission problems.
You will need to create an administrator account (and add it to the administrators group) for this site to use or simply use your administrator credentials.
Open the IIS manager
Expand Sites
Highlight the site in question
On the right side of the screen click 'Basic Settings', a dialog box should pop up.
Click the button at the bottom that says 'Connect as...'
Select 'Specific user' and then click the 'Set...' button
Type the user name and password of either your account or the account you created.
Hit 'Ok' button 3 times.
This is a bit of a sledge hammer fix since it will grant full unrestricted access to the file system from your scripts.
If you created a new user and you want to maintain some level of script security then you can try pulling the user out of the administrators group and then giving it full permissions on only that site with the following:
Highlight site
Right-Click, Edit Permissions
Security Tab
Click 'Edit' button
Click 'Add' button
Click 'Advanced' then 'Find Now'
Double click on the user you created
Click 'Ok'
Highlight your user, tick the box under allow that is next to full control
click 'Ok' twice
If asked, select that you want to apply to all directories and files.
~
If your still having issues then there is a good chance your php setup is configured incorrectly or corrupt. (Safe mode turned on maybe?)
Following is the explanation of permissions.
Read
On a File: this means reading content of the files
On a Directory: it means viewing the contents of the directory, namely, being able to use ls or dir
Write
On a File: this means being able to edit content of the files
On a Directory: it means being able to create/modify content of the directory, namely making new files or folders in that directory.
Execute
On a File: this means executing the code from the file (for scripts/executables)
On a Directory: it means, entering the directory. You can not cd into that directory without this permission.
--
So, now that makes it clear the answer to your problem (as you guessed correctly), for making new directory or writing new files into the directory you need write permission on that directory. So for making folders into say C:/your_folder/ you need, write and execute permissions on that folder. (Yes you need execute too, as apparently for mkdir you need to go inside the folder first.)
One of the issues that we run into quite often is that files have been moved from any location to the websites location, maintaining the original permissions instead of inheriting the permission needed by the application pool user of the pool that's beeing used by the website.
So one good thing to try would be to right click your document root folder, go to properties and then the security tab. Press the advanced button, check the checkbox a "Replace permission entries on all child objects with entries shown here that apply to child objects". That way you can atleast be sure all your permissions are set on all subfolders and files.
We nerver had any problems with the read only attribute, even though this is checked for all our folders. (grayed out/checked). So i doubt that is your problemen.

Apache doesn't execute my copied PHP files, but testing.php works

I've just installed LAMP on my Ubuntu 9.10 machine, and everything works fine except when I copy my PHP files from another computer.
The LAMP guides I've followed also made me create a phpinfo() test file, which works, but when I try to type in e.g. index.php absolutely nothing happens - just a blank page in FireFox. :(
The files are in the exact same directory.
I'm thinking it's probably something with permissions and so on, but since I'm new to both PHP and Ubuntu, I'm kind of lost. It's like I can't create a PHP file with my file browser, but only by using the terminal - like when I created the testing.php from the LAMP guide.
Whaddayaknow... I made an error, tried to:
echo "Hello" world
which, even though I'm a PHP noob, I clearly know is wrong.
I think I'll have to figure out how to enable some sort of error reporting, a blank page is clearly not good enough.
You mean you have a index.php (copied from another computer) and a test.php (edited by hand, with a call to phpinfo()) in the same apache directory, the second works from your browser and the first doesnt ?
That can be a permission issue, or some compilation error in your php.
About permissions, for files should be readable from the apache server (more precisely, form the user that runs the apache server). You can type chmod a+r index.php.
YOu can also check your apache error logs (location dependent on installation). In any case it's vital to know where the error logs are if your are developing a web site.

Categories