编译安装PHP
与在LAMP编译安装时相同安装libmcrypt与mhash(这里下载这些包到/root/soft下了)
1
|
#yum --nogpgcheck localinstall -y libmcrypt- 2.5 . 7 - 5 .el5.i386.rpm libmcrypt-devel- 2.5 . 7 - 5 .el5.i386.rpm mhash- 0.9 . 2 - 6 .el5.i386.rpm mhash-devel- 0.9 . 2 - 6 .el5.i386.rpm |
安装一下编译所依赖的组件包
1
2
3
4
|
libcurl-devel.i686 bzip2-devel.i686 openssl-devel.i686 libxml2-devel.i686 |
开始编译安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# tar xf php- 5.4 . 13 .tar.bz2^C # cd php- 5.4 . 13 ./configure --prefix=/usr/local/php -- with -openssl --enable-fpm --enable-sockets --enable-sysvshm -- with -mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring -- with -freetype-dir -- with -jpeg-dir -- with -png-dir -- with -zlib-dir -- with -libxml-dir=/usr --enable-xml -- with -mhash -- with -mcrypt -- with -config-file-path=/etc -- with -config-file-scan-dir=/etc/php.d -- with -bz2 -- with -curl # make # make install |
准备PHP的配置文件
1
2
|
# cd php- 5.4 . 8 # cp php.ini-production /etc/php.ini |
为php-fpm提供Sysv init脚本,并将其添加至服务列表
1
2
3
4
5
6
|
# cd php- 5.4 . 8 # cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm # cp sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm # chmod +x /etc/init.d/php-fpm # chkconfig --add php-fpm # chkconfig php-fpm on |
准备php_fpm的配置文件
1
2
3
4
|
# cp php.ini-production /etc/php.ini # cd /usr/local/php/etc/ # cp php-fpm.conf. default php-fpm.conf # vim php-fpm.conf |
修改php-fpm.conf配置文件内容
1
2
3
4
5
|
pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 2 pm.max_spare_servers = 8 pid = /usr/local/php/ var /run/php-fpm.pid |
启动php-fpm
编辑nginx配置文件,整合nginx与php
说明:nginx默认页面路径已经更改为了/web/bbs;
1
2
3
4
5
6
7
|
location ~ \.php$ { root /web/bbs; fastcgi_pass 127.0 . 0.1 : 9000 ; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } |
添加默认默认页面
1
|
index index.php index.htmlindex.htm; |
编辑fastcgi_params文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# vim /etc/nginx/fastcgi_params --把原有内容更改如下 fastcgi_param GATEWAY_INTERFACE CGI/ 1.1 ; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 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_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; |
更改index.php页面内容
1
2
3
4
5
|
# vim /web/bbs/beifen/index.php 内容为(显示php信息): <?php phpinfo(); ?> |
重新启动nginx
验证Nginx是否与PHP整合