Deployment of CakePHP 2.x version, implementation of base URL adjustment (/ -> /creditshopback)
1. The current base url is /,https://creditshopback.xxx.cn/. Response 200. as shown in Figure 1
2. Edit the program file and output the current version number: 2.6.4. as shown in Figure 2
echo Configure::version();
exit;
3. Now the expected URL is adjusted to:https://console.xxx.cn/creditshopback. Refer to the development and installation method:https://book.cakephp.org/2/zh/installation.html. as shown in Figure 3
4. View the current Nginx configuration
server {
listen 82;
charset utf-8;
root /mcloud/creditshop_back/app/webroot;
index index.php;
location / {
# modsecurity on;
# modsecurity_rules_file /etc/nginx/modsec_includes_lite.conf;
if (!-e $request_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
}
location /creditf {
# modsecurity on;
# modsecurity_rules_file /etc/nginx/modsec_includes_lite.conf;
alias /webtv/wangjie/creditshop_back/h5jifen/files;
index index.html;
}
location /upload {
alias /webtv/wangjie/creditshop_back/upload;
index index.html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /mcloud/creditshop_back/app/webroot$fastcgi_script_name;
include fastcgi_params;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
5. Cut the directory: /mcloud/creditshop_back/* to /mcloud/creditshop_back/creditshopback/*. as shown in Figure 4
6. Edit Nginx configuration
server {
listen 82;
charset utf-8;
root /mcloud/creditshop_back/;
index index.php;
location / {
# modsecurity on;
# modsecurity_rules_file /etc/nginx/modsec_includes_lite.conf;
if (!-e $request_filename) {
rewrite ^/(.+)$ /index.php?url=$1 last;
break;
}
}
location /creditshopback/creditf {
# modsecurity on;
# modsecurity_rules_file /etc/nginx/modsec_includes_lite.conf;
alias /webtv/wangjie/creditshop_back/h5jifen/files;
index index.html;
}
location /creditshopback/upload {
alias /webtv/wangjie/creditshop_back/upload;
index index.html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /mcloud/creditshop_back/$fastcgi_script_name;
include fastcgi_params;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
7. There is 404 in the response. Its URL:https://console.xxx.cn/creditshopback/css/common.css. Need to be adjusted to:https://console.xxx.cn/creditshopback/app/webroot/css/common.css. as shown in Figure 5
8. Replace echo $this->Html->css(for echo $this->html->css(/app/webroot/css/. Similar to echo $this->html->css(Cake.Generic); is not replaced. as shown in Figure 6
9. Replace echo $this->html->script(for echo $this->HTML->script(/app/webroot/js/. Similar to echo $this->html->css(Cake.Generic); is not replaced.
10. There is no 404 in the response.https://console.xxx.cn/creditshopback/app/webroot/css/common.css. Response 200. as shown in Figure 7
11. Open the URL:https://console.xxx.cn/creditshopback/products/AddNewProduct?tenantid=2a20ea857030b75d3efa343cd625ee03. Response 404.
12. Reference URL:https://www.shuijingwanwq.com/2018/08/16/2836/. Edit nginx configuration
server {
listen 82;
charset utf-8;
root /mcloud/creditshop_back;
index index.php;
location /creditshopback {
alias /mcloud/creditshop_back/creditshopback/app/webroot/;
location = /creditshopback {
try_files $uri /creditshopback/creditshopback/app/webroot/index.php$is_args$args;
}
try_files $uri $uri/ /creditshopback/creditshopback/app/webroot/index.php$is_args$args;
}
location /creditshopback/creditf {
# modsecurity on;
# modsecurity_rules_file /etc/nginx/modsec_includes_lite.conf;
alias /webtv/wangjie/creditshop_back/h5jifen/files;
index index.html;
}
location /creditshopback/upload {
alias /webtv/wangjie/creditshop_back/upload;
index index.html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ ^/.+\.php(/|$) {
rewrite (?!^/creditshopback/app/webroot)^/creditshopback(/.+)$ /creditshopback/app/webroot$1 break;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
try_files $fastcgi_script_name =404;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
13. Open the URL:https://console.xxx.cn/creditshopback/products/AddNewProduct?tenantid=2a20ea857030b75d3efa343cd625ee03. Response 200.
14. Restore steps 8 and 9. The final result responds to 200, in line with expectations.






