1.linux下网站开发 :
(1).acl权限设置
(2).修改apache进程执行者
(3).修改samba的访问用户
(4).用samba对apache网站根目录进行共享
(5).在windows中用“映射网络驱动器”把linux下网站根目录映射到本地磁盘中
(6).确保php代码在linux下创建的目录或文件的权限适当
2.samba服务器网站共享:
(1).安装samba服务器:
yum -y install samba*
(2).修改samba服务器配置:
vim /etc/samba/smb.conf
添加如下配置:
[web]
path = /opt/nginx/html
browseable = yes
writable = yes
(3).启动服务:
service smb restart
chkconfig smb on
(4).创建用户:
useradd catalpa
smbpasswd -a catalpa
(5).访问目录:
地址栏输入:\\192.168.61.132\web
用户名:catalpa
密码:123456
3.网站权限设计:
setfacl-m u:catalpa:rwx -R /opt/nginx/html
setfacl-m d:u:catalpa:rwx -R /opt/nginx/html
(1).如果是apache模式:
修改/etc/httpd/conf/httpd.conf:
User catalpa
Group catalpa
(2).如果是nginx模式:
修改/opt/php5.5/etc/php-fpm.conf:
user = catalpa
group = catalpa
4.php搜索代码测试:
$keyword = $_POST['word'];
$sphinx = new SphinxClient();
$sphinx->SetServer('localhost', 9312);
$sphinx->SetMatchMode(SPH_MATCH_ANY);
$sphinx->setLimits(0, 0);
$result = $sphinx->query("$keyword", "*");
$result_ids = implode(',', array_keys($result['matches']));
$pdo = new PDO("mysql:host=localhost;dbname=test","root","");
$rs = $pdo->query("select * from post where id in ({$result_ids})");
$opts = array(
'before_match' => '',
'after_match' => ''
);
while ($row = $rs->fetch()) {
//关键字高亮
$high_light = $sphinx->BuildExcerpts($row, "main", $keyword, $opts);
print_r($high_light);
}
注1:当searchd进程开启时,合并主索引使用命令:./indexer --all --rotate
注2:当连接mysql失败时,可尝试修改php.ini文件:
mysql.default_socket =/var/lib/mysql/mysql.sock
mysqli.default_socket =/var/lib/mysql/mysql.sock
pdo_mysql.default_socket =/var/lib/mysql/mysql.sock