Logging is not working. Yii Framework on Mac - macos

I have an application developed on Yii Framework and it was fully working on Ubuntu 11.04 on Linux. I recently had to move it to Mac Os. At the moment is mostly working but the logging function is not. It is not writing on /protected/runtime/application.log. I granted the right permissions to the /runtime folder, but still the error messages are not being logged in application.log.

First, I'd double-check that you've configured the logger to log at the appropriate level (e.g. is trace logging enabled?).
Once I did that and confirmed that my settings were correct but logging was still not happening I would then double-check the directory permissions and ownership for protected/runtime. It's terrible practice but you could just set runtime/ to 777 to ensure that it's globally writable. If chmodding it to 777 works then it's a permissions thing and you'll need to sort those out by ensuring that the web server (usually _www/_www on OSX) can write to the directory and that you can read the directory and the files therein.
The way I handle this on localhost is I just add my user to the _www group and chgrp -R _www then chmod g+rwx my Yii directory. This allows both me and apache to have all access.

have you cinfigured logging to file in your main.php:
'components' => array(
'log' => array(
'class' => 'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning, info',
),
),

Related

Saving files in a webhosting with Laravel?

I have a problem with saving files (photos) with laravel in a web hosting.
I can do it in localhost and works perfectly. But now I migrate all project to a web hosting, but saving files is not working.
The form is working, the name of file it's saved, but the file not.
I have this code into my config/filesystems.php:
'local' => [
'driver' => 'local',
'root' => public_path('web/photos'),
],
And I have this folders in public_html/web/photos Whats is wrong?
It's all about file permissions, on your web webserver you need to change it.
If you have console access:
sudo chown www-data /public_html/web/photos
sudo chmod 755 /public_html/web/photos
Or by FTP-client like so: https://www.youtube.com/watch?v=GWBwqlUhQOM

Hosting with OpenShift RedHat get 500 errors when access the website

I have this website. The problem I have is
The freelancer-ngohungphuc.rhcloud.com page isn’t working
freelancer-ngohungphuc.rhcloud.com is currently unable to handle this
request.
500
I develop this website using Laravel 5.1. So what I have to do to fix this error.
Although you can usually check logs to see why you are getting a 500 error, it would appear that this is due to insufficient permissions - which need to be set on the storage and bootstrap/cache folders (as per the docs).
The folders both need to be writeable by your web server, so whilst 777 permissions will definitely work 775 should be fine (and more secure).
Doing this via a command line can be done with the following command (run it with sudo if you need to elevate to root permissions) chomd 777 -R storage bootstrap/cache or chomd 775 -R storage bootstrap/cache.
Doing this via an FTP client is doable, generally speaking you can just right click on the folder and choosing to edit permissions from there.
In some instances, vendor may need to be done too - from my experiences anyway.
These folders are all inside the root project directory for your Laravel application.
Edit
Excerpt from bottom of error log:
PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE)
This would indicate that the PHP version you are running is not >= 5.5.9 (one of the Laravel requirements).
This is confirmed in the screenshot shown of the OpenShift configuration. The version of PHP needs to be updated for Laravel to work - this wasn't just a permission issue.

Vagrant permission with drupal using nfs

I use vagrant as environment on OSX (made with PUPHPET), and i use NFS for synced folder.
But i tried to install drupal on it, and the installation failed because of non writable file.
Do you have any solution to change permission on NFS synced folder ? or should i use something different synced folder ?
Error
The website encountered an unexpected error. Please try again later.
Exception: The directory <em class="placeholder">sites/default/files/config_UoG7KuH42rAreqqHW3qJvJP1SKbBL5Bsoln_xR2lZ4cXUkSW7M3ZCb-QyQi3vFJ8zr5pdnWuPQ/sync</em> could not be created or could not be made writable. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see the online handbook. in drupal_install_config_directories() (line 508 of core/includes/install.inc).
You can modify the owner, group, and permissions of a synced folder using Vagrant...
config.vm.synced_folder "foo/", "/opt/foo",
owner: "www-data",
group: "www-data",
mount_options: ["dmode=775", "fmode=664"]
The www-data user is the default user for both Apache and Nginx, so that's probably what you'll want to use. In the mount options, dmode sets permissions on directories while fmode sets permissions on files. Details for synced folders are in the Vagrant docs.
If you don't want to edit the Vagrantfile directly, then I'm not sure if there's a relevant configuration option within PuPHPet that you can change.

How to give apache the right to write in the Document root on Mac Os 10.8 ( Mountain Lion)

I'm having a lot of issues with PHP and Apache while using os-x mountain lion. Basically my plugin needs wordpress to move some files but it always ask for ftp server credential, like if apache doesn't have permission to write those directories.
Apache is running with
User daemon
Group daemon
if i do
ls -lad htdocs/
i get
drwxrwxr-x 7 root staff 238 13 Ago 21:51 htdocs/
i'm using zend server ce 5.6. What should i do to make sure that apache has full rights to do everything? I would give it root access (it' my dev machine and i must get things working, so i don't care about security issues, but i don't know how to that, if i can do it in a cleaner why i'd be happy but i need this to work )
Your htdocs directory is owned by root, and in the group staff. User permissions on it are rwx, group permission are rwx, and world permissions are rx. So apache needs to be run as either user root or group staff to have full read/write/execute permissions. Otherwise change the owner and/or group of your htdocs directory to daemon and apache will have full rwx permissions. If you really don't care about security at all, just do chmod 777 htdocs (not recommended).
WordPress isn't really checking if it has the right to write in a directory (it's the same for plugin installation), it's only checking if the user and group it's running through Apache is the same that the parent folder.
So the only way is indeed to chmod the folder to your Apache user/group

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