4、接着安装php、php-frm
tar zxvf php-5.2.17.tar.gz
gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
cd php-5.2.17
./configure --prefix=/usr/local/php --with-MySQL=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv=/usr/local/libiconv/ --with-libxml-dir=/usr/local/libxml2 --with-gd=/usr/local/gd/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/local/zlib --with-png-dir=/usr/local/lib --with-freetype-dir=/usr/local/freetype --with-mysql=/usr/local/mysql --with-mcrypt=/usr/local/lib/libmcrypt --enable-mbstring --with-openssl --enable-ftp --with-curl --enable-fastcgi --enable-xml --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fpm --enable-force-cgi-redirect --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl
make
make install
cp php.ini-dist /usr/local/php/lib/php.ini
PHP的配置一会再说,先把nginx安装完成
5、nginx及php扩展插件
tar zxvf pcre-8.01.tar.gz groupadd www useradd -g www -d /home/www -s /sbin/nologin www tar zxvf nginx-0.9.5.tar.gz tar zxvf memcache-2.2.5.tgz tar jxvf eaccelerator-0.9.5.3.tar.bz2 mkdir /tmp/eaccelerator
cd pcre-8.01/
./configure
make
make install
cd ..
cd nginx-0.9.5/
./configure --with-http_stub_status_module --with-http_ssl_module --user=www --group=www --with-http_realip_module
make
make install
cd ..
cd memcache-2.2.5/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ..
cd eaccelerator-0.9.5.3/
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make
make install
cd ..
chmod 777 /tmp/eaccelerator
chown www:www /tmp/eaccelerator
6、安装完那一大堆软件之后,要开始配置了,下面这些才是关键
第一步:配置php.ini
vi /usr/local/php/lib/php.ini
找到
extension_dir =""
修改成
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
extension = "memcache.so"
再找到
output_buffering=off修改成
output_buffering = On
再次查找
; cgi.fix_pathinfo=0
把注释去掉
cgi.fix_pathinfo=0
最后跳到php.ini文件的末尾,加入以下内容:
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="0"
eaccelerator.compress_level="9"
eaccelerator.keys = "disk_only"
eaccelerator.sessions = "disk_only"
eaccelerator.content = "disk_only"
至此,php.ini文件修改完毕!
第二步:配置nginx的FCGI
vi /usr/local/nginx/conf/fcgi.conf
写入以下内容:
fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param QUERY_STRING $query_string; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param REMOTE_ADDR $remote_addr; # PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REDIRECT_STATUS 200;
第三步:配置php-fpm文件
mv /usr/local/php/etc/php-fpm.conf /usr/local/php/etc/php-fpm.conf.bak
vi /root/lnmp/php-fpm.conf
重新写入以下内容
<?xml version="1.0" ?> All relative paths in this config are relative to php's install prefix <section> Pid file Error log file Log level When this amount of php processes exited with SIGSEGV or SIGBUS ... ... in a less than this interval of time, a graceful restart will be initiated. Time limit on waiting child's reaction on signals from master Set to 'no' to debug fpm </section> <workers> <section> Name of pool. Used in logs and stats. Address to accept fastcgi requests on. <value> Set listen(2) backlog Set permissions for unix socket, if one used. Additional php.ini defines, specific to this pool of workers. Unix user of processes Unix group of processes Process manager settings Sets style of controling worker process count. Sets the limit on the number of simultaneous requests that will be served. Settings group for 'apache-like' pm style Sets the number of server processes created on startup. Sets the desired minimum number of idle server processes. Sets the desired maximum number of idle server processes. </value> </value> The timeout (in seconds) for serving a single request after which the worker process will be terminated The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file The log file for slow requests Set open file desc rlimit Set max core size rlimit Chroot to this directory at the start, absolute path Chdir to this directory at the start, absolute path Redirect workers' stdout and stderr into main error log. How much requests each process should execute before respawn. Comma separated list of ipv4 addresses of FastCGI clients that allowed to connect. Pass environment variables like LD_LIBRARY_PATH </section> </workers> </configuration>
<configuration>
<value>/usr/local/php/logs/php-fpm.pid</value>
<value>/usr/local/php/logs/php-fpm.log</value>
<value>notice</value>
<value>10</value>
Useful to work around accidental curruptions in accelerator's shared memory.
<value>1m</value>
<value>5s</value>
<value>yes</value>
<value>default</value>
Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'
<value>127.0.0.1:9000</value>
<value>-1</value>
In Linux read/write permissions must be set in order to allow connections from web server.
Many BSD-derrived systems allow connections regardless of permissions.
<value></value>
<value></value>
<value>0666</value>
</value>
<value>
<value>/usr/sbin/sendmail -t -i</value>
<value>0</value>
</value>
<value>www</value>
<value>www</value>
<value>
Valid values are 'static' and 'apache-like'
<value>static</value>
Equivalent to Apache MaxClients directive.
Equivalent to PHP_FCGI_CHILDREN environment in original php.fcgi
Used with any pm_style.
<value>128</value>
<value>
Used only when 'apache-like' pm_style is selected
<value>20</value>
Used only when 'apache-like' pm_style is selected
<value>5</value>
Used only when 'apache-like' pm_style is selected
<value>35</value>
Should be used when 'max_execution_time' ini option does not stop script execution for some reason
'0s' means 'off'
<value>0s</value>
'0s' means 'off'
<value>0s</value>
<value>logs/slow.log</value>
<value>65535</value>
<value>0</value>
<value></value>
<value></value>
If not set, they will be redirected to /dev/null, according to FastCGI specs
<value>yes</value>
Useful to work around memory leaks in 3rd party libraries.
For endless request processing please specify 0
Equivalent to PHP_FCGI_MAX_REQUESTS
<value>1024</value>
Equivalent to FCGI_WEB_SERVER_ADDRS environment in original php.fcgi (5.2.2+)
Makes sense only with AF_INET listening socket.
<value>127.0.0.1</value>
All $VARIABLEs are taken from current environment
<value>
<value>$HOSTNAME</value>
<value>/usr/local/bin:/usr/bin:/bin</value>
<value>/tmp</value>
<value>/tmp</value>
<value>/tmp</value>
<value>$OSTYPE</value>
<value>$MACHTYPE</value>
<value>2</value>
</value>