CmsTop 大衆版運行環境搭建 (CentOS+Nginx+PHP FastCGI)

1、CentOS 5.5 操做系統的安裝javascript

 

操做系統這裏咱們仍採用 CentOS 5.5 來講明 Linux 下的 Nginx 安裝與配置。關於CentOS的安裝與注意事項請你們點擊這裏:(其中包含配置yum的步驟,由於咱們接下來會使用到yum)。php

 

2、準備工做css

 

和Apache的配置相同,咱們就來進行一些準備工做,譬如建立網站目錄,日誌目錄等。而後安裝服務器的相關軟件。html

 

(1) 建立網站目錄和日誌目錄java

 

shell> mkdir -p /www/mysql  # MySQL數據庫文件node

 

shell> mkdir -p /www/htdocs  # 網站主目錄mysql

 

shell> mkdir -p /var/log/php  # PHP日誌目錄linux

 

shell> mkdir -p /var/log/mysql  # MySQL日誌目錄nginx

 

(2) 改變MySQL屬主和用戶組c++

 

shell> chown -R mysql:mysql /www/mysql

 

shell> chown -R mysql:mysql /var/log/mysql

 

(3) 改變網站目錄屬主和用戶組

 

shell> chown -R www:www /www/htdocs

 

shell> chown -R www:www /var/log/php

 

注:若是 mysql 等用戶不存在,則須要事先經過 useradd 指令建立。這裏咱們建立的 www 用戶和用戶組,用於 Nginx 守護進程。

 

shell> useradd -s /sbin/nologin -M mysql

 

2、服務器軟件的安裝與配置

 

1. yum安裝MySQL

 

# 安裝系統組件,這些大都是一些編譯環境、PHP擴展等等,若是這些都使用源代碼安裝,那是一個痛苦的過程。

 

shell> yum -y install gcc gcc-c++ autoconf make

 

shell> yum -y install libjpeg libjpeg-devel libpng
libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel
curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel
openssl openssl-devel openldap openldap-devel openldap-clients openldap-servers

 

shell> yum -y install mysql mysql-devel mysql-server

 

在安裝過程當中,咱們看到使用了上述咱們的非官方源進行更新,經過這種方式安裝的軟件版本分別爲: MySQL 5.1.50 ( 截止到2010-09-16)

 

2. MySQL 的啓動與基本配置

 

系統已經安裝好了
MySQL 數據庫,咱們來稍做配置後而後啓動它,由於初次啓動會安裝數據庫文件,因此要對my.cnf裏的配置進行一些修改,尤爲是數據庫文件存放位置。

 

# 複製一個樣本,/usr/share/mysql 目錄下有好多樣本,請自主選擇。

 

shell> cp /usr/share/mysql/my-medium.cnf /etc/my.cnf 

 

修改配置文件,咱們稍做修改

 

# 注:是在原有my.cnf基礎上進行修改,沒有的選項添加

 

shell> vi /etc/my.cnf  

[client]

port = 3306

socket = /var/lib/mysql/mysql.sock

default-character-set = utf8

[mysqld]

user = mysql

datadir = /www/mysql

log-error = /var/log/mysql/mysql_error.log

log-bin=/var/log/mysql/mysql-bin

character-set-server = utf8

 

啓動
MySQL,或者使用 service mysqld start ,系統會提示安裝數據庫,而後啓動成功。不然請查看由 log-error 配置項定義的錯誤信息。

 

shell> /etc/init.d/mysqld start

 

MySQL 初始安裝啓動後是能夠用匿名空密碼登錄的,咱們須要刪除匿名用戶,更改root帳戶密碼

 

shell> mysql

 

mysql> UPDATE mysql.user SET password = PASSWORD(""cmstop"")
WHERE user = ""root"";

 

mysql> DELETE FROM mysql.user WHERE user = """";

 

mysql> FLUSH PRIVILEGES;

 

# 查看MySQL 支持插件狀況  注:這種方式安裝的MySQL 默認支持
InnoDB, 查看該值後面是否爲 YES

 

mysql> SHOW VARIABLES LIKE ""%have%"";

 

# 查看MySQL 字符集,應該都是
utf8

 

mysql> SHOW VARIABLES LIKE ""%char%"";

 

3. 安裝Nginx

 

接下來咱們採用源代碼的方式安裝Nginx + PHP ,首先下載程序所需源碼包:

 

shell> cd ~

 

(感謝張宴爲你們提供的源碼包鏡像,原文出處:http://blog.s135.com/nginx_php_v6/)

 



wget http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.8.46.tar.gz

wget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.14.tar.gz

wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.14-fpm-0.5.14.diff.gz

wget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.1.tar.gz

wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz

wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz

wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz

wget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-8.10.tar.gz

wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgz

 

(1) 安裝 Nginx 所需的pcre庫

 

shell> tar zxvf pcre-8.10.tar.gz

 

shell> cd pcre-8.10/

 

shell> ./configure

 

shell> make && make install

 

shell> cd ..

 

(2) 安裝 Nginx

 

shell> tar zxvf nginx-0.8.46.tar.gz

 

shell> cd nginx-0.8.46

 

shell> ./configure --user=www --group=www
--prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

 

shell> make && make install

 

shell> cd ..

 

# 作個Nginx 的指令軟連接,方便咱們啓動,中止

 

shell> ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx

 

# Nginx 的啓動,中止,平滑重啓指令。僅限0.8.*系列

 

shell> nginx -s  {reload | start | stop}

 

Nginx 0.8.46咱們已經安裝好了,直接啓動,在瀏覽器中輸入服務器IP。看到了這樣的界面是否是有點興奮了?

 

 

 


















 

 4. 安裝PHP

 

(1) 安裝 libiconv

 

shell> cd ~

 

shell> tar zxvf libiconv-1.13.1.tar.gz

 

shell> cd libiconv-1.13.1/

 

shell> ./configure --prefix=/usr/local

 

shell> make && make install

 

shell> cd ..

 

(2) 安裝 PHP

 

shell> tar zxvf php-5.2.14.tar.gz

 

shell> gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d
php-5.2.14 -p1

 

shell> cd php-5.2.14/

 

shell> ./configure --prefix=/usr/local/php
--with-config-file-path=/usr/local/php/etc --with-mysql --with-mysqli
--with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir
--with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath
--enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop
--enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers
--enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect
--enable-mbstring  --with-gd --enable-gd-native-ttf --with-openssl
--enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc
--enable-zip --enable-soap

 

shell> make ZEND_EXTRA_LIBS=""-liconv""

 

( 注:這裏可能會報錯。報未找到 liconv ,.so 庫等等。按照下面幾種方法解決,再從新 make install:

 

I. error while loading shared libraries: libiconv.so.2 .....

 

shell> vi /etc/ld.so.conf  在文件最後加入
/usr/local/lib 這一行

 

shell> ldconfig -v

 

II. 64位操做系統,還可能會報 liconv 路徑不對,嘗試如下方法,

 

shell> ln -s /usr/local/lib/libiconv.so.2
/usr/local/lib64/libiconv.so.2

 

shell>  ln -s /usr/local/lib/libiconv.so.2
/usr/lib64/libiconv.so.2 )

 

shell> make install

 

shell> cp php.ini-dist /usr/local/php/etc/php.ini

 

shell> cd ..

 

(3) 安裝 PDO_mysql 擴展

 

shell> tar zxvf PDO_MYSQL-1.0.2.tgz

 

shell> cd PDO_MYSQL-1.0.2/

 

shell> /usr/local/php/bin/phpize

 

shell> ./configure
--with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql

 

shell> make && make install

 

shell> cd ..

 

(4) 安裝 ZendOptimizer 擴展

 

下載相應
Zend Optimizer 擴展,分別對應32位和64位:

 

shell> wget http://download.cmstop.com/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

 

shell> wget http://download.cmstop.com/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz

 

shell> tar xvzf ZendOptimizer-3.3.9...

 

shell> cp
ZendOptimizer-3.3.9.../data/5_2_x_comp/ZendOptimizer.so
/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613

 

(5) 修改 php.ini 配置文件

 

shell> vi /usr/local/php/etc/php.ini

 

查找
extension_dir = "./"

 

修改成
extension_dir =
"/usr/local//php/lib/php/extensions/no-debug-non-zts-20060613/"

 

查找
cgi.fix_pathinfo=0

 

如下配置參考修改:

short_open_tag = On

output_buffering = 4096

max_execution_time = 600 

post_max_size = 32M

allow_url_fopen = On

open_basedir = /www/htdocs/

upload_max_filesize = 32M

log_errors = On

error_reporting = E_ALL & ~E_NOTICE | E_STRICT

display_errors = Off

error_log = /var/log/php/php_error.log

magic_quotes_gpc = Off

 

最後在該文件最後增長如下配置段:

 



extension = "pdo_mysql.so"

[Zend]

zend_extension="/usr/local//php/lib/php/extensions/no-debug-non-zts-20060613/ZendOptimizer.so"

zend_optimizer.enable_loader = 1

zend_optimizer.optimization_level=0

zend_optimizer.disable_licensing=0

 

這樣,咱們的PHP以及相關擴展都已經安裝完畢了,接下來咱們說明Nginx 如何與
PHP 進行 CGI交互。

 

3、配置 Nginx 與 PHP (FastCGI) 

 

1. 建立php-fpm配置文件

 

(php-fpm是爲PHP打的一個FastCGI管理補丁,能夠平滑變動php.ini配置而無需重啓php-cgi)

 

shell> cp /usr/local/php/etc/php-fpm.conf.default
/usr/local/php/etc/php-fpm.conf

 

shell> vi /usr/local/php/etc/php-fpm.conf

 

這是一個xml的配置文件,如下用紅色標註注意修改的地方,其餘則爲默認文件配置:

 

pid_file  /usr/local/php/logs/php-fpm.pid

 

error_log  /usr/local/php/logs/php-fpm.log

 

log_level  notice

 

daemonize  yes

 

listen_address  127.0.0.1:9000

 

display_errors  0

 

user  www

 

group  www       

 

max_children  32

 



      啓動php-cgi進程,監聽127.0.0.1的9000端口,進程數爲32(進程數自行修改,視服務器配置和 Nginx 進程數而定),用戶爲www:

 

shell> ulimit -SHn 65535

 

shell> /usr/local/php/sbin/php-fpm start

 

# 咱們也建立個 PHP 的軟連接,方便控制

 

shell> ln -s /usr/local/php/sbin/php-fpm
/usr/sbin/php-fpm 

 

PHP 進程的啓動,中止,平滑重啓方法:

 

shell> php-fpm {start | stop
| quit | restart | reload | logrotate}

 

2. 修改 Nginx 配置文件

 

修改 Nginx 前,咱們先將服務中止,執行:

 

shell> nginx -s stop

 

Nginx 有和Apache 一樣的配置文件檢測指令,因此在每次修改配置文件後,請檢測下語法是否有錯誤:

 

shell> nginx -t

 

如下是配置範例,請參考修改紅色部分:

 

user 
www www;

 

 

 

worker_processes 4;

 

 

 

error_log  /var/log/nginx_error.log  crit;

 

 

 

pid        /usr/local/nginx/nginx.pid;

 

 

 

worker_rlimit_nofile 65535;

 

 

 

events

 

{

 

      use
epoll;

 

      worker_connections
65535;

 

}

 

 

 

http

 

{

 

      include       mime.types;

 

      default_type  application/octet-stream;

 

 

 

      charset  utf8;

 

 

 

      server_names_hash_bucket_size
128;

 

      client_header_buffer_size
32k;

 

      large_client_header_buffers
4 32k;

 

      client_max_body_size
8m;

 

 

 

      sendfile
on;

 

      tcp_nopush     on;

 

 

 

      keepalive_timeout
60;

 

 

 

      tcp_nodelay
on;

 

 

 

      fastcgi_connect_timeout
300;

 

      fastcgi_send_timeout
300;

 

      fastcgi_read_timeout
300;

 

      fastcgi_buffer_size
64k;

 

      fastcgi_buffers
4 64k;

 

      fastcgi_busy_buffers_size
128k;

 

      fastcgi_temp_file_write_size
128k;

 

 

 

      gzip
on;

 

      gzip_min_length  1k;

 

      gzip_buffers     4 16k;

 

      gzip_http_version
1.0;

 

      gzip_comp_level
2;

 

      gzip_types       text/plain application/x-javascript
text/css application/xml;

 

      gzip_vary
on;

 

 

 

      ssi
on;

 

      ssi_silent_errors
off;

 

      ssi_types
text/shtml;

 

 

 

      server

 

      {

 

            listen       80;

 

            server_name
localhost;

 

            index
index.shtml index.html index.php;

 

            root  /www/htdocs;

 

 

 

            location
~ .*\.(php|php5)?¥

 

            {

 

                  fastcgi_pass  127.0.0.1:9000;

 

                  fastcgi_index
index.php;

 

                  include
fastcgi.conf;

 

            }

 

            location
~ .*\.(gif|jpg|jpeg|png|bmp|swf)¥

 

            {

 

                  expires      30d;

 

            }

 

            location ~ .*\.(js|css)?¥

 

            {

 

                  expires      7d;

 

            }

 

            access_log
off;

 

      }

 

}

 

以上配置文件啓動了4個Nginx進程,指定用戶名爲 www ,而且配置了默認的虛擬主機 localhost,指向/www/htdocs目錄,這個只是方便咱們測試用。

 

 3. 啓動Nginx + PHP

 

shell> ulimit -SHn 65535

 

shell> php-fpm restart

 

shell> nginx

 

建立phpinfo.php文件測試:

 

shell> vi /www/htdocs/phpinfo.php

 

瀏覽器訪問咱們的phpinfo.php,看到如此熟悉的身影,這說明咱們的PHP CGI 已經安裝成功,順便查看是否包含 Zend 等擴展:

 

注:由於咱們配置了localhost虛擬主機段,這裏是經過主機IP訪問,如http://192.168.1.190/phpinfo.php

 

 

 

 4、配置Nginx的服務器端包含SSI

 

編輯Nginx的配置文件

 

shell> vi /usr/local/nginx/conf/nginx.conf

 

在http語句段中加入如下幾行:

 

ssi on;

ssi_silent_errors off;

ssi_types text/shtml;

 

重啓Nginx服務便可。

 

5、安裝CmsTop大衆版

 

1. 配置虛擬主機

 

你不會想安裝在
localhost 經過 IP 地址來訪問吧,確定不想,那咱們就簡要來講下 Nginx 下的虛擬主機配置:

 

編輯配置文件,增長一段
server 配置段。(提示:你也能夠像Apache同樣,寫個
include vhosts/*.conf 語句)

 

shell> vi /usr/local/nginx/conf/nginx.conf   
# 增長一段server

 

server

 

{

 

        listen       80;

 

        server_name www.demo.loc;

 

        index index.shtml index.html index.php;

 

        root  /www/htdocs/demo;

 

 

 

        location ~ .*\.(php|php5)?¥

 

        {

 

                fastcgi_pass  127.0.0.1:9000;

 

                fastcgi_index index.php;

 

                include fastcgi.conf;

 

        }

 

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)¥

 

        {

 

                expires      30d;

 

        }

 

        location ~ .*\.(js|css)?¥

 

        {

 

                expires      7d;

 

        }

 

        access_log off;

 

 

 

 

建立網站目錄:

 

shell> mkdir /www/htdocs/demo

 

2. 上傳 CmsTop 大衆版程序文件

 

上傳CmsTop大衆版至安裝目錄/www/htdocs/demo目錄下,而後咱們更改一下網站目錄的屬主和屬組。

 

shell> chown -R www:www /www/htdocs/demo

 

 

 

進入安裝界面第二步,查看環境監測配置,若是您是經過 Windows 環境下綁定 hosts 文件訪問,會發現 SSI 沒有檢測成功,這是由於咱們配置的 www.demo.loc 域名並無經過合法的
DNS 進行解析,修改 Linux 主機的 hosts 文件能夠解決。

 

shell> vi /etc/hosts

 

127.0.0.1    www.demo.loc   
# 增長此行

 

按照環境要求設置相應的目錄權限,由於咱們剛纔已經將整個目錄設爲 www 權限,因此只須要更改 /index.php 這個文件的權限便可:

 

shell> chmod 777 /www/htdocs/demo/index.php

 

恭喜您,您的環境已經徹底符合 CmsTop 大衆的安裝需求!

 

4. 建立 MySQL 數據庫

 

shell> mysql -uroot -p

 

mysql> create database demo;  # 建立 demo 數據庫( 注:爲何沒指定字符集,由於咱們已經在配置文件默認設置設置爲 utf8 了)

 

mysql> GRANT ALL PRIVILEGES ON demo.* TO ""demo""@""localhost""
IDENTIFIED BY ""cmstop"";  # 建立
demo 數據庫的帳戶

 

mysql> FLUSH PRIVILEGES;

 

而後在安裝界面的第三步中,填寫剛剛建立的數據庫信息,測試成功。下一步下一步……

 

5. CmsTop 大衆版安裝完畢

 

安裝完成後進入後臺: http://www.demo.loc/admin

 

依次進行如下操做:

 

工具
-- 文件校驗

 

工具
-- 更新緩存

 

內容
-- 快捷操做 -- 生成首頁、生成欄目頁、生成內容頁

 

區塊
-- 所有生成

 

而後預覽下咱們的前臺頁面:http://www.demo.loc

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Nginx+MySQL+PHP+phpmyadmin+memcache+eaccelerator
For CentOS Linux

 

 

 

至於爲何要搭建這個平臺,我大概就不用多說了,能找到這裏來的確定對Nginx有必定了解。很少說了,直入主題:

 

本人建議使用CentOS(yum太方便了),其餘版本不能經過yum更新的請自行下載下面的包。本人在CentOS 5.2和CentOS 4.7 Server版本中測試均無任何錯誤,單機30分鐘安裝完成!

 

爲了方便你們,下面整個過程並不複雜,你只需複製黏貼便可,無需打任何命令!

 

一,首先升級更新系統各類庫(基本完整)

 

yum -y install patch make gcc gcc-c++ autoconf kernel-devel libjpeg
libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel
zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses
ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn
libidn-devel openssl openssl-devel

yum -y install fonts-chinese scim-chewing scim-pinyin scim-tables-chinese

 

二,下載所需軟件:

 

wget http://leoz.googlecode.com/files/nginx-0.7.19.tar.gz

wget http://leoz.googlecode.com/files/php-5.2.6.tar.gz

wget http://leoz.googlecode.com/files/php-5.2.6-fpm-0.5.9.diff.gz

wget http://leoz.googlecode.com/files/libiconv-1.12.tar.gz

wget http://leoz.googlecode.com/files/libmcrypt-2.5.8.tar.gz

wget http://leoz.googlecode.com/files/mcrypt-2.6.7.tar.gz

wget http://leoz.googlecode.com/files/memcache-2.2.3.tgz

wget http://leoz.googlecode.com/files/mhash-0.9.9.tar.gz

wget http://leoz.googlecode.com/files/pcre-7.7.tar.gz

wget http://leoz.googlecode.com/files/eaccelerator-0.9.5.3.tar.bz2

wget http://leoz.googlecode.com/files/mysql-5.0.22.tar.gz

wget http://leoz.googlecode.com/files/phpMyAdmin-3.1.1-all-languages.tar.gz

 

三,安裝PHP環境支持包(就是上面的包)

 

tar zxvf libiconv-1.12.tar.gz

cd libiconv-1.12/

./configure --prefix=/usr/local

make

make install

cd ../

 

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8/

./configure

make

make install

/sbin/ldconfig

cd libltdl/

./configure --enable-ltdl-install

make

make install

cd http://www.cnblogs.com/

 

tar zxvf mhash-0.9.9.tar.gz

cd mhash-0.9.9/

./configure

make

make install

cd ../

 

cp /usr/local/lib/libmcrypt.* /usr/lib

ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

 

tar zxvf mcrypt-2.6.7.tar.gz

cd mcrypt-2.6.7/

./configure

make

make install

cd ../

 

四,安裝Mysql

 

tar -zxvf mysql-5.0.22.tar.gz

cd mysql-5.0.22

./configure --prefix=/usr/local/webserver/mysql --enable-assembler
--with-charset=utf8 --enable-thread-safe-client --with-extra-charsets=all
--without-innodb --without-isam

make;make install

cd ../

groupadd mysql

useradd -g mysql mysql

cp /usr/local/webserver/mysql/share/mysql/my-medium.cnf /etc/my.cnf

/usr/local/webserver/mysql/bin/mysql_install_db --user=mysql

chown -R mysql /usr/local/webserver/mysql/var

chgrp -R mysql /usr/local/webserver/mysql/.

cp /usr/local/webserver/mysql/share/mysql/mysql.server /etc/init.d/mysql

chmod 755 /etc/init.d/mysql

chkconfig --level 345 mysql on

echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf

echo "/usr/local/lib" >>/etc/ld.so.conf

ldconfig

ln -s /usr/local/webserver/mysql/lib/mysql /usr/lib/mysql

ln -s /usr/local/webserver/mysql/include/mysql /usr/include/mysql

service mysql start

/usr/local/mysql/bin/mysqladmin -u root password root

service mysql restart

service mysql stop

 

五,安裝PHP

 

tar zxvf php-5.2.8.tar.gz

gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1

cd php-5.2.8/

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc
--with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config
--with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir
--with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath
--enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop
--enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers
--enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl
--with-mhash --enable-pcntl --enable-sockets

make ZEND_EXTRA_LIBS=""-liconv""

make install

cp php.ini-dist /usr/local/php/etc/php.ini

cd ../

 

make

make install

cp php.ini-dist /usr/local/php/etc/php.ini

cd ../

 

六,安裝配置eaccelerator+memcache

 

tar zxvf memcache-2.2.3.tgz

cd memcache-2.2.3/

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make

make install

cd ../

 

tar jxvf eaccelerator-0.9.5.3.tar.bz2

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 ../

 

sed -i ""s#extension_dir = "./"#extension_dir =
"/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension
= "memcache.so"\n#"" /usr/local/php/etc/php.ini

sed -i ""s#output_buffering = Off#output_buffering = On#""
/usr/local/php/etc/php.ini

 

mkdir -p /usr/local/eaccelerator_cache

cat >>/usr/local/php/etc/php.ini<<EOF

[eaccelerator]

zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"

eaccelerator.shm_size="1"

eaccelerator.cache_dir="/usr/local/eaccelerator_cache"

eaccelerator.enable="1"

eaccelerator.optimizer="1"

eaccelerator.check_mtime="1"

eaccelerator.debug="0"

eaccelerator.filter=""

eaccelerator.shm_max="0"

eaccelerator.shm_ttl="3600"

eaccelerator.shm_prune_period="3600"

eaccelerator.shm_only="0"

eaccelerator.compress="1"

eaccelerator.compress_level="9"

eaccelerator.keys = "disk_only"

eaccelerator.sessions = "disk_only"

eaccelerator.content = "disk_only"

#[eaccelerator]

#zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"

#eaccelerator.shm_size="128"

#eaccelerator.cache_dir="/usr/local/eaccelerator_cache"

#eaccelerator.enable="1"

#eaccelerator.optimizer="1"

#eaccelerator.check_mtime="1"

#eaccelerator.debug="0"

#eaccelerator.filter=""

#eaccelerator.shm_max="0"

#eaccelerator.shm_ttl="300"

#eaccelerator.shm_prune_period="120"

#eaccelerator.shm_only="0"

#eaccelerator.compress="1"

#eaccelerator.compress_level="9"

 

七,建立www用戶和用戶組,

 

groupadd www

useradd -g www www

mkdir -p /web/www

chmod +w /web/www

mkdir -p /web/logs

chmod 777 /web/logs

 

chown -R www:www /web/www

rm -f /usr/local/php/etc/php-fpm.conf

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

 

echo "ulimit -SHn 51200" >/root/run.sh

echo "/usr/local/php/sbin/php-fpm start" >>/root/run.sh

 

八,安裝Nginx

 

tar zxvf pcre-7.7.tar.gz

cd pcre-7.7/

./configure

make && make install

cd ../

tar zxvf nginx-0.7.19.tar.gz

cd nginx-0.7.19/

./configure --user=www --group=www --prefix=/usr/local/nginx
--with-http_stub_status_module --with-http_ssl_module

make && make install

cd ../

rm -f /usr/local/nginx/conf/nginx.conf

cp conf/nginx.conf /usr/local/nginx/conf/nginx.conf

sed -i ""s/www.xxxx.com/""¥domain""/g"" /usr/local/nginx/conf/nginx.conf

 

rm -f /usr/local/nginx/conf/fcgi.conf

cp conf/fcgi.conf /usr/local/nginx/conf/fcgi.conf

 



echo "/usr/local/nginx/sbin/nginx" >>/root/run.sh

chmod 777 /root/run.sh

service mysql start

/root/run.sh

 

九,安裝phpmyadmin

 

tar zxvf phpMyAdmin-3.1.1-all-languages.tar.gz

mv phpMyAdmin-3.1.1-all-languages /web/www/phpmyadmin

 

十,加入開機自啓動

echo "ulimit -SHn 51200" >>/etc/rc.local echo "/usr/local/php/sbin/php-fpm start" >>/etc/rc.local echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local

相關文章
相關標籤/搜索