分类: LINUX
2007-11-05 21:27:25
redhat as4下Mysql5+php5+apache2.2.4+GD2安装
一. 准备工作:
apache 2.2.4 下载
mysql 5.0.22 下载
php 5.2.1 下载
gd 下载 图像处理需要的LIB)
zlib 下载 (使用GD功能所需要的软件包)
libpng-config 下载 (使用GD功能所需要的软件包)
jpeg-6b 下载 [url=ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz]ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz[/url] (使用GD功能所需要的软件包,支持jpeg图片)
freetype2下载 (使用GD功能所需要的软件包,FreeType2是一个简单的跨平台的字体绘制引擎)
fontconfig 下载 (使用GD功能所需要的软件包,fontconfig是字体库)
openssl 下载 (apache的https协议需要的模块)
libxml2 下载
Libxslt 下载
zend optimizer 下载
1. 安装OpenSSL
tar zxvf openssl-0.9.8e.tar.gz
cd openssl-0.9.8e
./config --prefix=/usr/local/openssl
make
make install
修改(此步骤非常重要,至少对于现有的软件版本)
vi /etc/ld.so.conf 添加一行/usr/local/openssl/lib/
/sbin/ldconfig
2. 安装zlib (安装libpng和gd前需要先安装zlib)
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/local/zlib && make && make install
3.安装libpng
tar zxvf libpng-1.2.12.tar.gz
cd libpng-1.2.12
./configure --prefix=/usr/local/libpng2 && make;make install
4. 安装freetype
tar zxvf freetype-2.2.1.tar.gz
cd freetype-2.1.10
./configure --prefix=/usr/local/freetype2 &&make && make install
5. 安装jpeg
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/include
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/man/
mkdir /usr/local/jpeg6/man/man1/
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --prefix=/usr/local/jpeg6 --enable-shared --enable-static && make && make test && make install
vi /etc/ld.so.conf 加入一行:
/usr/local/jpeg6/lib
/sbin/ldconf
6. 解压fontconfig源代码
cd fontconfig-2.3.2
./configure --prefix=/usr/local/fontconfig --disable-docs --sysconfdir=/etc --mandir=/usr/share/man && make && make install
7. 安装gd
tar zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
CPPFLAGS="-I/usr/local/freetype2/include -I/usr/local/jpeg6/include -I/usr/local/libpng2/include -I/usr/local/fontconfig/include" ./configure --prefix=/usr/local/gd2/ --with-zlib=/usr/local/zlib/ --with-png=/usr/local/libpng2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype2/ --with-fontconfig=/usr/local/fontconfig
configure的结果:
** 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: yes
Support for Xpm library: yes
Support for pthreads: yes
make && make install
8. 安装libxml2(因php5.02要求libxml2的版本是 libxml2.5.10 or greater required.)
tar zxvf libxml2-2.6.27.tar.gz
cd libxml2-2.6.27
./configure --prefix=/usr/local/libxml2 && make && make install
9. 安装libxslt
tar zxvf libxslt-1.1.20.tar.gz
cd libxslt-1.1.20
./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2 && make && make install
二、安装Mysql
groupadd mysql
useradd -g mysql -c 'mysql account' -p mysql mysql
mkdir /usr/local/mysql
cd /usr/local/
chown -R mysql.mysql mysql #然后设置权限设定mysql用户能访问/usr/local/mysql,里面存的是mysql的所有文件
tar –xzvf mysql-5.0.22.tar.gz
cd mysql-5.0.22
mysql安装_编译、安装
为了防止使用旧的配置信息或目标文件,在重新运行configure前运行这些命令:
rm config.mk
make clean
configure针对Intel CPU的优化
CFLAGS="-O6 -mpentiumpro -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O6 -mpentiumpro -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --disable-shared --with-charset=gbk --with-extra-charsets=none --with-mysqld-user=mysql --with-zlib-dir=/usr/local/zlib --with-big-tables
make
make install
安装mysql测试数据库
cd /usr/local/mysql/bin
./mysql_install_db
设置mysql全局变量
cd /opt/mysql-5.0.37/support-files/
cp my-huge.cnf /etc/my.cnf
chown -R mysql.mysql /usr/local/mysql #修改mysql安装目录的权限
可以将mysql的bin目录加入/etc/profile的PATH环境变量,或手动启动mysql serve
cd /usr/local/mysql/bin
su - mysql (因为使用了--with-mysqld-user=mysql设置,只有mysql用户可以启动mysql数据库)
./mysqld_safe &
修改mysql数据库超级用户root的缺省密码:
/usr/local/mysql/bin/mysqladmin -u root password 'mysql'
/usr/local/mysql/bin/mysqladmin -u root -p -h `hostname` password 'mysql'
删除mysql默认空用户
cd /usr/local/mysql/bin
./mysql -u root -p
use mysql;
delete from user where host='localhost.localdomain';
delete from
user where host='';
commit;
flush privileges;
quit;
关闭mysql服务器
cd /usr/local/mysql/bin
./mysqladmin -u root -p shutdown
三. 安装apache2
./configure --prefix=/usr/local/apache2 --enable-auth-anon --enable-auth-dbm --enable-cache --enable-disk-cache --enable-expires --enable-file-cache --enable-headers --enable-info --enable-logio --enable-mem-cache --enable-proxy --enable-rewrite --enable-ssl --with-ssl=/usr/local/openssl -enable-unique-id --enable-usertrack --enable-vhost-alias --enable-mods-shared=most
make
make install
按实际情况修改apache 配置文件
找到 #ServerName 在其下设置 ServerName 如下
ServerName
基中 为你网站名,也可用IP代替
找到 DocumentRoot "/usr/local/apache/htdocs"
设置你的 WEB 服务器的根目录 如
DocumentRoot "/myweb"
找到 DirectoryIndex index.html index.html.var 改为
DirectoryIndex index.html index.php index.htm
用下面命令启动WEB服务器
# /usr/local/apache2/bin/apachectl start
查看自己的站点是否正常 也可用IP
用 # /usr/local/apache2/bin/apachectl stop 可停止服务
使 SSL 工作
手工签署证书
cd /usr/local/apache2/conf
openssl genrsa -des3 -passout pass:asecretpassword -out server.key.org 1024
openssl req -new -passin pass:asecretpassword -passout pass:asecretpassword -key server.key.org -out server.csr -days 3650
Country Name (2 letter code) [AU]:CN #<--## 国家代码
State or Province Name (full name) [Some-State]:LN #<--## 省或州 Locality (eg, city) []:SY #<--## 城市
Organization Name (eg, company) [Internet Widgits Pty Ltd]:micronsky.net #<--## 组织名称
Organizational Unit Name (eg, section) []:root #<--## 部门
Common Name (eg, YOUR name) []:keelort #<--## 名字
Email Address []:keelort@gmail.com #<--## 电子邮 r b>Pleaens;enter the following ''''extra'''' attributes
to be sent with your certificate request
A challenge password []: #<--## 直接回车就可以
An optional company name []: #<--## 直接回车就可以
openssl req -x509 -passin pass:asecretpassword -passout pass:asecretpassword -key server.key.org -in server.csr -out server.crt -days 3650
openssl rsa -passin pass:asecretpassword -in server.key.org -out server.key
vi /usr/local/apache2/conf/httpd.conf
将Include conf/extra/httpd-ssl.conf前面的“#”去掉
重启Apache
/usr/local/apachectl restart
然后访问: 是否可以访问
四. 安装php5
# tar zxvf php-5.1.6.tar.gz
# cd php-5.1.6
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-apxs2=/usr/local/apache2/bin/apxs --with-openssl-dir=/usr/local/openssl --with-expat-dir=/usr/lib --enable-xslt --with-gd=/usr/local/gd2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-zlib-dir=/usr/local/zlib/ --with-png-dir=/usr/local/libpng2/ --with-freetype-dir=/usr/local/freetype2/ --with-mime-magic --with-png --with-xml --with-iconv --enable-gd-native-ttf --enable-ftp --enable-embed --enable-fastcgi --enable-calendar --enable-magic-quotes --enable-track-vars --enable-sockets --enable-soap --enable-pcntl --enable-mbstring=all --enable-mbregex --with-libxml-dir=/usr/local/libxml2 --with-xsl=/usr/local/libxslt/
配置 php.ini
cp php.ini-dist /usr/local/lib/php.ini
配置 httpd.conf 让apache支持PHP
# vi /usr/local/apache2/conf/httpd.conf
添加下面的内容: