» php の記事

~ php 7.0 update to 7.4 on centos 7 ~

connie 2020.09.14 | php | | No Comments

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

~ install msgpack on centos7 ~

connie 2020.08.12 | centos, php | | No Comments

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

~ centos 7 update php to 7.4 ~

connie 2020.08.12 | centos, php | | No Comments
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

~ Centos7 php7 install pThread ~

connie 2017.03.30 | centos, php | | No Comments
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 

 

~ Install Mod_GeoIP in centos ~

connie 2016.07.13 | apache | | No Comments
yum update

yum install mod_geoip GeoIP GeoIP-devel GeoIP-data zlib-devel

cd/usr/share/GeoIP/
mv GeoIP.dat GeoIP.dat_org
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip GeoIP.dat.gz

nano /etc/httpd/conf/httpd.conf
<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat
</IfModule>
nano /var/www/html/testgeoip.php
<?
var_dump(getenv(GEOIP_COUNTRY_NAME))

 

~ PDO @ php ~

connie 2016.05.19 | php | | No Comments

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] => 銀魂
)

 

~ centos setting GEOIP ~

connie 2016.05.06 | centos, php | | No Comments
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);
    }

 

~ php doc generator ~

connie 2013.06.25 | php | | No Comments

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 

 

~ php get current directory or filename ~

connie 2013.04.03 | php | | No Comments

目標:

/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__));

~ install mcrypt in ubuntu ~

connie 2013.01.22 | ubuntu | | No Comments
apt-get install php5-mcrypt
/etc/init.d/apache2 restart

 

« Previous Page | HOME |

Smiley face

December 2020
S M T W T F S
 12345
6789101112
13141516171819
20212223242526
2728293031