nginx0.6.31:Nginx 0.6.31 + PHP 5.2.6(FastCGI)搭建胜过Web服务器(一)来源: 发布时间:星期三, 2009年9月2日 浏览:2次 评论:0
MySQL 5.1.24-rc
/usr/sbin/groupadd mysql /usr/sbin/useradd -g mysql mysql tar zxvf mysql-5.1.24-rc.tar.gz cd mysql-5.1.24-rc/ ./configure --prefix=/usr/local/webserver/mysql/ --without-debug --with-unix--path=/usr/local/webserver/mysql/mysql.sock --with-client-ldflags=-all- --with-mysqld-ldflags=-all- --enable-assembler --with-extra-chars=gbk,gb2312,utf8 --with-pthread --enable-thread-safe-client make && make chmod +w /usr/local/webserver/mysql chown -R mysql:mysql /usr/local/webserver/mysql cp support-files/my-medium.cnf /usr/local/webserver/mysql/my.cnf cd ../ 附:以下为附加步骤如果你想在这台服务器上运行MySQL数据库则执行以下两步如果你只是希望让PHP支持MySQL扩展库能够连接其他服务器上MySQL数据库那么以下两步无需执行 ①、以mysql用户帐号身份建立数据表: /usr/local/webserver/mysql/bin/mysql__db --defaults-file=/usr/local/webserver/mysql/my.cnf --basedir=/usr/local/webserver/mysql --datadir=/usr/local/webserver/mysql/data --user=mysql --pid-file=/usr/local/webserver/mysql/mysql.pid --skip-locking --port=3306 --=/tmp/mysql.sock ②、启动MySQL(最后&表示在后台运行) /bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/usr/local/webserver/mysql/my.cnf & 3、编译安装PHP(FastCGI模式) tar zxvf php-5.2.6.tar.gz gzip -cd php-5.2.6-fpm-0.5.8.df.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-debug --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-mb --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 cp php.ini-dist /usr/local/webserver/php/etc/php.ini cd ../ 4、编译安装PHP5扩展模块 tar zxvf memcache-2.2.3.tgz cd memcache-2.2.3/ /usr/local/webserver/php/bin/phpize ./configure --with-php-config=/usr/local/webserver/php/bin/php-config make make cd ../ tar zxvf xcache-1.2.2.tar.gz cd xcache-1.2.2/ /usr/local/webserver/php/bin/phpize ./configure --with-php-config=/usr/local/webserver/php/bin/php-config --enable-xcache make make cd ../ 5、修改php.ini文件 手工修改:查找/usr/local/webserver/php/etc/php.ini中extension_dir = "./" 修改为extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/" 并在此行后增加以下几行然后保存: extension = "memcache.so" 再查找display_errors = _disibledevent=> 自动修改:若嫌手工修改麻烦可执行以下shell命令自动完成对php.ini文件修改: 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#display_errors = _disibledevent=> 6、配置XCache加速PHP: vi /usr/local/webserver/php/etc/php.ini 按sht+g键跳到配置文件最末尾加上以下配置信息: [xcache-common] zend_extension = /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so [xcache.admin] xcache.admin.user = "xcache" ; xcache.admin.pass = md5($yourpasswd) xcache.admin.pass = "8e6867a5d05144cf4761d6481fc674a8" [xcache] xcache.cacher = _disibledevent=>xcache.size = 32M ; cpu number (cat /proc/cpuinfo |grep -c processor) xcache.count = 2 xcache.slots = 8k xcache.ttl = 0 xcache.gc_erval = 0 xcache.var_size = 2M ; cpu number (cat /proc/cpuinfo |grep -c processor) xcache.var_count = 2 xcache.var_slots = 8K xcache.var_ttl = 0 xcache.var_maxttl = 0 xcache.var_gc_erval = 300 xcache.readonly_protection = Off xcache.mmap_path = "/dev/zero" 7、创建www用户和组以及供blog.s135.com和www.s135.com两个虚拟主机使用目录: /usr/sbin/groupadd www -g 48 /usr/sbin/useradd -u 48 -g www www mkdir -p /data0/htdocs/blog chmod +w /data0/htdocs/blog chown -R www:www /data0/htdocs/blog mkdir -p /data0/htdocs/www chmod +w /data0/htdocs/www chown -R www:www /data0/htdocs/www 8、创建php-fpm配置文件(php-fpm是为PHP打个FastCGI管理补丁可以平滑变更php.ini配置而无需重启php-cgi): 在/usr/local/webserver/php/etc/目录中创建php-fpm.conf文件: rm -f /usr/local/webserver/php/etc/php-fpm.conf vi /usr/local/webserver/php/etc/php-fpm.conf 输入以下内容:<?xml version="1.0" ?> <configuration> All relative paths in this config are relative to php's prefix <section name="global_options"> Pid file <value name="pid_file">/usr/local/webserver/php/logs/php-fpm.pid</value> Error log file <value name="error_log">/usr/local/webserver/php/logs/php-fpm.log</value> Log level <value name="log_level">notice</value> When this amount of php processes exited with SIGSEGV or SIGBUS ... <value name="emergency_restart_threshold">10</value> ... in a less than this erval of time, a graceful restart will be initiated. Useful to work around accidental curruptions in accelerator's shared memory. <value name="emergency_restart_erval">1m</value> Time limit _disibledevent=> Set to 'no' to debug fpm <value name="daemonize">yes</value> </section> <workers> <section name="pool"> Name of pool. Used in logs and stats. <value name="name">default</value> Address to accept fastcgi requests _disibledevent=> <value name="listen_options"> Set listen(2) backlog <value name="backlog">-1</value> Set permissions for unix , _disibledevent=> <value name="group"></value> <value name="mode">0666</value> </value> Additional php.ini s, specic to this pool of workers. <value name="php_s"> <value name="sendmail_path">/usr/sbin/sendmail -t -i</value> <value name="display_errors">0</value> </value> Unix user of processes <value name="user">www</value> Unix group of processes <value name="group">www</value> Process manager tings <value name="pm"> Sets style of controling worker process count. Valid values are '' and 'apache-like' <value name="style"></value> Sets the limit _disibledevent=> Settings group for 'apache-like' pm style <value name="apache_like"> Sets the number of server processes created _disibledevent=> Sets the desired minimum number of idle server processes. Used _disibledevent=> Sets the desired maximum number of idle server processes. Used _disibledevent=> </value> </value> Time limit _disibledevent=> Set open file desc rlimit <value name="rlimit_files">51200</value> Set max core size rlimit <value name="rlimit_core">0</value> Chroot to this directory at the start <value name="chroot"></value> Chdir to this directory at the start <value name="chdir"></value> Redirect workers' stdout and stderr o error log. If not , they will be redirected to /dev/null, according to FastCGI specs <value name="catch_workers_output">yes</value> How much requests each process should execute before respawn. Useful to work around memory leaks in 3rd party libraries. For endless request processing please specy 0 Equivalent to PHP_FCGI_MAX_REQUESTS <value name="max_requests">51200</value> Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect. Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+) Makes sense _disibledevent=> Pass environment variables like LD_LIBRARY_PATH All $VARIABLEs are taken from current environment <value name="environment"> <value name="HOSTNAME">$HOSTNAME</value> <value name="PATH">/usr/local/bin:/usr/bin:/bin</value> <value name="TMP">/tmp</value> <value name="TMPDIR">/tmp</value> <value name="TEMP">/tmp</value> <value name="OSTYPE">$OSTYPE</value> <value name="MACHTYPE">$MACHTYPE</value> <value name="MALLOC_CHECK_">2</value> </value> </section> </workers> </configuration> 0
相关文章
读者评论发表评论 |