實驗平臺:RHEL5.8php
實驗拓撲:html
PHP配置部分:前端
一、編譯安裝PHPmysql
./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 nginx
make && make installweb
備註--enable-fpm使php工做在php-fpm模式下sql
二、配置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.confapi
爲php-fpm提供配置文件並修改監聽地址及啓動開啓的進程數、最小空閒進程、最大空閒進程
2.3複製源碼包下的php.ini-production到/etc/php.ini便可成爲php配置文件
三、編譯安裝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
一、建立mysql用戶mysql組
二、建立數據目錄/mydata/data 並設置數據目錄的屬主、屬組爲mysql
三、mysql目錄的屬組設置爲root 屬組設置爲mysql
四、cp support-files/mysql.server /etc/init.d/mysqld 複製啓動腳本
五、cp support-files/my-large.cnf /etc/my.cnf 複製配置文件
六、修改配置文件
datadir=/mydata/data
innodb_file_per_table = ON
七、初始化數據庫
./scripts/mysql_install_db --user=mysql --datadir=/mydata/data
八、service mysqld start 啓動數據庫
九、輸出庫文件及頭文件及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
十、添加一個數據庫用戶使得遠程主機能夠登陸,這裏主要給Discuz服務器鏈接用
grant all on *.* to nice@"10.32.9.%" identified by "redhat";
flush privileges;
Nginx部分:
一、添加運行nginx的用戶組nginx
二、編譯安裝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
三、配置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;----關鍵配置,nginx bug 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;
注意問題:
動靜分離,意味着網頁文件在先後端主機都要有,前端要有是由於用戶請求文件web服務器發現這裏有這樣的文件才能夠請求的(已試驗),可是動態須要轉到後端去執行。後端執行要在本身的主機上找這個文件。
安裝及測試Discuz