首页 > 代码库 > centos 6.3 64位安装php5.5及配置tengine

centos 6.3 64位安装php5.5及配置tengine


PHP 用到的工具包: 

yum install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel openssl-devel libicu-devel libmcrypt-devel 

PHP configure参数

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-gd --with-iconv --with-zlib --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --with-jpeg-dir=/usr/lib64 --with-freetype-dir=/usr/lib64 --with-png-dir=/usr/lib64 --disable-debug
make #编译make install #安装cp php.ini-production /usr/local/php5/etc/php.ini #复制php配置文件到安装目录rm -rf /etc/php.ini #删除系统自带配置文件ln -s /usr/local/php5/etc/php.ini /etc/php.ini #添加软链接cp /usr/local/php5/etc/php-fpm.conf.default /usr/local/php5/etc/php-fpm.conf #拷贝模板文件为php-fpm配置文件vi /usr/local/php5/etc/php-fpm.conf #编辑user = www #设置php-fpm运行账号为wwwgroup = www #设置php-fpm运行组为wwwpid = run/php-fpm.pid #取消前面的分号设置 php-fpm开机启动cp /usr/local/src/php-5.4.5/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm #拷贝php-fpm到启动目录chmod +x /etc/rc.d/init.d/php-fpm #添加执行权限chkconfig php-fpm on #设置开机启动vi /usr/local/php5/etc/php.ini #编辑配置文件找到:disable_functions = 修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname#列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。找到:;date.timezone = 修改为:date.timezone = PRC#设置时区 找到:expose_php = On 修改为:expose_php = OFF#禁止显示php版本的信息 找到:short_open_tag = Off 修改为:short_open_tag = ON #支持php短标签

最后service php-fpm start #启动php-fpm

tengine 集成php

在nginx.conf中的server段中加入

location ~ \.php$ {            root           /usr/local/tengine/html;            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;            include        fastcgi_params;        }