+ -
当前位置:首页 → 问答吧 → 多个php版本多个mysql版本下的NGINX+php+mysql+zend 安装教程

多个php版本多个mysql版本下的NGINX+php+mysql+zend 安装教程

时间:2009-05-20

来源:互联网

本帖最后由 七月十五 于 2009-5-20 21:59 编辑

一台机器多个版本mysql 安装步骤:(mysql5.0+mysql5.1+mysql4)
1.
groupadd mysql .
2.
useradd –g mysql mysql
3.
cd /usr/local/src
二、第一步安装mysql5.0
1.tar –zxvf mysql5.0.tar.gz
2.cd mysql5.0 (我的目录为5.0以实际的目录名为准)
3../configure –prefix=/usr/local/mysql5.0(开始编译5.0版本)
4.make
5.make install (安装完毕)
6.cp -r scripts /usr/local/mysql5.0/ (因为5.0编译完后没有直接将scripts 拷贝到安装目录,我们手工操作一下)
7.cd /usr/local/mysql5.0
8. scripts/mysql_install_db --user=mysql(运行mysql_install_db 初始化您的数据目录)
9. chown -R root .
(后面的点不能省略)
10. chown –R mysql var
11.chgrp –R mysql . (后面的点不能省略)
12.
./bin/mysqld_safe –user=mysql &
13.
./bin/mysqladmin –uroot password 123456
14. cp ../src/mysql5.0/support-files/my-large.cnf
/etc/my50.cnf (因为多版本所以我处理的时候先用 my50.cnf 为名字)
15. cp ../src/mysql5.0/support-files/mysql.server

/etc/init.d/mysql5.0
16.chkconfig --add mysql5.0
17.chkconfig
--level
345
mysql5.0
on
18.chkconfig --list mysql5.0
19.(处理到这我们得改些参数); vi /etc/init.d/mysql5.0
修改下面的内容:
conf=/etc/my50.cnf
$bindir/mysqld_safe --defaults-file=/etc/my50.cnf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
vi /etc/my50.cnf修改相关的端口
port = 3307 (不同的版本对应不同的版本)
socket = /tmp/mysql50.sock(不同的版本建立自己的SOCK)

20. ps –A 查看进程  找到 mysql_safe
和 mysqld
对应的 PID
        首先 kill -9 (mysql_safe对应的PID) 然后 同样kill -9 (mysqld的PID)

21.chmod 755 /etc/init.d/mysql5.0
        然后其他版本 如上步骤执行 !


每个版本装好后 用 service mysql5.0(您的服务,即拷贝到 /etc/init.d 下面的mysql 启动脚本) start
这样 多个 mysql 就装好了
三、GD库的安装
1安装 jpeg6

建立目录:
mkdir -p /usr/local/jpeg6
mkdir -p /usr/local/jpeg6/bin
mkdir -p /usr/local/jpeg6/lib
mkdir -p /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/man
mkdir -p /usr/local/jpeg6/man1
mkdir -p /usr/local/jpeg6/man/man1
cd /usr/local/src
tar -zvxf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make && make install
2安装libpng
cd /usr/local/src
tar -zvxf libpng-1.2.12.tar.gz
cd libpng-1.2.12
./configure  //这个如同上面zlib的说明一样,不要带参数,让它默认安装到相应目录
make && make install
3 zlib安装
cd /usr/local/src
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure //这个配置编译命令不要加目录参数,我试过的,加上--prefix=/usr/local/zlib这个参数,在这里是一定会顺利编译通的,但可惜的是,到下面你编译gd库时,是不会通过的,到时就是会出问题,也真怪了,这些问题不是摸索出来,我是不会相信的。网友们自己有空了也可以多试试,看看为什么不能加参数。
make && make install
4安装 freetype
cd /usr/local/src
tar -zvxf freetype-2.3.4.tar.gz
cd freetype-2.3.4
mkdir -p /usr/local/freetype
./configure --prefix=/usr/local/freetype
make && make install
5安装GD库
//下面开始另一个重要的工作,安装gd库,因为gd库在window操作系统下默认是自带有的,但到linux下,必须得自己安装,不然,很多目前流行的论坛图水印功能、缩略图功能等都不能用,打开自己的网站图片大的大小的小,严重变形,影响美观,所以下决心要整冶好gd库。
//这个gd库的安装是目前第四重要的软件。呵呵,第一个当然是php了,老二就是apache了,老三还用说吗是mysql,老四就是gd库了。呵呵。
cd /usr/local/src
tar -zvxf gd-2.0.34.tar.gz
mkdir -p /usr/local/gd
cd gd-2.0.34
./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg6/ --with-png --with-zlib --with-freetype=/usr/local/freetype/
//大家看到了吧,在这些参数中,由于上面安装zlib、png二个软件没有指定目录,所以这里也不要指定了。
//第一次安装测试时,上面zlib、png都很顺利编译通过,但到了这里,总是提示找不到freetype/png等相应的路径啊什么的。
make && make install
6 curl
curl安装
cd /usr/local/src //进入软件存放目录
tar -zxvf curl-7.16.2.tar.gz
./configure --prefix=/usr/local/curl
make && make install //这个小软件很简单,不明白什么意思,到网上查资料吧。
7
libxml安装

cd /usr/local/src
tar -xjvf libxml2-2.6.23.tar.bz //这个我下的是.bz的,你下的如果是.gz的就执行 tar -zxvf libxml2-6.23.tar.gz
cd /libxml2-2.6.23
./configure --prefix=/usr/local/libxml2


四、
php的安装(多版本注意路劲即可)
在src目录下面
解压你的PHP版本我先做PHP5.25的
然后
进入php5.25目录


./configure --prefix=/usr/local/php5 --with-config-file-
path=/usr/local/php5/etc --with-mysql=/usr/local/mysql5.1 --with-
freetype-dir=/usr/local/freetype/ --with-jpeg-dir=/usr/local/jpeg/ --
with-png-dir --with-curl=/usr/local/curl/ --with-zlib-dir --with-
libxml-dir=/usr/local/libxml/ -enable-shared --with-gd=/usr/local/gd/
--enable-fastcgi --enable-discard-path
--enable-force-cgi-redirect -
-enable-mbstring=all --enable-mbregex --enable-so
( 编译参数不能写错哦)
Make && make install

拷贝php.ini-dist 到/usr/local/php5/etc/php.ini

五、安装lighttpd中附带的spawn-fcgi(用来启动PHPCGI)
网络下载lighttpd-1.4.20版本
只需要编译 ./configure
make
即可
在安装包目录下面的 src 文件夹中 cp spawn-fcgi /usr/local/php5/bin/

启动php-cgi 进程 /usr/local/php5/bin/spawn-fcgi –a 127.0.0.1 –p 9000 –C64 –u root –f /usr/local/php5/bin/php-cgi (注意PHP4 都是 php, 我可是找了好久才知道这个的郁闷死了)

安装nginx (我选择的是0.6.31)

1.安装nginx 所需要的pcre库 (pcre-7.8.tar.gz)

tar –zxvf pcre-7.8.tar.gz

cd pcre-7.8

./configure

make
&& make install

2.安装nginx(nginx-0.6.31.tar.gz)
tar –zxvf nginx-0.6.31.tar.gz
cd /nginx-0.6.31
./configure –prefix=/usr/local/nginx –with-http_stup_status_module
make &&make install
cd /usr/local/nginx/conf/
创建fcgi.conf
Vi fcgi.conf 并拷贝下面内容到fcgi.conf
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;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
#fastcgi_param  REDIRECT_STATUS    200;

配置文件
rm –f nginx.conf
vi nginx.conf 拷贝下面的内容
#user
nobody;
worker_processes
1;
#error_log
logs/error.log;
#error_log
logs/error.log
notice;
#error_log
logs/error.log
info;
#pid
logs/nginx.pid;
events {

worker_connections
1024;
}
http {

include
mime.types;

default_type
application/octet-stream;

#log_format
main
'$remote_addr - $remote_user [$time_local] $request '

#
'"$status" $body_bytes_sent "$http_referer" '

#
'"$http_user_agent" "$http_x_forwarded_for"';

#access_log
logs/access.log
main;

sendfile
on;

#tcp_nopush
on;

#keepalive_timeout
0;

keepalive_timeout
65;

#gzip
on;

server {

listen
80;

server_name
localhost;

#charset koi8-r;

#access_log
logs/host.access.log
main;

location /{

root
html;

index index.php
index.html index.htm;

}

#error_page
404
/404.html;

# redirect server error pages to the static page /50x.html

#

error_page
500 502 503 504
/50x.html;

location = /50x.html {

root
html;

}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

#location ~ \.php$ {

#
proxy_pass
http://127.0.0.1;


#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.php$ {

root
html;

fastcgi_pass
127.0.0.1:9000;

fastcgi_index
index.php;

include

fcgi.conf;

}

# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

#location ~ /\.ht {

#
deny
all;

#}

}

# another virtual host using mix of IP-, name-, and port-based configuration

#

server {

listen
81;
#
(注意处  如果安装多个版本这里添加运行的端口和CGI启动的端口)

#listen
somename:8080;

#server_name
somename
alias
another.alias;

location / {

root
html;

index
index.html index.htm index.php;

}

location ~ \.php$ {

root
html;

fastcgi_pass
127.0.0.1:10000;

fastcgi_index
index.php;

include
fcgiphp4.conf;

}

}

# HTTPS server

#

#server {

#
listen
443;

#
server_name
localhost;

#
ssl
on;

#
ssl_certificate
cert.pem;

#
ssl_certificate_key
cert.key;

#
ssl_session_timeout
5m;

#
ssl_protocols
SSLv2 SSLv3 TLSv1;

#ssl_ciphers
ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

#
ssl_prefer_server_ciphers
on;

#
location / {

#
root
html;

#
index
index.html index.htm;

#
}
#}
创建开机启动 cp /usr/local/nginx/sbin/nginx
/etc/init.d/nginx
七 安装zend(ZendOptimizer-3.3.0)
安装时在选择APACHE 服务时有个NO 选项
给出PHP.INI 的路径
/usr/local/php5/etc
安装完毕 启动 service nginx start
OK
这里就安装完了
如果正常安装时 软件加载不了 请修改/etc/sysconfig/selinux 下的
SELINUX=disabled
您的根目录就在/usr/local/nginx/html/ 下

作者: q376621340   发布时间: 2009-05-20

文字太小了,我只能尽力调整了一部分。

作者: xieaotian   发布时间: 2009-05-20