yum install yum-utils
yum update -y
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager –enable remi-php74
php -v
sudo systemctl restart php-fpm
» php の記事
yum install php-pear php-devel
nano php.ini
disable_functions =
sudo systemctl restart php-fpm
pecl install msgpack
cd /etc/php.d
nano msgpack.txt
extension=msgpack.so
nano php.ini
disable_functions = add back disable_function
sudo systemctl restart php-fpm

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum install yum-utils yum-config-manager --enable remi-php74 yum update php -v systemctl start php-fpm
yum install gcc php70w-devel git clone https://github.com/krakjoe/pthreads.git cd pthreads zts-phpize ./configure --with-php-config=/usr/bin/zts-php-config make cp modules/pthreads.so /usr/lib64/php-zts/modules/
nano /etc/php-zts.d/pthreads.ini extension=pthreads.so
Testing for Thread Safety enable
/etc/php-zts.d/pthreads.ini Should see those thing below Thread Safety => enabled pthreads
Execute server-side Script
zts-php -q ws_server.php instead of using php -q
~ PDO @ php ~
get assoc array from db ONLY
$rtn= $query->fetchAll(PDO::FETCH_ASSOC);
Array
(
[hmvID] => 1
[insertDate] => 2016-03-16 15:18:53
[requestType] => EAN
[requestData] => 4547557009859
[requestDate] => 2016-03-16 17:45:38
[status] => 1
[type] => CD
[title] => ジレンマ(期間生産限定盤)(アニメ盤)
[artist] => ecosystem
[ReleaseDate] => 2011-11-30
[sPhoto] => http://ecx.images-amazon.com/images/I/512THFU3PrL._SL75_.jpg
[XLPhoto] => http://ecx.images-amazon.com/images/I/512THFU3PrL.jpg
[ListPrice] => ¥ 1,337
[LowestNewPrice] => ¥ 570
[ASIN] => B005OCSU7Y
[EAN] => 4547557009859
[SeikodoProductCode] =>
[DetailPageURL] => http://www.amazon.co.jp/%E3%82%B8%E3%83%AC%E3%83%B3%E3%83%9E-%E6%9C%9F%E9%96%93%E7%94%9F%E7%94%A3%E9%99%90%E5%AE%9A%E7%9B%A4-%E3%82%A2%E3%83%8B%E3%83%A1%E7%9B%A4-ecosystem/dp/B005OCSU7Y%3FSubscriptionId%3DAKIAIMFGLRVRLCPPHX7A%26tag%3Dpuiconnie-22%26linkCo
[currentStorage] => 房間貓柱CD櫃
[tag] => 銀魂
)
get assoc and int array from db
$rtn= $query->fetchAll();
Array
(
[hmvID] => 1
[0] => 1
[insertDate] => 2016-03-16 15:18:53
[1] => 2016-03-16 15:18:53
[requestType] => EAN
[2] => EAN
[requestData] => 4547557009859
[3] => 4547557009859
[requestDate] => 2016-03-16 17:45:38
[4] => 2016-03-16 17:45:38
[status] => 1
[5] => 1
[type] => CD
[6] => CD
[title] => ジレンマ(期間生産限定盤)(アニメ盤)
[7] => ジレンマ(期間生産限定盤)(アニメ盤)
[artist] => ecosystem
[8] => ecosystem
[ReleaseDate] => 2011-11-30
[9] => 2011-11-30
[sPhoto] => http://ecx.images-amazon.com/images/I/512THFU3PrL._SL75_.jpg
[10] => http://ecx.images-amazon.com/images/I/512THFU3PrL._SL75_.jpg
[XLPhoto] => http://ecx.images-amazon.com/images/I/512THFU3PrL.jpg
[11] => http://ecx.images-amazon.com/images/I/512THFU3PrL.jpg
[ListPrice] => ¥ 1,337
[12] => ¥ 1,337
[LowestNewPrice] => ¥ 570
[13] => ¥ 570
[ASIN] => B005OCSU7Y
[14] => B005OCSU7Y
[EAN] => 4547557009859
[15] => 4547557009859
[SeikodoProductCode] =>
[16] =>
[DetailPageURL] => http://www.amazon.co.jp/%E3%82%B8%E3%83%AC%E3%83%B3%E3%83%9E-%E6%9C%9F%E9%96%93%E7%94%9F%E7%94%A3%E9%99%90%E5%AE%9A%E7%9B%A4-%E3%82%A2%E3%83%8B%E3%83%A1%E7%9B%A4-ecosystem/dp/B005OCSU7Y%3FSubscriptionId%3DAKIAIMFGLRVRLCPPHX7A%26tag%3Dpuiconnie-22%26linkCo
[17] => http://www.amazon.co.jp/%E3%82%B8%E3%83%AC%E3%83%B3%E3%83%9E-%E6%9C%9F%E9%96%93%E7%94%9F%E7%94%A3%E9%99%90%E5%AE%9A%E7%9B%A4-%E3%82%A2%E3%83%8B%E3%83%A1%E7%9B%A4-ecosystem/dp/B005OCSU7Y%3FSubscriptionId%3DAKIAIMFGLRVRLCPPHX7A%26tag%3Dpuiconnie-22%26linkCo
[currentStorage] => 房間貓柱CD櫃
[18] => 房間貓柱CD櫃
[tag] => 銀魂
[19] => 銀魂
)
yum install GeoIP-devel yum install php-pear yum install php-pecl-geoip cd /usr/share/GeoIP wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz gunzip GeoIP.dat.gz gunzip GeoLiteCity.dat.gz mv GeoLiteCity.dat GeoIPCity.dat sudo systemctl restart php-fpm sudo systemctl restart nginx
TEST PHP CODE
$record = geoip_record_by_name($_SERVER["REMOTE_ADDR"]);
if ($record) {
print_r($record);
}
nano /etc/cron.d/php5
Change
09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null ; -delete
to
09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete
Firstly, install the pear
sudo apt-get install php-pear
Install apigen
pear config-set auto_discover 1 pear install pear.apigen.org/apigen
generate the doc
go to the target "web system" folder
apigen --source . --destination docs/apigen --todo yes \ --title "the api title" --php no
目標:
/var/www/connie/test.php
output = "/var/www/connie/test.php"
echo __FILE__;
output = "test.php"
echo basename(__FILE__);
output = "test"
echo basename(__FILE__, '.php');
output = "/var/www/connie"
echo dirname(__FILE__);
output = "/var/www/" (parent folder)
echo dirname(dirname(__FILE__));
首先要setup 好server side , 變更host and port
完成後要係putty 開啟server
php -q socket_server.php
<?php
//php -q socket_server.php
// 设置一些基本的变量
global $lat,$lnt;
$host = "192.168.0.1";
$port = 8888;
// 设置超时时间
set_time_limit(0);
// 创建一个Socket
$commonProtocol = getprotobyname("tcp");
$socket = socket_create(AF_INET, SOCK_STREAM, $commonProtocol);
//绑定Socket到端口
$result = socket_bind($socket, $host, $port) or die("Could not bind to socket\n");
$ret = socket_listen($socket, 5);
if($ret){
while (true){
$spawn = socket_accept($socket) or die("Could not accept incoming connection\n");;
echo("socket connected\n");
if(!$spawn) break;
$output = "Welcome to the PHP Test Server.....nice\n";
socket_write($spawn, $output, strlen ($output)) or die("error\n");
while($input = socket_read($spawn, 64)){
echo($input);
}
echo("\n");
socket_close($spawn);
}
}
?>
Client Side
<?php
// 设置一些基本的变量
$host = "192.168.0.1";
$port = 8888;
// 设置超时时间
set_time_limit(0);
// 创建一个Socket
$commonProtocol = getprotobyname("tcp");
$socket = socket_create(AF_INET, SOCK_STREAM, $commonProtocol);
if(!$socket) echo "can't create socket";
//绑定Socket到端口
$result = socket_connect($socket, $host, $port) or die(socket_strerror());
if($result){
$output="hello server!,connie";//lat:30.582029016593196;lnt:103.98662567138672
socket_write($socket, $output, strlen ($output));
$input = socket_read($socket, 1024);
echo($input);
}
?>
之後係web browser 開client url , 便可以

Recent Comments