实验平台:RHEL5.8

实验拓扑:

PHP配置部分:


1、编译安装PHP


./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-openssl --with-mysqli=mysqlnd --enable-mbstring --with-freetype-dir --with-gpg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-sockets --enable-fpm --with-mycrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts


make && make install


备注--enable-fpm使php工作在php-fpm模式下


2、配置PHP

2.1为其提供服务脚本,源码包里cp /sapi/fpm/init.d.php-fpm到相应目录

2.2cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

为php-fpm提供配置文件并修改监听地址及启动开启的进程数、最小空闲进程、最大空闲进程

2.3复制源码包下的php.ini-production到/etc/php.ini即可成为php配置文件


3、编译安装xcache

3.1xcache源代码目录下执行/usr/local/php/bin/phpize

3.2 ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config

3.3 make && make install



Mysql部分:

通用二进制安装mysql5.5

1、创建mysql用户mysql组

2、创建数据目录/mydata/data 并设置数据目录的属主、属组为mysql

3、mysql目录的属组设置为root 属组设置为mysql

4、cp support-files/mysql.server /etc/init.d/mysqld 复制启动脚本

5、cp support-files/my-large.cnf /etc/my.cnf 复制配置文件

6、修改配置文件

datadir=/mydata/data

innodb_file_per_table = ON

7、初始化数据库

./scripts/mysql_install_db --user=mysql --datadir=/mydata/data

8、service mysqld start 启动数据库

9、输出库文件及头文件及man page文件

库文件输出vi /etc/ld.so.conf.d/mysql 添加/usr/local/mysql/lib

头文件输出ln -s /usr/local/mysql/include/ /usr/include/mysql

man page文件输出 MANPATH /usr/local/mysql/man

10、添加一个数据库用户使得远程主机可以登录,这里主要给Discuz服务器连接用

grant all on *.* to nice@"10.32.9.%" identified by "redhat";

flush privileges;



Nginx部分:

1、添加运行nginx的用户组nginx

2、编译安装nginx

./configure \

--prefix=/usr \

--sbin-path=/usr/sbin/nginx \

--conf-path=/etc/nginx/nginx.conf \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--user=nginx \

--group=nginx \

--with-http_ssl_module \

--with-http_flv_module \

--with-http_stub_status_module \

--with-http_gzip_static_module \

--http-client-body-temp-path=/var/tmp/nginx/client/ \

--http-proxy-temp-path=/var/tmp/nginx/proxy/ \

--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \

--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \

--http-scgi-temp-path=/var/tmp/nginx/scgi \

--with-pcre

make && make install

3、配置nginx

location/{roothtml;indexindex.htmlindex.htmindex.php;----添加能够处理的php主页}

location~\.php${roothtml;fastcgi_pass10.32.9.52:9000;------php页面转发至相应php服务器fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;----关键配置,nginxbugincludefastcgi_params;}

编辑/etc/nginx/fastcgi_params,将其内容更改为如下内容:

fastcgi_paramGATEWAY_INTERFACECGI/1.1;fastcgi_paramSERVER_SOFTWAREnginx;fastcgi_paramQUERY_STRING$query_string;fastcgi_paramREQUEST_METHOD$request_method;fastcgi_paramCONTENT_TYPE$content_type;fastcgi_paramCONTENT_LENGTH$content_length;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;fastcgi_paramSCRIPT_NAME$fastcgi_script_name;fastcgi_paramREQUEST_URI$request_uri;fastcgi_paramDOCUMENT_URI$document_uri;fastcgi_paramDOCUMENT_ROOT$document_root;fastcgi_paramSERVER_PROTOCOL$server_protocol;fastcgi_paramREMOTE_ADDR$remote_addr;fastcgi_paramREMOTE_PORT$remote_port;fastcgi_paramSERVER_ADDR$server_addr;fastcgi_paramSERVER_PORT$server_port;fastcgi_paramSERVER_NAME$server_name;

注意问题:

动静分离,意味着网页文件在前后端主机都要有,前端要有是因为用户请求文件web服务器发现这里有这样的文件才可以请求的(已试验),但是动态需要转到后端去执行。后端执行要在自己的主机上找这个文件。


安装及测试Discuz