Compile PHP code into C/C ++ code to make your PHP run faster.

Source: Internet
Author: User

Facebook released a tool that converts PHP code to C ++, hiphop
If your website is large and a large portal like Sina, consider it.
It has been compiled on centos, Ubuntu, and other Linux servers.
Installation:
1. Dependent packages
  • Cmake2.6 is the minimum version
  • G ++/GCC4.3 is the minimum version
  • Boost1.37 is the minimum version
  • Flex
  • Bison
  • Re2c
  • Libmysql
  • Libxml2
  • Libmcrypt
  • Libicu4.2 is the minimum version
  • OpenSSL
  • Binutils
  • Libcap
  • GD
  • Zlib
  • TBBIntel's thread building blocks
  • Oniguruma
  • Libpcre
  • Libexpat
  • Libmemcached

The following package must be patched based on the source code

  • Libcurl
  • Src/third_party/libcurl. fb-changes.diff
  • Libevent 1.4
  • Src/third_party/libevent-1.4.13.fb-changes.diff or SRC/third_party/libevent-1.4.14.fb-changes.diff

Ii. Specify the cmake location
Export cmake_prefix_path =/home/user

Iii. Compilation
CD/home/user/dev
Git clone git: // github.com/facebook/hiphop-php.git
CD hiphop-PHP
Git submodule init
Git submodule update
Export hphp_home = 'pwd'
Export hphp_lib = 'pwd'/bin
Make
Cmake.

According to fackbook, the performance can be improved by about 50%, provided that PHP Code does not contain Eval, a rarely used method.

4. Use hphp
Environment Settings:
CD .. # enter the root directory of hphp and the directory where the source code is stored
Export hphp_home = 'pwd'
Export hphp_lib = 'pwd'/bin
# If you followed the Ubuntu 9.10 instructions, you also need
Export cmake_prefix_path = '/bin/pwd '/../

There are several modes
1: directly compile and execute C ++ code
Hphp/hphp test. php

2: Compile to a temporary folder and execute the compiled C ++ program.
Hphp/hphp test. php -- keep-tempdir = 1 -- log = 3
/Tmp/hphp_p6vssp/program based on your own running

3: Compile php as a service and run it on the specified port
Hphp/hphp test. php -- keep-tempdir = 1 -- log = 3
/Tmp/hphp_p6vssp/Program-M server-P 8080
Curl http: // localhost: 8080/test. php
Sudo/tmp/hphp_p6vssp/Program-M daemon

Refer:
Https://github.com/facebook/hiphop-php/wiki/Running-HipHop
Http://www.ooso.net/archives/557

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.