分类: LINUX
2011-06-17 15:39:22
RedHat linux AS 4.8+Apache2.2+MYSQL5.0.54+PHP5.3.6 配置手记
因系统RedHat AS 4.8自带的httpd与mysql及php无法满足客户的需求,除了vsftpd外,所有其它包都是源代码安装,这次php5.3.6与mysql 5.5安装编译没有通过,php在编译过程报一些 库文件错误,以后在虚拟环境中再测试。
一、安装MYSQL
# groupadd mysql
# useradd -g mysql -d /usr/local/mysql/var -M mysql
# tar -zxvf mysql-5.0.54.tar.gz
# cd mysql-5.0.54
./configure –prefix=/usr/local/mysql --with-charset=gbk \ 添加gbk字符支持
--with-extra-charsets=all --enable-assembler --enable-thread-safe-client
# make
# make install
# /usr/local/mysql/bin/mysql_install_db –user=mysql
# chown -R mysql:mysql /usr/local/mysql/var
# cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# cp /usr/local/mysql/share/mysql/my-medium.cnf /usr/local/mysql/etc/my.cnf
###mysql 5.5编译安装法
先安装cmake
解压mysql 5.5.
进入mysql 5.5源码目录
运行
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
make
make install
会自动安装到/usr/local/mysql下
Mysql 5.5 安装时默认字符集注意点
现在建立的表默认字符集都是latin1. 和5.0/5.1版本不一样, 早期版本编译时指定默认字符集是起作用的.
为了解决这个问题, 一定要在my.cnf配置文件里指定如下参数才行:
[client]
default-character-set = gbk
[mysqld]
character-set-server = gbk
然后重启mysqld, 此时默认字符集才正确:
mysql>show variables like 'character%';
+--------------------------+------------------------------------+
| Variable_name | Value |
+--------------------------+------------------------------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | gbk |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | gbk |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql/share/charsets/ |
+--------------------------+------------------------------------+
8 rows in set (0.00 sec)
mysql>show variables like 'collation%';
+----------------------+----------------+
| Variable_name | Value |
+----------------------+----------------+
| collation_connection | gbk_chinese_ci |
| collation_database | gbk_chinese_ci |
| collation_server | gbk_chinese_ci |
+----------------------+----------------+
3 rows in set (0.00 sec)
这时候再建立的数据库默认就是gbk, 且插入和显示中文数据都没有问题了.
安装OpenSSL
# tar -zxvf openssl-1.0.0.tar.gz
# cd openssl-1.0.0
# ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl shared zlib
# make
# make install
# vi /etc/ld.so.conf
添加路径
/usr/local/ssl/lib
更新运行时连接
# ldconfig
编译和安装 apr
# tar -zxvf apr-1.4.2.tar.gz
# cd apr-1.4.2
# ./configure --prefix=/usr/local/apr
# make
# make install
编译和安装 apr-util
# tar -zxvf apr-util-1.3.9.tar.gz
# cd apr-util-1.3.9
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make
# make install
安装Apache
tar -zvxf httpd-2.2.15.tar.gz
cd httpd-2.2.15
# vi server/mpm/worker/worker.c
找到下面几行,并改成如下的数值,其目的是在源码中修改apache可支持的最大线程数和最大客户端数目。
# define DEFAULT_SERVER_LIMIT 256
# define MAX_SERVER_LIMIT 40000
# define DEFAULT_THREAD_LIMIT 256
# define MAX_THREAD_LIMIT 40000
./configure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=all --with-mpm=worker
--enable-rewrite --enable-deflate --enable-cache --enable-disk-cache --enable-mem-cache
--enable-file-cache --enable-proxy --enable-ssl --with-ssl=/usr/local/ssl –
--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make
make install
先安装支持包(注意安装顺序)
先列出配置gd2需要的网址
gd-2.0.35.tar.gz
jpegsrc.v6b.tar.gz
libpng-1.4.1.tar.gz
zlib-1.2.4.tar.gz
freetype-2.1.9.tar.gz
libxml2-2.6.30.tar.gz
ftp.gnome.org/pub/GNOME/sources/libxml2
建立jpeg目录 (安装jpeg时需先建立安装目录)
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir /usr/local/jpeg6/man
mkdir /usr/local/jpeg6/man/man1
安装libxml
# tar -zxvf libxml2-2.6.30.tar.gz
# cd libxml2-2.6.30
# ./configure (xml默认安装就可以,不要指定路径了,因为安装时php可能找不到它,PHP5只支持libxml2-2.5.10以上版本)
# make
# make install
安装zlib
tar xzvf zlib-1.2.4.tar.gz
cd zlib-1.2.4
#不要用--prefix自定义安装目录,影响gd的安装
./configure
make
make install
安装freetype
tar xzvf freetype-2.3.12.tar.gz
cd freetype-2.3.12
./configure --prefix=/usr/local/freetype
make
make install
安装libpng
tar xzvf libpng-1.4.1.tar.gz
#不要用--prefix自定义安装目录,影响gd的安装
cd libpng-1.4.1
cp scripts/makefile.std makefile
make
make install
安装jpeg
tar xzvf jpegsrc.v6b.tar.gz
./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static
make
make install
安装GD
tar xzvf gd-2.0.35.tar.gz
./configure --prefix=/usr/local/gd --with-jpeg=/usr/local/jpeg6 --with-png --with-zlib --with-freetype=/usr/local/freetype
make
make install
安装cURL
# wget http://curl.haxx.se/download/curl-7.20.1.tar.gz
# tar -zxvf curl-7.20.1.tar.gz
# cd curl-7.20.1
# ./configure --prefix=/usr/local/curl --with-ssl=/usr/local/openssl
# make
# make install
tar -zxvf php-5.3.6.tar.gz
cd php-5.3.6
./configure --prefix=/usr/local/php5 \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=/usr/local/mysql \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-libxml-dir=/usr/local/lib \
--with-gd=/usr/local/gd \
--with-jpeg-dir=/usr/local/jpeg6 \
--with-zlib \
--with-png-dir \
--with-freetype-dir=/usr/local/freetype \
--with-xmlrpc \
--with-iconv
--enable-soap
--enable-sockets
--enable-mbstring
--enable-static
--with-openssl=/usr/local/openssl
--with-curl=/usr/local/curl
make
make install
cp ./php.ini-development /usr/local/php/lib/php.ini ##注意不要放在/usr/local/php/etc目录下,如果你在架设zabbix监控系统,可能会找不到php.ini配置文件,我。
--with-mysqli的目录指定要正确,否则会报错
修改httpd.conf
#vi /usr/local/apache/conf/httpd.conf
加载php模块,去掉注释“#”,如没有此行,请加上。
LoadModule php5_module modules/libphp5.so
加上此两行
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
二、vsftpd采用二进制安装,配置较简单,禁止了匿名登录,只允许系统本地用户登录,且登录后不能切换到其它目录。