标签:1.4 mod 主服务器 next ati add openssl conf install
http.server_port=80
group_name=group1
base_path=/home/fastdfs
store_path0=/home/fastdfs/storage/storage0
tracker_server=175.22.14.205:22122
base_path=/home/fastdfs
tracker_server=175.22.14.205:22122
group_name=group1
url_have_group_name = true
store_path0=/home/fastdfs/storage/storage0
cd /home/softs/lnmp1.4
vi lnmp.conf (主要修改加黑的行就可以了)
Download_Mirror=‘https://soft.vpser.net‘
Nginx_Modules_Options=‘--add-module=/home/softs/fastdfs/fastdfs-nginx-module/src‘
PHP_Modules_Options=‘‘
##MySQL/MariaDB database directory##
MySQL_Data_Dir=‘/usr/local/mysql/var‘
MariaDB_Data_Dir=‘/usr/local/mariadb/var‘
##Default website home directory##
Default_Website_Dir=‘/home/wwwroot/default‘
Enable_Nginx_Openssl=‘y‘
~
更新一下nginx
cd /home/softs/lnmp1.4
./upgrade.sh nginx 【运行之后会要求输入一个nginx版本,当前版本是1.12.1】
# vi /usr/local/nginx/conf/nginx.conf
location /group2/M00 {
root /home/fastdfs/storage/storage0/data;
ngx_fastdfs_module;
}
# vi /etc/fdfs/client.conf
base_path=/home/tmp
tracker_server=175.22.14.205:22122
http.tracker_server_port=80
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cp ../conf/client.conf /etc/fdfs/
cat fastdfs_client.ini >> /usr/local/php/etc/php.ini
cp fastdfs_test.php /home/wwwroot/default/ (测试php扩展是否安装成功)
<html>
<body>
<form action="upload.php" method="post" target="_blank" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="upFile" id="upFile" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
function uploadAttach() {/* {{{ */
$ret = array();
$ret[‘errorcode‘] = 0;
$ret[‘errormsg‘] = ‘‘;
if (!$_FILES || false == isset($_FILES["upFile"])) {
$ret[‘errorcode‘] = 1;
$ret[‘errormsg‘] = "ERROR:upFile is not set";
return $ret;
}
$file = $_FILES["upFile"];
if (false == isset($file[‘tmp_name‘]) || false == is_file($file[‘tmp_name‘])) {
$ret[‘errorcode‘] = 2;
$ret[‘errormsg‘] = "tmp_name is not file";
return $ret;
}
if (0 == filesize($file[‘tmp_name‘])) {
$ret[‘errorcode‘] = 3;
$ret[‘errormsg‘] = "tmp_name filesize is 0";
return $ret;
}
$curlFile = new CurlFile($file[‘tmp_name‘], $file[‘type‘], $file[‘name‘]);
$fileSuffix = getSuffix($curlFile->getPostFilename());
$ret[‘file‘] = $file;
$ret[‘fileId‘] = uploadToFastdfs($curlFile, $fileSuffix);
return $ret;
}
/* }}} */
//获取后缀
function getSuffix($fileName) {/* {{{ */
preg_match(‘/\.(\w+)?$/‘, $fileName, $matchs);
return isset($matchs[1]) ? $matchs[1] : ‘‘;
}
/* }}} */
//上传文件到fastdfs
function uploadToFastdfs(CurlFile $file, $fileSuffix) {/* {{{ */
$fdfs = new FastDFS();
$tracker = $fdfs->tracker_get_connection();
$fileId = $fdfs->storage_upload_by_filebuff1(file_get_contents($file->getFilename()), $fileSuffix);
$fdfs->tracker_close_all_connections();
return $fileId;
}
/* }}} */
function start() {
$ret = uploadAttach();
if (!empty($ret[‘fileId‘])) {
$host_file = ‘http://175.22.14.205/‘ . $ret[‘fileId‘];
header(‘location:‘ . $host_file);
}
print_r($ret);
}
start();
?>
标签:1.4 mod 主服务器 next ati add openssl conf install
原文地址:http://www.cnblogs.com/venuc/p/7357259.html