Environment configuration of cakephp

Source: Internet
Author: User
Cakephp is a beginner in environment configuration. He is currently working on a project and has not completed it all day. he is very anxious.
Environment: Linux (el7) + nginx (1.6.2) + mysql (5.6.23) + php (5.4.39) + cakephp (2.6.0)
The web environment is normal. when you access http: // 172.16.3.91: 8080/cake, the following error occurs:
Warning: _ cake_core _ cache was unable to write 'cake_dev_zh-cn 'to File cache in/usr/share/nginx/dataCenter/lib/cake/Cache. php on line 323

Warning: /usr/share/nginx/dataCenter/app/tmp/cache/persistent/is not writable in/usr/share/nginx/dataCenter/lib/Cake/Cache/Engine/FileEngine. php on line 385

Fatal error: Uncaught exception 'cacheexception' with message 'cache engine _ cake_core _ is not properly configured. 'In/usr/share/nginx/dataCenter/lib/Cake/Cache. php: 181 Stack trace: #0/usr/share/nginx/dataCenter/lib/Cake/Cache. php (151): Cache: _ buildEngine ('_ cake_core _') #1/usr/share/nginx/dataCenter/app/Config/core. php (374): Cache: config ('_ cake_core _', Array) #2/usr/share/nginx/dataCenter/lib/Cake/Core/Configure. php (72): include ('/usr/share/ngin... ') #3/usr/share/nginx/dataCenter/lib/Cake/bootstrap. php (175): Configure: bootstrap (true) #4/usr/share/nginx/dataCenter/app/webroot/index. php (100): include ('/usr/share/ngin... ') #5 {main} thrown in/usr/share/nginx/dataCenter/lib/Cake/Cache. php on line 181

1. you have confirmed that the tmp Directory has all the 777 permissions set for the parent and sub-directories below;
2. cakephp (downloaded from the official website) does not change any other configuration items except the database configuration;
3. nginx. conf (refer to the rewrite settings in the official documentation)
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/

User nobody;
Worker_processes 1;

Error_log/var/log/nginx/error. log info;
# Error_log/var/log/nginx/error. log notice;
# Error_log/var/log/nginx/error. log info;

Pid/run/nginx. pid;

Worker_rlimit_nofile 65535;
Events {
Use epoll;
Worker_connections 4096;
}


Http {
Include/etc/nginx/mime. types;
Default_type application/octet-stream;

Log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request "'
'$ Status $ body_bytes_sent "$ http_referer "'
'"$ Http_user_agent" "$ http_x_forwarded_for "';

Access_log/var/log/nginx/access. log main;

Sendfile on;
# Tcp_nopush on;

Root/usr/share/nginx/html;
# Unit: Seconds
Keepalive_timeout 100;
# Keepalive_timeout 1000;

# Gzip on;

Index index.html index.htm;
# Uwsgi_buffering off;
# Uwsgi_max_temp_file_size 64 m;
# Load modular configuration files from the/etc/nginx/conf. d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# For more information.
Include/etc/nginx/conf. d/*. conf;

Server {
Listen 8080;
# Server_name localhost;
Server_name 172.16.3.91 shuju. baijie;
Rewrite 301 http: // 172.16.3.91: 8080 $ request_uri permanent;

Root/usr/share/nginx/dataCenter/app/webroot;
Index. php index.html index.htm;

# Charset KOI8-R;
Charset UTF-8;

Access_log/var/log/nginx/dataCenter. access. log;
Error_log/var/log/nginx/dataCenter. error. log;

# Load configuration files for the default server block.
Include/etc/nginx/default. d/*. conf;

Location /{
Try_files $ uri // index. php? $ Args;
If (-e $ request_filename) {# the file or directory exists.
Break;
}
If (! -E $ request_filename) {# the file or directory does not exist.
Rewrite ^/(. +) $/index. php? Url = $1 last;
Break;
}
}
Location ~ /\. Ht {# Disable. htaccess
Deny all;
}

Location ~ \. Php $ {
Try_files $ uri = 404;
# The fastcgi process listening port is specified here, where nginx interacts with php
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root/$ fastcgi_script_name;
Include fastcgi_params;
}
# Redirect server error pages to the static page/40x.html
#
Error_page 404/404 .html;
Location =/40x.html {
}

# Redirect server error pages to the static page/50x.html
#
Error_page 500 502 503 x.html;
Location =/50x.html {
}
}

Server {
Listen 8081;
# Server_name localhost;
Server_name 172.16.3.91 shuju. baijie;
Root/usr/share/nginx/mytest;
Index. php index.html index.htm;

# Charset KOI8-R;
Charset UTF-8;

Access_log/var/log/nginx/mytest. access. log;
Error_log/var/log/nginx/mytest. error. log;

# Load configuration files for the default server block.
Include/etc/nginx/default. d/*. conf;

Location/phpmyadmin /{
Index. php;
}
Location ~ \. Php $ {
# The fastcgi process listening port is specified here, where nginx interacts with php
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root/$ fastcgi_script_name;
Include fastcgi_params;
}
}
}


Reply to discussion (solution)

Warning: /usr/share/nginx/dataCenter/app/tmp/cache/persistent/is not writable in/usr/share/nginx/dataCenter/lib/Cake/Cache/Engine/FileEngine. php on line 385
Clearly stated
/Usr/share/nginx/dataCenter/app/tmp/cache/persistent/not writable
This is a directory, and the write cache should be a file name.

Thank you for your reply.
Persistent should indeed be a directory, not a file. the problem should not be here:
383 if ($ this-> _ init &&! ($ Dir-> isDir () & $ dir-> isWritable ())){
384 $ this-> _ init = false;
385 trigger_error (_ d ('Cake _ dev', '% s is not writable', $ this-> settings ['path']), E_USER_WARNING );
386 return false;
387}

Please pay attention to it!

I found the cause, my php. configure cgi in ini. force_redirect uses the default value (enabled by default) and sets cgi. force_redirect = 0 after the configuration is disabled, restart nginx and php-fpm to get the value of writeable correctly. Check the comments of this configuration item in php. ini. when it is enabled, php runs in the web service in a safe way.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.