OneThinkPHP 安装
下载onethinkphp:http://www.onethink.cn/
http://www.thinkphp.cn/down.html
下载解压到服务器的目录(默认路径/Library/WebServer/Documents,修改服务器路径参考http://blog.youkuaiyun.com/qq_25639809/article/details/77988470),然后后需要给目录授权,代开终端进入服务器目录,使用命令
sudo chmod -R 777 wwwroot(onethink解压目录)
然后在浏览器访问该目录即可进入引导安装。http://localhost/www
OneThinkPHP 问题解决
安装完成后登陆后台发现验证码不显示。
http://www.brighttj.com/onethink/onethink-mac-verify-error-config.html
由于BOM头导致的,使用以下代码清除掉项目文件的BOM头即可。
<?php
if (isset($_GET['dir'])){
$basedir=$_GET['dir'];
}else{
$basedir = '.';
}
$auto = 1;
checkdir($basedir);
function checkdir($basedir){
if ($dh = opendir($basedir)) {
while (($file = readdir($dh)) !== false) {
if ($file != '.' && $file != '..'){
if (!is_dir($basedir."/".$file)) {
echo "filename: $basedir/$file ".checkBOM("$basedir/$file")." <br>";
}else{
$dirname = $basedir."/".$file;
checkdir($dirname);
}
}
}
closedir($dh);
}
}
function checkBOM ($filename) {
global $auto;
$contents = file_get_contents($filename);
$charset[1] = substr($contents, 0, 1);
$charset[2] = substr($contents, 1, 1);
$charset[3] = substr($contents, 2, 1);
if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) {
if ($auto == 1) {
$rest = substr($contents, 3);
rewrite ($filename, $rest);
return ("<font color=red>BOM found, automatically removed._<a href=http://www.hengidc.com>http://www.hengidc.com</a></font>");
} else {
return ("<font color=red>BOM found.</font>");
}
}
else return ("BOM Not Found.");
}
function rewrite ($filename, $data) {
$filenum = fopen($filename, "w");
flock($filenum, LOCK_EX);
fwrite($filenum, $data);
fclose($filenum);
}
?>
下载phpmyadmin后解压到onethink目录,浏览器访问登陆数据库出现问题:
#2002 - No such file or directory — 服务器没有响应(或本地服务器的套接字没有正确设置)和mysqli_real_connect(): (HY000/2002): No such file or directory的问题。
解决方案:
找到根目录中 config.sample.inc.php 复制并重命名为 config.inc.php ,打开配置文件,找到
c
f
g
[
′
S
e
r
v
e
r
s
′
]
[
cfg['Servers'][
cfg[′Servers′][i][‘host’] = ‘localhost’; 修改为
c
f
g
[
′
S
e
r
v
e
r
s
′
]
[
cfg['Servers'][
cfg[′Servers′][i][‘host’] = ‘127.0.0.1’; 即可。
mysql_connect()不支持,原因php版本过高,需安装php5版本
curl -s https://php-osx.liip.ch/install.sh | bash -s force 5.6
sudo vim /etc/apache2/httpd.conf
将LoadModule php7_module libexec/apache2/libphp7.so改为
LoadModule php5_module /usr/local/php5/libphp5.so
重启服务器
sudo apachectl restart
安装OneThink报错
The server requested authentication method unknown to the client
原因是MySQL版本过高,Mysql5 到Mysql8启用了新的加密方法。
修改mysql配置文件my.cnf 使数据库启用兼容的加密方式
sudo vi /usr/local/etc/my.cnf ,在最下面新增如下代码:
[mysqld]
default_authentication_plugin= mysql_native_password
重启mysql
mysql.server restart
再次运行PHP成功连接mysql