private function _http_post($url, $data) {
$json_data = json_encode($data);
$options = array(
'http' => array(
'ignore_errors' => true,
'method'=> 'POST',
'header'=> 'Content-type: application/json; charset=UTF-8',
'content' => $json_data
)
);
$context = stream_context_create($options);
$contents = file_get_contents($url, false, $context);
log_message('debug', 'contents:' . $contents);
log_message('debug', 'http_response_header:' . print_r($http_response_header, true));
preg_match('/HTTP\/1\.[0|1|x] ([0-9]{3})/', $http_response_header[0], $matches);
$code = $matches[1];
log_message('debug', 'code:' . $code);
$msg_err = [
400 => 'Bad Request',
401 => 'Unauthorized',
402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Time-out',
409 => 'Conflict',
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Large',
415 => 'Unsupported Media Type',
500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Time-out',
505 => 'HTTP Version not supported',
];
$msg_unexpected = 'Unexpected Error';
$msg = array_key_exists($code, $msg_err) ? $msg_err[$code] : $msg_unexpected;
if($code >= 400 && $code <= 500) {
log_message('WARN', __METHOD__.' Response Code='.$code.' Message='.$msg);
}
return json_decode($contents, true);
}-
-
Save Phalacrocorax/25e3ff5a3b9669fbab701ae1ac4db5f5 to your computer and use it in GitHub Desktop.
| public function csvToArray($filename = '', $delimiter = ',') { | |
| if (!file_exists($filename) || !is_readable($filename)) | |
| return FALSE; | |
| $header = NULL; | |
| $data = array(); | |
| if (($handle = fopen($filename, 'r')) !== FALSE) { | |
| while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE) { | |
| if (!$header) | |
| $header = $row; | |
| else | |
| $data[] = array_combine($header, $row); | |
| } | |
| fclose($handle); | |
| } | |
| return $data; | |
| } |
CLI COMMAND
lsof -i:8080 //lookup port在做AWS的时候遇到过很多问题,经常是代码pull,访问500错误。数据库遇到的最多,因为password和本地不一样,没有用config区分开的话就很容易出错。 还有一些重要的vendor没有提交到master也会有这样的错误
总的权限需要sudo chown -R root:www /var/www。
cache类似直接sudo chmod 777 var -R。 团队开发注意先设置git config core.filemode false
另外注意查看服务器日志👌
sudo tail -10 /var/log/httpd/error_log
This site can’t be reached whatcode.cc refused to connect. 这是 sudo service httpd stop 的结果,应该就是服务器启动失败了,最近每次想要restart httpd必然出现的结果= =。 先查看配置文件
/usr/sbin/httpd -S如果配置文件中有语法错误也会显示出来,然后可以看的DocumentRoot 以及ErrorLog地址。
seg fault or similar nasty error detected in the parent process
sudo apachectl stop / sudo apachectl start / sudo apachectl graceful
用gulp开发着,突然一刷新就出现这个错误,有点懵逼。难道是刚下的vueDraggable的错, 于是马上 npm unintsall然后git reset --hard
...没用, 访问localhost都不行,
sudo apachectl restart
Address already in use: make_sock: could not bind to address //= = 端口占用?
lsof -i | grep :80 //查一查
Shadowsoc TCP *:8090 (LISTEN) 没想到是shadowsocks,为了看Nokisaka Official@youtube的视频, 把VPN调到日本然后开了Global Mode... 居然是这个锅。
在AWS EC2上的blog,试着用phpmyadmin
MAC
brew search
BASH
grep -r "string" dir //目录下查找有“string”的文件
APACHE
apachectl(Apache control interface)是用来控制Apache HTTP服务器的程序。是slackware内附Apache HTTP服务器的script文件,可供管理员控制服务器,但有些Linux的Apache HTTP服务器不一定有这个文件。
apache再起動 in centOS
sudo /etc/init.d/httpd restart/usr/sbin/httpd -S