【服务器配置】CentOS+Nginx+PHP+Mysql环境配置(二)

用户 流年岁月 2014-8-21 4971

本帖最后由 流年岁月 于 2014-8-21 04:54 编辑

[编译安装PHP(FastCGI模式)]

    # tar zxvf php-5.2.6.tar.gz
    # gzip -cd php-5.2.6-fpm-0.5.9.diff.gz | patch -d php-5.2.6 -p1
    # cd php-5.2.6/
    # ./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql --with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl
    # sed -i 's#-lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt#& -liconv#' Makefile
    # make
    # make install
    # cp php.ini-dist /usr/local/webserver/php/etc/php.ini
    # cd ../

    在centos6.0 x86_64上安装php5.3.6时,自带了mysql相关组件,这样编译

    ./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --without-pdo-sqlite --without-sqlite --without-sqlite3 --with-mysql-sock=/tmp/mysql.sock --with-curl  --enable-mbstring --with-mhash --with-mcrypt  --with-libdir=lib64 --enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-gd --with-zlib --with-freetype-dir --enable-sockets --enable-zip --enable-soap --with-libxml-dir --with-openssl-dir  --enable-fpm  --with-iconv-dir  --enable-safe-mode --enable-bcmath

    注意:编译时可能会遇到错误:error: libjpeg.(a|so) not found.     用#whereis libjpeg 命令找到libjpeg   然后拷贝到  /usr/lib64目录下重新编译即可

    错误:error: png.h not found.    解决办法:找到png.h  拷贝到/usr/include目录下重新编译即可。

[编译安装PHP5扩展模块]

    # tar zxvf memcache-2.2.3.tgz
    # cd memcache-2.2.3/
    # /usr/local/webserver/php/bin/phpize    //在此处可能会出现错误“运行phpize时出现:Cannot find autoconf. Please check your autoconf installation”,这时需要安装m4和autoconf库,如下:

    yum -y install m4
    yum -y install autoconf

      

    # ./configure --with-php-config=/usr/local/webserver/php/bin/php-config  --enable-memcache
    # make
    # make install
    # cd ../

    # tar jxvf eaccelerator-0.9.5.3.tar.bz2
    # cd eaccelerator-0.9.5.3/
    # /usr/local/webserver/php/bin/phpize
    # ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
    # make
    # make install
    # cd ../

[修改php.ini文件]

    手工修改:
    # vi /usr/local/webserver/php/etc/php.ini
    将 " extension_dir = "./" "
    修改为            " extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/" "

    将 "output_buffering = Off"
    修改为            " output_buffering = On "

    extension = "memcache.so"
    ↑ 文件末尾增加此行

    自动修改(已使用手动修改的跳过):
    # sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\n#' /usr/local/webserver/php/etc/php.ini
    # sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/webserver/php/etc/php.ini

[配置eAccelerator加速PHP]

    # mkdir -p /usr/local/webserver/eaccelerator_cache
    # vi /usr/local/webserver/php/etc/php.ini
    按shift+g键跳到配置文件的最末尾,加入以下配置信息:

    [eaccelerator]
    zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
    eaccelerator.shm_size="128"
    eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"
    eaccelerator.enable="1"
    eaccelerator.optimizer="1"
    eaccelerator.check_mtime="1"
    eaccelerator.debug="0"
    eaccelerator.filter=""
    eaccelerator.shm_max="0"
    eaccelerator.shm_ttl="300"
    eaccelerator.shm_prune_period="120"
    eaccelerator.shm_only="0"
    eaccelerator.compress="1"
    eaccelerator.compress_level="9"

    # vi /etc/sysctl.conf
    ↑ 修改配置文件

    将    "kernel.shmmax = **********"
    修改为        "kernel.shmmax = 134217728"

    # /sbin/sysctl -p
    ↑ 执行此命令使配置生效

http://bbs.zblogcn.com/static/image/smiley/default/smile.gif流年岁月http://bbs.zblogcn.com/static/image/smiley/default/sad.gif

最新回复 (0)
全部楼主
    • ZBlogger技术交流中心
      2
          
返回