在Cloud Foundry上部署开源CMS“我的小论坛”(需要PHP和MySQL)

时间:2016-07-29 19:08:33

标签: php mysql web-deployment cloudfoundry buildpack

  

我的小论坛是一个简单的基于PHP和MySQL的互联网论坛   在经典线程视图(树结构)中显示消息。它   是根据GNU通用公共许可证授权的开源软件。主要的   这个网络论坛的主张很简单。此外,它应该很容易   使用PHP和。在标准服务器配置上安装和运行   的MySQL。

我尝试在基于Cloud Foundry的托管上部署mylittleforum

  

安装

     

解压缩脚本包。   将完整的文件夹“论坛”上传给你的。

     

根据您的服务器配置,写入权限   子目录templates_c(CHMOD 770,775或777)和文件   可能需要按顺序更改config / db_settings.php(CHMOD 666)   他们可以通过脚本写入。运行安装脚本   在您的网络浏览器中访问yourdomain.tld / forum / install /并按照   说明。

我做了什么:

wget -nd https://github.com/ilosuna/mylittleforum/archive/v2.3.5.tar.gz
tar xvfz v2.3.5.tar.gz
cd mylittleforum-2.3.5/
cf cs mariadb large mylittleforum-db
cf push mylittleforum -b https://github.com/cloudfoundry/php-buildpack.git
cf bs mylittleforum mylittleforum-db
cf env mylittleforum
vi config/db_settings.php 
<?php
// Database host, mostly 'localhost':
$db_settings['host'] = '10.0.20.18';

// Database name:
$db_settings['database'] = 'CF_39CC64E1_578D_IIF3_BF1F_BC06LDIDK74009';

// Database user name:
$db_settings['user'] = '84mwzL9fonrlptzmGn';

// Database password:
$db_settings['password'] = 'xzG1s0dff89lYtunp5Mn';

// Database tables (normally not necessary to edit): 
$db_settings['settings_table'] =       'mlf2_settings';
$db_settings['forum_table'] =          'mlf2_entries';
$db_settings['category_table'] =       'mlf2_categories';
$db_settings['userdata_table'] =       'mlf2_userdata';
$db_settings['smilies_table'] =        'mlf2_smilies';
$db_settings['pages_table'] =          'mlf2_pages';
$db_settings['banlists_table'] =       'mlf2_banlists';
$db_settings['useronline_table'] =     'mlf2_useronline';
$db_settings['login_control_table'] =  'mlf2_logincontrol';
$db_settings['entry_cache_table'] =    'mlf2_entries_cache';
$db_settings['userdata_cache_table'] = 'mlf2_userdata_cache';
?>
chmod 777 config/db_settings.php
cf push mylittleforum -b https://github.com/cloudfoundry/php-buildpack.git

然后尝试启动安装程序,但收到404.更新发现安装程序位于http://mylittleforum.domain/install/

curl -I http://mylittleforum.domain/forum/install/
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=iso-8859-1
Date: Fri, 29 Jul 2016 19:03:25 GMT
Server: Apache
X-Vcap-Request-Id: bd734b38-bb6e-4167-731c-f20d8aabfb51

CF推送输出

$ cf push mylittleforum -b https://github.com/cloudfoundry/php-buildpack.git
Updating app mylittleforum in org xxx / space xxx as xxx...
OK

Uploading mylittleforum...
Uploading app files from: /Users/xxx/Downloads/mylittleforum-2.3.5
Uploading 2M, 405 files
Done uploading               
OK

Stopping app mylittleforum in org xxx / space xxx as xxx...
OK

Starting app mylittleforum in org xxx / space xxx as xxx...
Creating container
Successfully created container
Downloading app package...
Downloaded app package (1008.5K)
Downloading build artifacts cache...
Downloaded build artifacts cache (109B)
Staging...
-------> Buildpack version 4.3.17
Installing HTTPD
Downloaded [https://buildpacks.cloudfoundry.org/concourse-binaries/httpd/httpd-2.4.23-linux-x64.tgz] to [/tmp]
Installing PHP
PHP 5.5.37
Downloaded [https://buildpacks.cloudfoundry.org/concourse-binaries/php/php-5.5.37-linux-x64-1468353118.tgz] to [/tmp]
Finished: [2016-07-29 19:16:32.177909]
Exit status 0
Staging complete
Uploading droplet, build artifacts cache...
Uploading build artifacts cache...
Uploading droplet...
Uploaded build artifacts cache (109B)
Uploaded droplet (48.3M)
Uploading complete

1 of 1 instances running

App started


OK

App mylittleforum was started using this command `$HOME/.bp/bin/start`

Showing health and status for app mylittleforum in org xxx / space xxx as xxx...
OK

requested state: started
instances: 1/1
usage: 1G x 1 instances
urls: mylittleforum.domain
last uploaded: Fri Jul 29 19:16:18 UTC 2016
stack: cflinuxfs2
buildpack: https://github.com/cloudfoundry/php-buildpack.git

     state     since                    cpu    memory        disk           details
#0   running   2016-07-29 09:16:51 PM   0.5%   22.7M of 1G   142.6M of 1G

PHP Buildpack选项(.bp-config/options.json

$ pwd
/Users/RomeoOw/Downloads/mylittleforum-2.3.5
$ cat .bp-config/options.json 
{
    "WEBDIR": ""
}

我ssh到容器中(删除应用程序后再次推送,这是奇怪的时间戳,我猜是因为S3文件缓存):

$ cf ssh mylittleforum
vcap@88b21d94-0a7d-4c7c-74f9-2c1af0b49578:~$ pwd
/home/vcap
vcap@88b21d94-0a7d-4c7c-74f9-2c1af0b49578:~$ ls -al
total 36
drwx------  6 vcap vcap 4096 Jul 31 14:19 .
drwxr-xr-x  4 root root 4096 Jul 31 14:20 ..
drwxr-xr-x 19 vcap root 4096 Jul 31 14:19 app
-rw-r--r--  1 vcap vcap  220 Apr  9  2014 .bash_logout
-rw-r--r--  1 vcap vcap 3637 Apr  9  2014 .bashrc
drwxr-xr-x  2 vcap vcap 4096 Jul 31 14:19 logs
-rw-r--r--  1 vcap vcap  675 Apr  9  2014 .profile
-rw-r--r--  1 vcap vcap   64 Jul 31 14:19 staging_info.yml
drwxr-xr-x  2 vcap vcap 4096 Jul 31 14:22 tmp
vcap@88b21d94-0a7d-4c7c-74f9-2c1af0b49578:~$ cd app/
vcap@88b21d94-0a7d-4c7c-74f9-2c1af0b49578:~/app$ ls -lrt
total 124
-rw-r--r-- 1 vcap vcap  1158 Jul 31 14:19 README.md
-rw-r--r-- 1 vcap vcap 33093 Jul 31 14:19 LICENSE
-rw-r--r-- 1 vcap vcap  7757 Jul 31 14:19 index.php
-rw-r--r-- 1 vcap vcap 17047 Jul 31 14:19 CHANGELOG
drwxr-xr-x 2 vcap vcap  4096 Jul 31 14:19 update
drwxr-xr-x 3 vcap vcap  4096 Jul 31 14:19 themes
drwxr-xr-x 2 vcap vcap  4096 Jul 31 14:19 templates_c
drwxr-xr-x 8 vcap vcap  4096 Jul 31 14:19 modules
drwxr-xr-x 2 vcap vcap  4096 Jul 31 14:19 lang
drwxr-xr-x 2 vcap vcap  4096 Jul 31 14:19 js
drwxr-xr-x 2 vcap vcap  4096 Jul 31 14:19 install
drwxr-xr-x 3 vcap vcap  4096 Jul 31 14:19 includes
drwxr-xr-x 5 vcap vcap  4096 Jul 31 14:19 images
drwxr-xr-x 2 vcap vcap  4096 Jul 31 14:19 config
drwxr-xr-x 2 vcap vcap  4096 Jul 31 14:19 backup
drwxr-xr-x 7 vcap vcap  4096 Jul 31 14:19 httpd
drwxr-xr-x 8 vcap vcap  4096 Jul 31 14:19 php
drwxr-xr-x 2 vcap vcap  4096 Jul 31 14:20 logs
vcap@88b21d94-0a7d-4c7c-74f9-2c1af0b49578:~/app$ cd install/
vcap@88b21d94-0a7d-4c7c-74f9-2c1af0b49578:~/app/install$ ls -lrt
total 40
-rw-r--r-- 1 vcap vcap 12765 Jul 31 14:19 install.sql
-rw-r--r-- 1 vcap vcap 21779 Jul 31 14:19 index.php

我试过了:

$ curl -I http://mylittleforum.domain/install/
HTTP/1.1 500 Internal Server Error
Content-Type: text/html
Date: Sun, 31 Jul 2016 14:27:06 GMT
Server: Apache
X-Vcap-Request-Id: ab6db4f1-78ff-483e-7b74-09211fd0b6b9

这是我的应用程序日志(我尝试了错误和良好的路径)。错误的路径/forum/install/给出404并且好的路径/install/给出500.在日志中我看到的信息不是状态代码为500的事实.CF应用输出似乎是健康的mylittleforum started 1/1 1G 1G mylittleforum.domain

我看了app/.bp/logs/bp.log cf ssh。没什么用的。启用BP调试后,日志目录丢失了。

cf set-env mylittleforum BP_DEBUG true

是否进行了冲压,并且在Safari中找不到有关我的请求的有用信息,导致500.在我的请求之前有很多调试日志。请参阅cf logs --recent输出here

当我访问其他网址/index.php/install/时,会有其他HTTP标头(Set-CookiePragmaExpiresCache-Control

curl -I http://mylittleforum.domain/index.php/install/
HTTP/1.1 500 Internal Server Error
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Content-Type: text/html
Date: Sun, 31 Jul 2016 20:14:56 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Server: Apache
Set-Cookie: __VCAP_ID__=1334380f-6a6c-400c-62aa-56b07b4044b6; Path=/; HttpOnly
Set-Cookie: JSESSIONID=fvqr2fe7ac5gd73k24lr8drom7; path=/; HttpOnly
X-Vcap-Request-Id: f4aa004c-87a8-482e-60cd-c5704c6cf9da

1 个答案:

答案 0 :(得分:1)

在buildpack选项中设置WEBDIR:

似乎buildpack尝试提供buildpack配置的<?php session_start(); if($_SESSION["id"]!=$_GET["id"] or $$_GET["referrer"]!="allowedsite.com"){ echo "not valid"; die(); } ?> 变量中定义的文件夹,默认为WEBDIR。 mylittleforum希望从项目的根目录提供文件,因此请将changing the buildpack option值设为空字符串。

从环境中获取配置:

除此之外,我建议您通过使用htdocssee manual)函数获取相应的环境变量来设置config/db_settings.php