下面主要描述一下Ubuntu 10.10下面php环境的配置问题
(注,只进行主要软件包的安装而没有详细的配置文件描述)
1. apt安装所需的软件包:
apt-get install cpp flex gcc libarchive-zip-perl libc6-dev libcompress-zlib-perl libdb-dev libpopt-dev lynx nmap perl perl-modules unzip zip zlib1g-dev autoconf libtool bison autotools-dev g++ build-essential
2.安装pcre 7.9
cd /usr/local/src
wget http://ncu.dl.sourceforge.net/sourceforge/pcre/pcre-7.9.tar.gz
tar zxvf pcre-7.9.tar.gz
cd pcre-7.9
./configure
make && make install
cd ..
rm -rf pcre-7.9
rm -rf /usr/bin/pcre-config
cp -a /usr/local/bin/pcre-config /usr/bin/
rm -rf /usr/lib/libpcre.a
cp -a /usr/local/lib/libpcre.a /usr/lib/
3. 安装Mysql
本例所用为mysql5.5.8
3.1,安装libncurses5-dev库:
apt-get install libncurses5-dev
3.2 添加Mysql用户组:
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql mysql
3.3 下载并编译安装MySQL 5.5.8:
安装需要用到的库
shell:~$ sudo apt-get install cmake
shell:~$ sudo apt-get install libncurses5-dev
shell:~$ sudo apt-get install bison
wget http://mysql.mirrors.pair.com/Downloads/MySQL-5.5/mysql-5.5.8.tar.gz
tar zxvf mysql-5.5.8.tar.gz
cd mysql-5.5.8/
./configure
–prefix=/usr/local/mysql
–without-debug
–with-extra-charset=all
–exec-prefix=/usr/local/mysql
–with-pthread
–enable-assembler
–enable-thread-safe-client
–with-mysqld-user=mysql
–with-ssl
–without-isam
–without-innodb
make && make install
----配置文件my.cnf设置
----进入mysql安装目录下的支持文件目录
shell:~$ cd /usr/local/mysql5/support-files
shell:~$ sudo cp my-medium.cnf /etc/my.cnf
----添加mysql运行的用户和用户组
shell:~$ sudo groupadd mysql
shell:~$ sudo useradd -g mysql mysql
shell:~$sudo chown -R root .
shell:~$sudo chown -R mysql data
shell:~$sudo chgrp -R mysql .
----生成新的MySQL 授权表
----进入mysql安装目录下的脚本目录
shell:~$ cd /usr/local/mysql5/scripts
----利用mysql_install_db脚本生成新的MySQL 授权表
shell:~$ sudo./mysql_install_db --basedir=/usr/local/mysql5 --datadir=/usr/local/mysql5/data --user=mysql
注意 :--basedir=/usr/local/mysql5 --datadir=/usr/local/mysql5/data
这两个参数是必须的。因为mysql_install_db要利用basedir在datadir下建立授权表。
----mysql server在系统中的服务项设置
----复制服务文件并修改
shell:~$ sudo cp mysql.server mysqld
----修改mysqld
basedir=/usr/local/mysql5
datadir=/usr/local/mysql5/data
shell:~$ sudo mv mysqld /etc/init.d/mysqld
解释: linux的/etc/init.d/目录下存放的是系统的各种服务文件,可以对其设置达到开机服务自启动。
----启动服务
shell:~$ sudo service mysqld start
----关闭服务
shell:~$ sudo service mysqld stop
4. 安装Apache:
本例中所使用的是Apache 2.2.17
4.1,下载并解压缩Apache 2.2.17:
wget http://archive.apache.org/dist/httpd/httpd-2.2.17.tar.gz
tar zxvf httpd-2.2.17.tar.gz
apache必须先安装apr(可移植运行库)和apr-util
apache在没有正确实安装apr和apr-util时会出现
configure: error: APR version 1.2.0 or later is required
configure: error: APR-util version 1.2.0 or later is required
cd httpd-2.2.17/srclib/apr
shell:./buildconf
shell:./configure
shell:make && make install
然后在/etc/ld.so.conf 以下增加一行
/usr/local/apr/lib
cd httpd-2.2.17/srclib/apr-util
shell:./buildconf --with-apr=../apr
shell:./configure --with-apr=/usr/local/apr/
shell: make && make install
cd /usr/local/src/httpd-2.2.17
./configure
–prefix=/usr/local/apache2
–enable-mods-shared=all
–with-mysql=/usr/local/mysql
–enable-deflate
–enable-cache
–enable-file-cache
–enable-mem-cache
–enable-disk-cache
–enable-rewrite
–enable-expires
–enable-authn-dbm
–enable-vhost-alias
–with-mpm=worker
–with-ssl
–disable-ipv6
–disable-cgid
–disable-cgi
make && make install
在apache的目录bin下,运行:
shell:./apachectl start
停止:
shell:./apachectl stop
重起:
shell:./apachectl resart
IT works
5,安装PHP:
本例中所用的是php5.3.5
先安装GD库及其他相关组件,详细请参照( http://www.phpcto.net/blog/read.php?121 的 5.1及5.2部分)
5.1 安装PHP 5.3.5
cd /usr/local/src
wget http://us.php.net/distributions/php-5.3.5.tar.gz
tar zxvf php-5.3.5.tar.gz
cd php-5.3.5
./configure
–prefix=/usr/local/php
–with-apxs2=/usr/local/apache2/bin/apxs
–with-mysql=/usr/local/mysql5
--with-pdo-mysql=/usr/local/mysql5 (开启了mysql 的PDO)
–with-mysqli=/usr/local/mysql5/bin/mysql_config
–with-config-file-path=/etc
–with-zlib=/usr/local
–with-libxml-dir
–with-gd=/usr/local/gd2
–with-jpeg-dir=/usr/local
–with-png-dir=/usr/local
–with-ttf=/usr/local
–with-iconv=/usr/local
–with-mcrypt=/usr/local
–enable-static
–enable-maintainer-zts
–enable-zend-multibyte
–enable-zend-multibyte
–enable-inline-optimization
–enable-sockets
–enable-wddx
–enable-zip
–enable-calendar
–enable-bcmath
–enable-ftp
–enable-soap
–enable-mbstring
–disable-ipv6
–disable-cgi
–disable-debug
(如果在配置过程对某扩展有误,可以尝试去掉对其扩展的支持)
make ZEND_EXTRA_LIBS=’-liconv’
make install
cp php.ini-dist /etc/php.ini
至此,PHP的安装也已经完成。
Apache和PHP的整合部分此处不再写出
注: 本文参照的部分文档
www.phpcto.net/blog/read.php?121
http://hi.baidu.com/cary1208/blog/item/9cbad616da78a002b8127b4c.html
http://soph.jp/MT/archives/2006/05/apache_222.php