[文章作者: 陈瑞金(xuejin38) 本文版本:v0.1 最后修改:2008.08.11 转载请注明原文链接:
http://gooubuntu.blogspot.com
配置平台: ubuntu 8.10 或是dabian
黄色代表输入命令
需要的原码下载:
下面是所需要的软件,因为apache,php,mysql,ZendOptimizer很方便找到,我就不提供下载地址了
可以在下列地址取得
http://www.apache.org
http://www.php.net
http://www.mysql.com
http://www.zend.com
下面是这是安装GD时所需要的软件
http://www.ijg.org/files/jpegsrc.v6b.tar.gz
http://www.zlib.net/zlib-1.2.3.tar.gz
http://prdownloads.sourceforge.net/l...ar.gz?download
http://easynews.dl.sourceforge.net/s...-2.1.3.tar.bz2
http://telia.dl.sourceforge.net/sour...-2.1.3.tar.bz2
在安装apachen之前要先安装make gcc g++ 编译程序.
#apt-get install g++
一、下载源码包:
先从官方网站下载apache2、mysql5、php5的源码安装包
用wget下载,一般默认代码下载存放位置是全部放在/usr/local/src目录下面
本文架设的原码下面这些:mysql-5.0.45.tar.gz,httpd-2.2.2.tar.gz,php-5.1.4.tar.gz
二、安装mysql
A、增加mysql组、用户
#groupadd mysql
#useradd -g mysql mysql
B、编译并安装mysql:
#cd /usr/local/src
#tar zxvf mysql-5.0.45.tar.gz
#cd mysql-5.0.45
#./configure --prefix=/usr/local/mysql
如果出现了以下错误:
checking for tgetent in -ltermcap... no
checking for termcap functions library... configure: error: No curses/termcap library found
说明 curses/termcap 库没有安装
#apt-cache search curses | grep lib 查找程序
#libncurses5-dev ,然后重新运行配置
#apt-get install libcdk5-dev
#make
#make install
[#checkinstall -D --install=no 这步可以不做.做成deb包,以便以后使用。]
C、配置mysql
#cp support-files/my-medium.cnf /etc/my.cnf
给mysql权限:
#cd /usr/local/mysql
#chown -R mysql:mysql . (这个后面有加一个点,说明是在当前的目录下设权限)
初始化mysql:
#./bin/mysql_install_db --user=mysql
#chown -R root . (这个后面有加一个点,说明是在当前的目录下设权限)
#chown -R mysql var
#./bin/mysqld_safe --user=mysql &
按ctal+c
#netstat -tl 查看是否启动起来.
D、设置mysql自启动:
#cd /usr/local/src/mysql-5.0.45
#cp /usr/local/mysql/share/mysql/mysql.serve /etc/init.d/mysqld
#chmod 700 /etc/init.d/mysqld
E、测试
#/usr/local/mysql/bin/mysqladmin ping 出现:mysqld is alive 说明启动了.
#/usr/local/mysql/bin/mysqladmin version
出现下面这个:
---------------------------------------------------------------------------------------------------------
/usr/local/mysql/bin/mysqladmin Ver 8.41 Distrib 5.0.45, for pc-linux-gnu on i686
Copyright (C) 2000-2006 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Server version 5.0.45-log
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /tmp/mysql.sock
Uptime: 2 min 16 sec
Threads: 1 Questions: 2 Slow queries: 0 Opens: 12 Flush tables: 1 Open tables: 6 Queries per second avg: 0.015
---------------------------------------------------------------------------------------------------------
出现上面这个说明你成功安装上了.
#/usr/local/mysql/bin/mysql
F、添加root密码
#/usr/local/mysql/bin/mysqladmin -u root password "your password" your password为你设置访问mysql的密码
G、配置库文件搜索路径及环境变量
#echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
#ldconfig -v
#export PATH=$PATH:/usr/local/mysql/bin
H、再访问mysql测试,
#/usr/local/mysql/bin/mysql -u root 输入刚才设置mysql的root的密码就可以进入了。
使用:
# /usr/local/mysql/bin/mysql -u root -p 可以访问mysql
三.安装插件[freetype/jpeg/zlib/gd2/libpng]
1.freetype
#tar -xvjf freetype-2.1.3.tar.bz2
#cd freetype-2.1.3
#./configure
#make
#make install
2.jpeg
#tar -xvzf jpegsrc.v6b.tar.gz
#cd jpeg-6b/
#./configure --enable-shared --enable-static
#make
#mkdir /usr/local/man
#mkdir /usr/local/man/man1
#make install
-------上面安装不行可以试这个------------
安装 jpeg6
CODE:
建立目录:
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
--------------------------
#vi /etc/ld.so.conf 加入一行:
#/usr/local/jpeg6/lib
#/sbin/ldconf
--------------------------
3.zlib
#tar zxvf zlib-1.2.3.tar.gz
#cd zlib-1.2.3
#./configure
#make
#make install
4.libpng
#tar zxvf libpng-1.2.8-config.tar.gz
#cd zlib-1.2.8
#./configure
#make
#make test
#make install
5.gd2
#tar -zxvf gd-2.0.27.tar.gz
#cd gd-2.0.27/
#./configure --prefix=/usr/local/gd2
-----------------提示下面------------------
** Configuration summary for gd 2.0.34:
Support for PNG library: yes
Support for JPEG library: yes
Support for Freetype 2.x library: yes
Support for Fontconfig library: no
Support for Xpm library: no
Support for pthreads: yes
--------------------------------------------
#make
#make install
四、编译并安装apache
#useradd www 添加用户
#groupadd www 添加用户组
#cd /usr/local/ser/
#tar zvxf httpd-2.2.2.tar.gz
#cd httpd-2.2.2
#./configure --prefix=/usr/local/apache2 --enable-module=most --enable-rewrite --enable-shared=max --enable-so
#make
#make install
进入/usr/local/apache2/conf/ 修改文档httpd.conf
# vi /usr/local/apache2/conf/httpd.conf
1.修改:#ServerName www.example.com:80---->>ServerName 192.168.0.187
2.修改:#User daemon---->>User www
#Group daemon---->>Group www
#mkdir /home/www 添加存放http的目录
#mkdir /home/www/html
# chown www:www www -Rf 设置目录的权限只有www用户所属的权限
#cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd 配置启动程序
# chown 700 /etc/init.d/httpd
# ln -s /usr/local/apache2/bin/apachectl /etc/rc2.d/S101http 创建一个启动连接脚本
#/etc/init.d/httpd start
#netstat -tl (查看启动进程)
[#checkinstall -D --install=no 做成deb包,以便以后使用]
五、编译并安装php
#cd /usr/local/src/
#tar zxvf php-5.1.4.tar.gz
#cd php-5.1.4
# ./configure --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/apache2/bin/apxs --with-gd --with-zlib --with-gettext --with-zlib-dir --with-jpeg-dir
会出现下面这些错误是因为在安装php的时候,系统默认缺少两个组件
#sudo apt-get install flex
#sudo apt-get install libxml2 libxml2-dev
--------------------------------------------
Configuring extensions
checking whether to enable LIBXML support... yes
checking libxml2 install dir... no
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
# 安装过程中出现的错误:
configure: error: cannot find output from lex; giving up
# 错误分析:
需要安装flex, bison:
#sudo apt-get install bison
#sudo apt-get install flex
# 安装过程中出现的错误:
configure: error: xml2-config not found. Please check your libxml2 installation.
# 错误分析:
只需要安装libxml2-dev:
#sudo apt-get install libxml2-dev
--------------------------------------------
#make
#make install
[#checkinstall -D --install=no 做成deb包,以便以后使用。]
#cp php.ini-dist /usr/local/lib/php.ini
六、编辑apache配置文件httpd.conf,以apache支持php
1.编辑httpd.conf
#vim /usr/local/apache2/conf/httpd.conf
定位至DirectoryIndex index.html
修改为:
DirectoryIndex index.php index.html
2.让apache支持php网页,
找到AddType application/x-gzip .gz .tgz 再在其下面添入
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php .phtml
apache里还有一些参数需要修改
ServerName 如果不修改这项,启动apache的时候,会报错
DocumentRoot 改成你希望指定的主目录
3.添加一个网页进行测试/usr/local/apache2/htdocs/下新建一个index.php文件
加入下面代码:
<?
phpinfo();
?>
4.重启apache,
#/usr/local/apache2/bin/apachectl restart
其中假设root,1234是mysql的登陆帐户和密码,在浏览器中浏览下index.php页面测试下就可以了!
#lynx 127.0.0.1
成功了就会显示:
SuccessfullyHello World
说明,apache2、php5、mysql成功结合一起了。
虽然现在apache+mysql+php配置文完成了,但是还要配置让它在启动机器时可以自动启动这些服务程序.
七、配置apache+mysql自动启动.
1.设置Apache:
首先把apachectl拷贝到/etc/init.d目录下,并改名为apache2
# cp /usr/local/apache2/bin/apachectl /etc/init.d/apache2
然后进入/etc/rc2.d目录,这是debian默认的启动级别。建立连接指向/etc/init.d/apache2
# cd /etc/rc2.d
# ln -s /etc/init.d/apache2 S20apache2
重新启动系统后,apache自动启动。
2.设置MYSQL
首先拷贝mysql.server到/etc/init.d目录下命名为mysql
# cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql
然后进入/etc/rc2.d目录,这是debian默认的启动级别。建立连接指向/etc/init.d/mysql
# cd /etc/rc2.d
# ln -s /etc/init.d/mysql S20mysql
重新启动系统后,mysql就自动启动了。
七、安装phpMyAdmin
#tar –zxf ../src/phpMyAdmin-2.8.0.1.tar.gz
#mv phpMyAdmin-2.8.0.1 /var/www/html/phpmyadmin/
#cd /home/www/html/phpmyadmin
#cp libraries/config.default.php ./config.inc.php
修改:
#$cfg['PmaAbsoluteUri'] = '';
$cfg['PmaAbsoluteUri'] = 'localhost/phpmyadmin';
#$cfg['blowfish_secret'] = '';
$cfg['blowfish_secret'] = 'cookie';
#$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
有时在打开IE还是会提示出错.要清理一下IE的临时文件.就可以了.
声明:
本次安装phpMyAdmin指南适用于WINDOWS/LINUX所有站点环境。
安装中phpMyAdmin使用cookie验证,即通过网站访问时要求输入用户名密码登入,本配置适合大多数网站管理。
安装phpMyAdmin其实很简单:
1、下载phpMyAdmin的最新版程序。
官方下载:
http://jaist.dl.sourceforge.net/sour...nguages.tar.gz
本站下载:
http://www.cncms.com.cn/mysql/upfile...nguages.tar.gz
2、解压并上传到站点目录(前提这个站点要配置了PHP支持,这里不做多讲)。
3、复制libraries/config.default.php到根目录下,并重命名为config.inc.php
4、修改config.inc.php的配置,具体修改如下:
4.1、 行:$cfg['PmaAbsoluteUri'] = '';
修改为:$cfg['PmaAbsoluteUri'] = 'http://www.domain.com/phpMyAdmin';
这里要填写的网址为phpMyAdmin的网页访问地址,也可以留空不限制访问地址。
4.2、 行:$cfg['blowfish_secret'] = '';
修改为:$cfg['blowfish_secret'] = 'cookie';
4.3、 行:$cfg['Servers'][$i]['auth_type'] = 'config';
修改为:$cfg['Servers'][$i]['auth_type'] = 'cookie';
4.4、 如果你要管理的MySQL非本地服务器,还需要配置:
$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname or IP address
//把localhost修改为您的MySQL服务器IP
$cfg['Servers'][$i]['port'] = ''; // MySQL port - leave blank for default port
//port要配置的是MySQL服务器连接端口,如果是默认的3306端口,可以不填写。