在Cloud Foundry上部署开源CMS 'my little forum'(需要PHP和MySQL)



我的小论坛是一个简单的基于PHP和MySQL的互联网论坛以经典的线程视图(树状结构)显示消息。它是根据GNU通用公共许可证授权的开源软件。主要这个网络论坛声称简单。此外,它应该很容易使用PHP和MySQL。

我尝试在基于CloudFoundry的主机上部署mylittleforum。

安装

解压缩脚本包。将完整的文件夹"论坛"上传到您的服务器。

根据您的服务器配置子目录templates_c(CHMOD 770、775或777)和文件config/db_settings.php(CHMOD 666)可能需要更改它们可由脚本写入。运行安装脚本的方式在您的web浏览器中访问您的域.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构建包选项(.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

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

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

cf set-env mylittleforum BP_DEBUG true

做了一次重新发布,也没有发现关于我在Safari中的请求的有用信息,结果是500。在我提出请求之前,有很多调试日志。参见此处的cf logs --recent输出

当我访问其他URL /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

在构建包选项中设置WEBDIR:

构建包似乎试图为构建包配置的WEBDIR变量中定义的文件夹提供服务,默认为htdocs。mylittleforum希望从项目的根目录提供文件,所以请尝试将buildpack选项值更改为空字符串。

从环境中获取配置:

除此之外,我建议您通过使用phpenv()(请参阅手册)函数获取相应的环境变量来设置config/db_settings.php

相关内容

  • 没有找到相关文章

最新更新