昨天部署一个从GitHub上下载的php框架:Simple-PHP-Framework。部署到Apache上时报错了,错误如下:
You need to setup your server names in class.config.php
$_SERVER['HTTP_HOST']
reported localhost
在网上找了好久,大概是知道要给Server name一个值,所有就在下面这段代码的$localServers赋值。
class Config
{
// Singleton object. Leave $me alone.
private static $me;
// Add your server hostnames to the appropriate arrays. ($_SERVER['HTTP_HOST'])
// Each array item should be a regular expression. This gives you the option to detect a whole range
// of server names if needed. Otherwise, you can simply detect a single server like '/^servername\.com$/'
private $productionServers = array('/^your-domain\.com$/');
private $stagingServers = array();
private $localServers = array();
我是这样写的:private $localServers = array('localhost'); 结果又报错了,错误如下:
Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in D:\Program Files\wamp\www\simple-php-framework-master\includes\class.config.php on line174
搞得好郁闷,早上问leader他没有及时过来帮我解决,我又是PHP新手,搞得都没有继续学习的兴趣,到下午他来帮我看时看了一下,结果解决方案和我的一样,看到上面的报错后又改成下面这样,就可以了:
private $localServers = array('/localhost/');
其中原理搞得不太清楚。给像我一样的新手参考一下。