首页 > 学技术 > 技术网文 > Web服务器 > 正文

[精华] Apache2.2.4+PHP5.2.1+MySQL5.0.37+openssl0.98e安装笔记(RedHat9.0)


来源 chinaunix.net 酷勤网整理

Apache2.2.3+PHP5.2.0+MySQL5.0.27+openssl0.98e安装笔记 

此实验在RedHat9.0上实现,特把过程写下来,希望能给初学者以指点;并肯请高手给予更多的改进方面的指点。并欢迎各位朋友关注本人博客:http://marion.cublog.cn

其中所需软件包均可以从网上下载得到,就不再指出路径。
 
1.安装mysql-5.0.37
 
#tar zxvf mysql-5.0.37-linux-i686-glibc23.tar.gz
#mv mysql-5.0.37-linux-i686-glibc23  /usr/local/mysql
#groupadd mysql
#useradd -d /usr/local/mysql/data -s /sbin/nologin -g mysql mysql
#cd /usr/local/mysql
#chown -R root .
#chown -R mysql data
#chgrp -R mysql .
#./scripts/mysql_install_db --user=mysql
#./bin/mysqld_safe --user=mysql &
#cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
#chmod 700 /etc/rc.d/init.d/mysqld
#chkconfig --add mysqld

 
测试
#/usr/local/mysql/bin/mysqladmin ping
#/usr/local/mysql/bin/mysqladmin version
#/usr/local/mysql/bin/mysql

添加root密码
#/usr/local/mysql/bin/mysqladmin -uroot -p
 
2.安装zlib-1.2.3
 
#tar zxvf zlib-1.2.3.tar.gz
#cd zlib-1.2.3
#./configure --prefix=/usr/local/zlib
#make
#make install
 
3.安装openssl-0.9.8e

#tar zxvf openssl-0.9.8e.tar.gz
#cd openssl-0.9.8e
#./config shared zlib
#make 
#make test
#make install
mv /usr/bin/openssl /usr/bin/openssl.OFF
mv /usr/include/openssl /usr/include/openssl.OFF
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl

配置库文件搜索路径

#echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
#ldconfig -v

 
4.安装httpd-2.2.4

#tar zxvf httpd-2.2.4.tar.gz
#cd httpd-2.2.4
#./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --with-ssl=/usr/local/ssl --enable-track-vars --enable-rewrite --with-z-dir=/usr/local/zlib --enable-mods-shared=most 
#make 
#make install
 
#echo "/usr/local/apache/bin/apachectl start" >> /etc/rc.local(系统启动时服务自动启动)
 
5.安装libpng-1.2.14 

#tar zxvf libpng-1.2.14.tar.gz   
# cd libpng-1.2.14 
# cp scripts/makefile.linux makefile 
# make (若是提示找不到zlib库文件或者头文件,多半是makefile文件里zlib的默认路径有误。可编辑makefile文件,找到zlib项并重新指定路径到/usr/local/zlib/lib和/usr/local/zlib/include)。
# make install
 
6.安装freetype-2.1.10 

# tar -zvxf freetype-2.1.10.tar.gz 
# cd freetype-2.1.10
# mkdir -p /usr/local/freetype 
# ./configure --prefix=/usr/local/freetype 
# make;make install  
 
7.安装jpegsrc.v6b

jpeg默认不会自建目录,因此需手动建立目录: 
# mkdir -pv /usr/local/jpeg6/{,bin,lib,include,man/man1,man1}

安装
#tar zxvf jpegsrc.v6b.tar.gz    
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static 
# make
# make install  
# make install-lib
 
8.安装libxml2-2.6.19

# tar -zxf libxml2-2.6.19.tar.gz
# cd libxml2-2.6.19
# mkdir -p /usr/local/libxml2
# ./configure --prefix=/usr/local/libxml2
# make; make install
#cp xml2-config /usr/bin
 
9.安装GD-2.0.33库 

# tar -zvxf gd-2.0.33.tar.gz 
# mkdir -p /usr/local/gd2 
# cd gd-2.0.33 
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6/ 
--with-png=/usr/local/lib/ 
--with-zlib=/usr/local/zlib/ 
--with-freetype=/usr/local/freetype/ 
# make; make install 
 
10.安装php-5.2.1

# tar -zvxf php-5.2.1.tar.gz
# mkdir -p /usr/local/php
# cd php-5.2.1
  # ./configure --prefix=/usr/local/php              (注意使用续行符)
  --with-apxs2=/usr/local/apache/bin/apxs
  --with-mysql=/usr/local/mysql
  --with-mysqli=/usr/local/mysql/bin/mysql_config
  --with-xml=/usr/local/libxml2
  --with-png=/usr/local/lib 
  --with-jpeg-dir=/usr/local/jpeg6 
  --with-zlib=/usr/local/zlib 
  --with-freetype=/usr/local/freetype 
  --with-gd=/usr/local/gd2  
  --enable-track-vars  
  --enable-mbstring=all 
# make
# make install
# cp php.ini-dist /usr/local/php/lib/php.ini 
 
11.编辑apache配置文件httpd.conf
  
  # vi /etc/httpd/httpd.conf
  要改的有如下几处:
  找到LoadModule php5_module modules/libphp5.so
  前面的#号去掉(默认已去掉注释)
  #AddType application/x-gzip .gz .tgz
  下加二行
  AddType application/x-httpd-php .php
  AddType application/x-httpd-php-source .phps
  还有找到DirectoryIndex index.html 
  加上 index.php 让它把index.php做为默认页
 
12.测试PHP
  
# vi /usr/local/apache/htdocs/index.php(其中/usr/local/apache/htdocs为网页主目录)
  添加:
   <?
    phpinfo();
   ?>
  
重新启动apache服务器
# /usr/local/apache/bin/apachectl restart
浏览器里http://localhost测试一下
 
13.安装ZendOptimizer-3.2.6-linux-glibc21-i386
 
#tar zxvf ZendOptimizer-3.2.6-linux-glibc21-i386.tar.gz
#cd ZendOptimizer-3.2.6
#./install.sh
接下去按提示输入php.ini文件的位置等即可
 
14.启用ssl
 
(1)下载ssl.ca-0.1.tar.gz(适合新手使用)到/etc/httpd(Apache2.2.4安装时指定的配置文件目录)
#tar zxvf ssl.ca-0.1.tar.gz
#cd ssl.ca-0.1
 
生成根证书
#./new-root-ca.sh
No Root CA key round. Generating one
Generating RSA private key, 1024 bit long modulus
...............................++++++
.......++++++
e is 65537 (0x10001)
Enter pass phrase for ca.key:   (此处要输入一个密码,至少四位)
Verifying - Enter pass phrase for ca.key: (重复以上密码)
Self-sign the root CA...
Enter pass phrase for ca.key:   (刚刚输过的密码)
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [MY]:CN
State or Province Name (full name) [Perak]:HeNan
Locality Name (eg, city) [Sitiawan]:Zhengzhou
Organization Name (eg, company) [My Directory Sdn Bhd]:Benet Ltd
Organizational Unit Name (eg, section) [Certification Services Division]:Marion
Common Name (eg, MD Root CA) []:Benet CA
Email Address []:knightma@yeah.net
如此可以生成ca.key和ca.crt两个文件;其中的省份、公司等内容可以按照你自己的相法来设定。
 
接下来要为服务器生成一个证书:
# ./new-server-cert.sh server (这个证书的名字是server)
No server.key round. Generating one
Generating RSA private key, 1024 bit long modulus
....++++++
.............++++++
e is 65537 (0x10001)
Fill in certificate data
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [MY]:CN
State or Province Name (full name) [Perak]:HeNan
Locality Name (eg, city) [Sitiawan]:Zhengzhou
Organization Name (eg, company) [My Directory Sdn Bhd]:Benet Ltd
Organizational Unit Name (eg, section) [Secure Web Server]:Marion
Common Name (eg, www.domain.com) []:localhost
Email Address []:knightma@yeah.net
You may now run ./sign-server-cert.sh to get it signed
执行结束后生成了server.csr和server.key这两个文件。但它们还需要签署一下才能使用。
 
# ./sign-server-cert.sh server
CA signing: server.csr -> server.crt:
Using configuration from ca.config
Enter pass phrase for ./ca.key:
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName           :PRINTABLE:'CN'
stateOrProvinceName   :PRINTABLE:'HeNan'
localityName          :PRINTABLE:'Zhengzhou'
organizationName      :PRINTABLE:'Benet Ltd'
organizationalUnitName:PRINTABLE:'Marion'
commonName            :PRINTABLE:'localhost'
emailAddress          :IA5STRING:'[email]knightma@yeah.net[/email]'
Certificate is to be certified until Nov 21 11:58:38 2007 GMT (365 days)
Sign the certificate? [y/n]:y

1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
CA verifying: server.crt <-> CA cert
server.crt: OK
 
(2)接下来要按照/etc/httpd/extra/httpd-ssl.conf里面的设置,将证书放在适当的位置。
#cp ./server.key /etc/httpd
#cp ./server.crt /etc/httpd
#cd ..
#chmod 400 server.key
 
(3)编辑/etc/httpd/httpd.conf
找到如下一句,将前面的注释#去掉
#Include /etc/httpd/extra/httpd-ssl.conf
而后重启apache即可
#killall -9 httpd
#/usr/local/apache/bin/apachectl start
 
(4)查看监听端口,确认里面有:443端口
#netstat -tnl
 
(5)https://localhost

[ 本帖最后由 marion 于 2007-6-1 16:30 编辑 ]



 marion 回复于:2006-11-30 01:49:29

不知道我写的够不够详细,欢迎各位进行探讨!


 无心细语 回复于:2006-12-07 10:34:31

学习一下!
呵呵~!~!


 zxxz79 回复于:2006-12-07 11:30:11

详细是够详细了,可是我觉得有点不足,通常这类文章都是写给我们菜鸟们看的,所以我觉得应该加上注释,告诉读者,这个整合实现了什么功能,各模块是用来做什么的。


 foxxx222 回复于:2006-12-07 16:20:05

学习中,,,


 m2eric 回复于:2006-12-21 15:36:54

--with-gd=/usr/local/gd   
应该为
--with-gd=/usr/local/gd2
测试一下看看ssl行不行先。。哈哈


 zhangyan@tq.cn 回复于:2006-12-22 13:35:19

引用:原帖由 marion 于 2006-11-30 01:49 发表
不知道我写的够不够详细,欢迎各位进行探讨! 


:P:em03::em02::lol::P
确实好,了解一些常用的知识


 wigeboy 回复于:2006-12-23 04:56:11

RedHat9.0 为何还要用这个版本?


 qiubowinter 回复于:2006-12-24 16:53:36

make 很正常的编译过去了!
但是到 make test就出现错误了!
为什么我的openssl总是编译出错!
错误信息是make (1) ****与(乱码...)与(乱码...)同文件
error   1

[ 本帖最后由 qiubowinter 于 2006-12-24 17:08 编辑 ]


 famo 回复于:2006-12-29 17:32:48

very good


 wind1211 回复于:2007-01-04 14:09:19

好帖 顶一下 
:em02:


 xuexh 回复于:2007-01-11 06:17:24

./apachectl start 后

Syntax error on line 56 of /usr/local/httpd/conf/extra/httpd-ssl.conf:
Invalid command 'SSLPassPhraseDialog', perhaps misspelled or defined by a module not included in the server configuration


 kukat 回复于:2007-01-11 14:04:21

ZendOptimizer3.01确实和php5.20不兼容 
可以用ZendOptimizer3.20


 ly_cyz 回复于:2007-01-11 22:50:12

高手!支持一下!
回头试一试!


 chenjie34 回复于:2007-01-18 10:56:19

详细是够详细了,可是我觉得有点不足,通常这类文章都是写给我们菜鸟们看的,所以我觉得应该加上注释,告诉读者,这个整合实现了什么功能,各模块是用来做什么的。


 mcumsigscr 回复于:2007-01-18 15:28:23

顶一下.不错的帖子.


 kexen 回复于:2007-01-21 01:00:22

花费了一周的时间,总算完整的的把这个东东架设完毕了。当PHPINFO终于出现在我的面前的时候,真的好激动。第一次完整的架设成功,让我学习起来觉得非常有成就感。hoho 谢谢你了LZ。


 fnet 回复于:2007-02-07 11:14:44

谢谢提供,顶完再看


 marion 回复于:2007-02-28 11:01:29

呵呵,这么多朋友来捧场了,大家共同学习!
CU是个好地方,感觉自己从中获益良多,学习之余就把自己的学习笔记拿出来共享了。欢迎各位多多交流!


 marion 回复于:2007-02-28 11:03:41

15楼的chenjie34朋友的建议不错,我回头整理一下自己对这个安装的理解贴上来!


 marion 回复于:2007-03-05 13:59:49

错误记录中说明的是语法错误,并进一步指出错误是"SSLPassPhraseDialog"指令不正确。
同时,并推测说或许是由于拼写错误,亦或是没有在主配置文件中把某一个文件包含进来所致。

造成这问题的原因可能是在编译时指定SSL的路径错误造成的,请再检查一下编译APACHE时所指向的SSL所在路径。


 tyc00n 回复于:2007-03-07 20:35:02

很好。。。加油


 marion 回复于:2007-03-20 12:19:24

呵呵,谢谢TYC00N的肯定。


 leewei544 回复于:2007-03-20 14:08:42

各位大哥....小第刚接触LINUX...现在在弄APACHE..但是老是MAKE不过去..有错误..有没有比较详细的APACHE的文章啊


 marion 回复于:2007-03-20 22:53:42

把你的错误贴上来,我们帮你分析一下。


 anen 回复于:2007-03-22 11:47:56

10.安装php-5.2.0

# tar -zvxf php-5.2.0.tar.gz
# mkdir -p /usr/local/php
# cd php-5.2.0
  # ./configure --prefix=/usr/local/php              (注意使用续行符)
  --with-apxs2=/usr/local/apache/bin/apxs
  --with-mysql-dir=/usr/local/mysql


应改为:
 
  --with-mysql=/usr/local/mysql


 leewei544 回复于:2007-03-22 12:00:42

我按照你给的步骤..安装httpd-2.2.3...当做到make的时候..出现了make: ***No targets specified and no makefile found.  Stop.
是什么原因呢..
我在./configure后最后几句出现了:checking for gcc... gcc
checking for Ccompiler default output file name... configure: error: C compiler cannot create executables
See 'config.log' for more details.
configure failed for srclib/apr好象有错误..什么错误..望不吝赐教..谢谢啊


 marion 回复于:2007-03-22 21:48:36

./configure没有成功,apr组件存在问题。

[ 本帖最后由 marion 于 2007-5-8 09:22 编辑 ]


 marion 回复于:2007-05-08 09:20:51

做了一次更新!


 yuyii 回复于:2007-06-06 13:15:54

apache启动时报不能加载libphp5.so,说是undefined symbol:zend_ini_string
网上查了也未果,有不少老外碰到同样的问题.我这里关于GD2的包都没安装,因为不用GD2.只装了zlib和libxml2.谁有遇到相似状况的?
PS:之前还碰到个sqlite3的undefined symbol.不过搞定了已经.


 ylcqen 回复于:2007-06-21 16:27:38

不错,但我安装mysql后,找不到mysql.sock.哈哈.请问牛哥是什么原因.


 marion 回复于:2007-06-22 12:39:34

楼上的兄弟,你的问题描述过于简单(找不到的可能性有多种),能不能把错误信息贴上来?




原文链接:http://bbs.chinaunix.net/viewthread.php?tid=863257
转载请注明作者名及原文出处



收藏本页到: