Answer the question
In order to leave comments, you need to log in
KPHP - exchange of experience, who worked?
There are a lot of questions.
1. Compiles nicely from php to elf (binary). Elf works great. It turns out that you can use kphp only as a compilation of console applications?
2. How it is possible to use all this business in web'e? How, for example, to cut the compiled miracle to nginx as a backend?
3. Is it possible to compile php-extension from kphp code? If so, how? Without dancing with tambourines in the form of kphp2cpp, and then porting it to phpize.
4. How to build and use the kphpdb examples that come with kphp?
Maybe I'm too dumb for this, but the product is a bit raw in terms of "documentation". The architecture, goals, cases are well painted, but assembly and use are nothing.
Answer the question
In order to leave comments, you need to log in
Engine setup
Assuming kphp-kdb is here: /usr/local/src/kphp-kdb/
cd /usr/local/src/kphp-kdb/
make all
mkdir /usr/share/engine/
mkdir /usr/share/engine /bin/
mkdir /var/log/engine/
mkdir /etc/engine
cp /usr/local/src/kphp-kdb/objs/bin/* /usr/share/engine/bin/
cp /usr/local/src/ kphp-kdb/scripts/debian-init.d-engine /etc/init.d/engine
cp /usr/local/src/kphp-kdb/scripts/_etc_logrotate.d_engine /etc/logrotate.d/engine
cp /usr/ local/src/kphp-kdb/scripts/start-engine /usr/share/engine/bin/
logrotate -d /etc/logrotate.d/engine
logrotate -v -f /etc/logrotate.d/engine
KDB can now be started engines.
For example, running lists-engine:
touch /etc/engine/engine.1.conf
Insert content:
execute lists-engine
arg1 groups23
-p 11200
-vvv
touch /var/lib/engine/groups23.bin
/usr/local/src/kphp-kdb/scripts/create_binlog .sh 0x6ef20101 128 98 > /var/lib/engine/groups23.bin
hexdump -C /var/lib/engine/groups23.bin
Outputs this:
00000000 4b 64 4c 04 01 01 f2 6e 00 00 00 00 80 00 00 00 | KdL....n........|
00000010 62 00 00 00 63 00 00 00 |b...c...|
00000018
chown -R kitten:kitten /var/lib/engine/
echo 1 > /proc/sys/vm/overcommit_memory
service engine start 1
service engine status
If fail look at logs
cat /var/log/engine/engine-1.log
Building KPHP
Ubuntu 12.04.4 LTS
sudo apt-get install git-core openssl zlib1g-dev libcg libprcre3-dev
Install libre2:
wget re2.googlecode.com/files/re2-20140304.tgz
tar -zxvf re2-20140304.tgz
cd re2 /
make
make test (Ignore the error)
make install
make testinstall
cd /usr/local/src/
git clone https://github.com/vk-com/kphp-kdb
cd /usr/local/src/kphp- kdb/
make kphp
Check build: /usr/local/src/kphp-kdb/objs/bin/kphp2cpp
If everything is ok:
export KPHP_PATH=/usr/local/src/kphp-kdb
An example of compiling php to kphp:
For example, take a file bench.php
It lies here: https://gist.github.com/anonymous/9391146
Download, put.
mkdir /var/www/testkphp
cd /var/www/testkphp/
Compile bench.php into kphp
python /usr/local/src/kphp-kdb/KPHP/tests/kphp.py bench.php -o bench
After compiling, run
. /bench
We will see the table of tests.
Compare with php:
php bench.php Rejoice
!
Starting the Web Server
An example, considering the installation according to the instructions above.
KPHP runs under user "kitten"
You need to create it:
mkdir /var/lib/engine - best here, useful later.
sudo useradd kitten -b /var/lib/engine -u 239
chown -R kitten:kitten /var/lib/engine/
cd /var/www/testkphp/
Create file:
touch index.php
Insert test content:
<?
print_r($_GET);
print_r($_SERVER);
?>
Compile our file into a binary with the -n switch:
python /usr/local/src/kphp-kdb/KPHP/tests/kphp.py index.php -o server -n
The output is the executable file "server"
Run ./ server -H 8080
Go to127.0.0.1:8080
1. How does a WEB application fundamentally differ from a console application? Think about it. You just need to somehow proxy requests from your web server (nginx I think) to the application.
2. See the answer to the 1st point. I don’t know exactly how to connect, I haven’t used it and I don’t see any practical benefit from KPHP.
3. No, it's not possible. Try marshmallows.
In fact, KPHP is a very dubious thing. and if you have questions of this kind, then you do not need it.
Gentlemen, please tell me how to install kphp on CentOs 6.5 x64
Now I have the following problem:
[[email protected] kphp-kdb]# make kphp
cc -Wall -O3 -m64 -march=core2 -mfpmath=sse -mssse3 -ggdb -fno-strict -aliasing -fno-strict-overflow -fwrapv -DCOMMIT=\"ce6dead5b3345f4b38487cc9e45d55ced3dd7139\" -I common -I binlog -I net -I kfs -I drinkless -I skat -I vv -I objs -I . -c -MP -MD -MF dep/TL/tlc-new.d -MQ objs/TL/tlc-new.o -o objs/TL/tlc-new.o TL/tlc-new.c
TL/tlc- new.c: In function 'main':
TL/tlc-new.c:73:9: warning: variable 'expr_filename' set but not used [-Wunused-but-set-variable]
char *expr_filename = NULL;
^
cc -Wall -O3 -m64 -march=core2 -mfpmath=sse -mssse3 -ggdb -fno-strict-aliasing -fno-strict-overflow -fwrapv -DCOMMIT=\"ce6dead5b3345f4b38487cc9e45d55ced3dd7139\" -I common -I binlog -I net -I kfs -I drinkless -I skat -I vv -I objs -I . -c -MP -MD -MF dep/TL/tl-parser-new.d -MQ objs/TL/tl-parser-new.o -o objs/TL/tl-parser-new.o TL/tl-parser -new.c
cc -Wall -O3 -m64 -march=core2 -mfpmath=sse -mssse3 -ggdb -fno-strict-aliasing -fno-strict-overflow -fwrapv -DCOMMIT=\"ce6dead5b3345f4b38487cc9e45d55ced3dd7139\" -I common -I binlog -I net -I kfs -I drinkless -I skat -I vv -I objs -I . -c -MP -MD -MF dep/common/kdb-data-common.d -MQ objs/common/kdb-data-common.o -o objs/common/kdb-data-common.o common/kdb-data -common.c
cc -Wall -O3 -m64 -march=core2 -mfpmath=sse -mssse3 -ggdb -fno-strict-aliasing -fno-strict-overflow -fwrapv -DCOMMIT=\"ce6dead5b3345f4b38487cc9e45d55ced3dd7139\" -I common -I binlog -I net -I kfs -I drinkless -I skat -I vv -I objs -I . -c -MP -MD -MF dep/common/server-functions.d -MQ objs/common/server-functions.o -o objs/common/server-functions.o common/server-functions.c
cc -Wall - O3 -m64 -march=core2 -mfpmath=sse -mssse3 -ggdb -fno-strict-aliasing -fno-strict-overflow -fwrapv -DCOMMIT=\"ce6dead5b3345f4b38487cc9e45d55ced3dd7139\" -I common -I binlog -I net -I kfs - I drinkless -I skat -I vv -I objs -I . -c -MP -MD -MF dep/common/crc32.d -MQ objs/common/crc32.o -o objs/common/crc32.o common/crc32.c
cc -o objs/bin/tlc-new objs/TL/tlc-new.o objs/TL/tl-parser-new.o objs/common/kdb-data-common.o objs/common/server-functions.o objs/common/crc32.o -m64 -ggdb -rdynamic -lm -lrt -lcrypto -lz -lpthread
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
make: *** [objs /bin/tlc-new] Error 1
[[email protected] kphp-kdb]# make kphp
cc -o objs/bin/tlc-new objs/TL/tlc-new.o objs/TL/tl-parser-new.o objs/common/kdb-data-common.o objs/common/server-functions.o objs/common/crc32.o -m64 -ggdb -rdynamic -lm -lrt -lcrypto -lz -lpthread
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
make: *** [objs/bin/tlc-new] Error 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question