首页 > 代码库 > 基于LNMP的Discuz论坛,php mysql nginx为单独服务器,php安装xcache实现共享opcode
基于LNMP的Discuz论坛,php mysql nginx为单独服务器,php安装xcache实现共享opcode
实验平台: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
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 / { root html; index index.html index.htm index.php;----添加能够处理的php主页 }
location ~ \.php$ { root html; fastcgi_pass 10.32.9.52:9000; ------php页面转发至相应php服务器 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;----关键配置 include fastcgi_params; }
编辑/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;
注意问题:动静分离,文件需要在nginx与php服务器各放一份!!!!!!!!!!
安装及测试Discuz