【原创】FC3中Apache2+PHP+Mysql的搭建

【原创】FC3中Apache2+PHP+Mysql的搭建

Fedora3中Apache+Mysql+PHP安装全攻略
这是我个人在FC3中安装AMP的过程,供大家参考。
第一步:
软件的下载:
需要的软件如下:
httpd-2.0.52.tar.gz http://www.apache.org
mysql-4.0.23.tar.gz http://www.mysql.com
php-4.3.10.tar.gz http://www.php.net
当然,你可以选用版本更高的,呵呵,但是可能在安装上有点不同,你可以查看相关的手册。

第二步:
解压:
呵呵,这步是必须的啊,不解压,怎么装?
tar -zxvf httpd-XXXX.tar.gz
tar -zxvf mysql-XXXX.tar.gz
tar -zxvf php-XXXX.tar.gz

ok,前面的都是写准备工作,下面,我们就要开工罗哦,呵呵

安装Apache:
#cd httpd-XXXX
#./configure --prefix=/usr/local/apache2 --enable-mods-share=most
当然,你可以查看编译参数--help,获得更多的资料,我这里只是把一些模块编译了进去。
如果一切正常,你就可以执行下面的了,
#make
#make install
这是一个非常漫长的过程,看机器性能了,呵呵,
Apache就装到这里,我们转到MySQL的安装

安装MySQL
#cd mysql-XXXX
#./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --disable-maintainer-mode --with-mysqld-user=mysql --enable-large-files
还是那句话,--help可以知道更多的编译参数
ok,如果你运气号,就可以编译成功,当然不成功页不要气馁,多试几遍就ok了
#make
#make install
安装MySQL的时间大概是Apache的4,5倍,很长很长,足够时间去洗个澡,换件衣服,呵呵
ok,全部搞定以后,你需要对MySQL做小小的设置:
#groupadd mysql //添加mysql用户组
#useradd -g mysql mysql //添加一个mysql的用户
接着,你需要对MySQL的数据库进行安装
#./scripts/mysql_install_db
接着,授权用户以及组:
#chown -R root:mysql /usr/local/mysql
#chown -R mysql:mysql /usr/local/mysql/data
为了避免问题,可以对ld.so.conf文件进行修改(备注:其实这个可以不用的)
#vi /etc/ld.so.conf 添加下面这行
/usr/local/lib/mysql
ok,MySQL安装就到这里完成了,下面就是启动它:
#/usr/local/mysql/bin/mysqld_safe & //后台启动mysql
大家都应该很清楚,MySQL安装完成后,最重要的就是修改root密码,我也不利外:
#/usr/local/mysql/bin/mysqladmin -u root password new_password
MySQL的基本安装与配置到此为止,剩下的关于MySQL的操作就是MySQL的事了,呵呵

安装PHP
#cd php-XXXX
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql
#make
#make install
如果不出现意外,PHP安装就OK了,下面要对PHP进行少少的配置:
#cp php.ini-dist /usr/local/lib/php.ini //php.ini-dist文件在php的安装文件里面,呵呵
#vi /usr/local/lib/php.ini
找到doc_root,修改成对应的地址:/usr/local/apache2/htdocs/
为了安全,我关闭了file_uploads,默认的是开启。

ok,安装工作到此结束,下面,要对Apache的配置文件进行修改:
#vi /usr/local/apache2/conf/httpd.conf
修改如下:
LoadModule php4_module modules/libphp4.so
DirectoryIndex index.html index.php
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
保存退出,启动apache
#/usr/local/apache2/bin/apachect1 start
在htdoc里面新建一个php测试页面,
#vi /usr/local/apache2/htdocs/test.php
内容如下://其实都是千篇一律的,哈哈哈
phpinfo();
?>
现在基本上可以收工了,呵呵,因为打开你的Firefox或者Mozilla,输入地址,如果不出先意外,就可以看见php的信息页面了!

以下部分是让系统启动是自动运行MySQL和Apache的,
关于MySQL的自动运行:
#cp support-files/mysql.server /etc/init.d/mysql
然后,用chkconfig来设定,呵呵:
#chkconfig --level 35 mysql //让mysql自动在level3和level5两个级里面自动运行,当然,你可以根据实际情况而定
应该就这么简单吧,呵呵,
关于Apache的自动运行:
apache2好象不支持chkconfig来设定,我在网上找到了一个玩意儿,就能启动了,如下:
#cp apachect1 /etc/init.d/httpd
然后,
#vi /etc/init.d/httpd
在开头(即#!/bin/sh)后面加入:
#chkconfig:2345 10 90 //2345是运行的级别,后面的是优先级
#description:Run the httpd server
经过改造以后,Apache也可以使用chkconfig来进行设定了,哈哈哈哈
不过我看见网上还有一种方法是在rc3.d里面ln一个链接来设定的,有空我试试,呵呵!

ok,收工!如果你经常安装的话,可以写一个shell脚本来全自动运行,呵呵
如果那位仁兄发现哪里有不足的地方,欢迎拍砖(RTDT36@gmail.com)

RTDT
2005-01-31-Mon      
我在编译My SQL时出错,

./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --disable-maintainer-mode --with-mysqld-user=mysql --enable-large-files
时,出错如下:
checking for termcap functions library... configure: error: No curses/termcap library found
我的My SQ版本是-4.0.13

不知哪里有错.........      
我用的是RED HAT 9.0  是不是我的系统缺少库文件,      
应该是缺这个东西吧libncurses5-dev      
要先安装ncureses-devel*rpm软件包。      
我又找来MYSQL的RMP包,安装能顺利完成,可是是安装到默认的目录,且我再编译HPH时还是报错..
MYSQL如下:
mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.9-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> \s
--------------
mysql  Ver 14.7 Distrib 4.1.9, for pc-linux-gnu (i686)

Connection id:          2
Current database:
Current user:           root@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         4.1.9-standard
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 17 min 33 sec

Threads: 1  Questions: 4  Slow queries: 0  Opens: 11  Flush tables: 1  Open tables: 0  Queries per second avg: 0.004
--------------

mysql>
编译PHP时出错如下:
[root@localhost php-5.0.0b1]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysqs
loading cache ./config.cache
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking whether gcc and cc understand -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking for AIX... no
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking for ranlib... ranlib
checking whether ln -s works... yes
checking for gawk... gawk
checking for bison... no
checking for byacc... no
configure: warning: You will need bison if you want to regenerate the PHP parsers.
checking for flex... lex
checking for yywrap in -ll... no
checking lex output file root... ./configure: line 2376: lex: command not found
configure: error: cannot find output from lex; giving up
[root@localhost php-5.0.0b1]#
安装按照上面楼主的的提示进行,(除MYSQL是RMP安装外)
我大概知道是输出的路径有问题,可又找不到再哪里,
望版主能帮看看 ...................      
RED HAT系列如果出现No curses/termcap library found提示,
你需要安装:
termcap-11.0.1-16.noarch.rpm
libtermcap-devel-2.0.8-35.i386.rpm
ncurses-5.3-4.i386.rpm
这些文件从安装光盘上都可以找的到,搜索一下就可以.      
service httpd start

unrecognized service      
creating os/unix/Makefile
creating server/mpm/Makefile
creating server/mpm/prefork/Makefile
creating modules/http/Makefile
creating modules/dav/main/Makefile
creating modules/generators/Makefile
creating modules/dav/fs/Makefile
creating modules/mappers/Makefile
creating Makefile
creating modules/Makefile
creating srclib/Makefile
creating os/beos/Makefile
creating os/os2/Makefile
creating os/Makefile
creating os/unix/Makefile
creating server/Makefile
creating support/Makefile
creating srclib/pcre/Makefile
creating test/Makefile
config.status: creating docs/conf/httpd-std.conf
config.status: creating docs/conf/ssl-std.conf
config.status: creating include/ap_config_layout.h
config.status: creating support/apxs
config.status: creating support/apachectl
config.status: creating support/dbmmanage
config.status: creating support/envvars-std
config.status: creating support/log_server_status
config.status: creating support/logresolve.pl
config.status: creating support/phf_abuse_log.cgi
config.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating include/ap_config_auto.h
config.status: include/ap_config_auto.h is unchanged
config.status: executing default commands



这些是安装apache2.0.55 ./configure 后最后的结果,请问这个有为题吗?
我就觉得没问题,但为什么我执行 make后会出问题呢?


make[1]: Entering directory `/root/httpd-2.0.55/support'
make[2]: Entering directory `/root/httpd-2.0.55/support'
make[2]: Nothing to be done for `local-all'.
make[2]: Leaving directory `/root/httpd-2.0.55/support'
make[1]: Leaving directory `/root/httpd-2.0.55/support'
make[1]: Entering directory `/root/httpd-2.0.55'
/root/httpd-2.0.55/srclib/apr/libtool --silent --mode=compile gcc  -g -O2 -pthread    -DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -DAP_HAVE_DESIGNATED_INITIALIZER   -I/root/httpd-2.0.55/srclib/apr/include -I/root/httpd-2.0.55/srclib/apr-util/include -I. -I/root/httpd-2.0.55/os/unix -I/root/httpd-2.0.55/server/mpm/prefork -I/root/httpd-2.0.55/modules/http -I/root/httpd-2.0.55/modules/filters -I/root/httpd-2.0.55/modules/proxy -I/root/httpd-2.0.55/include -I/root/httpd-2.0.55/modules/generators -I/root/httpd-2.0.55/modules/dav/main -prefer-non-pic -static -c modules.c && touch modules.lo
/root/httpd-2.0.55/srclib/apr/libtool --silent --mode=link gcc  -g -O2 -pthread    -DLINUX=2 -D_REENTRANT -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE -DAP_HAVE_DESIGNATED_INITIALIZER   -I/root/httpd-2.0.55/srclib/apr/include -I/root/httpd-2.0.55/srclib/apr-util/include -I. -I/root/httpd-2.0.55/os/unix -I/root/httpd-2.0.55/server/mpm/prefork -I/root/httpd-2.0.55/modules/http -I/root/httpd-2.0.55/modules/filters -I/root/httpd-2.0.55/modules/proxy -I/root/httpd-2.0.55/include -I/root/httpd-2.0.55/modules/generators -I/root/httpd-2.0.55/modules/dav/main -export-dynamic    -o httpd  modules.lo  modules/aaa/mod_access.la modules/aaa/mod_auth.la modules/filters/mod_include.la modules/loggers/mod_log_config.la modules/metadata/mod_env.la modules/metadata/mod_setenvif.la modules/http/mod_http.la modules/http/mod_mime.la modules/generators/mod_status.la modules/generators/mod_autoindex.la modules/generators/mod_asis.la modules/generators/mod_cgi.la modules/mappers/mod_negotiation.la modules/mappers/mod_dir.la modules/mappers/mod_imap.la modules/mappers/mod_actions.la modules/mappers/mod_userdir.la modules/mappers/mod_alias.la modules/mappers/mod_so.la server/mpm/prefork/libprefork.la server/libmain.la os/unix/libos.la  /root/httpd-2.0.55/srclib/pcre/libpcre.la /root/httpd-2.0.55/srclib/apr-util/libaprutil-0.la -lgdbm -ldb-4.0 -lexpat /root/httpd-2.0.55/srclib/apr/libapr-0.la -lrt -lm -lcrypt -lnsl -lpthread -ldl
make[1]: Leaving directory `/root/httpd-2.0.55'

我继续运行make install

到最后出现:
Making install in support
make[1]: Entering directory `/root/httpd-2.0.55/support'
make[2]: Entering directory `/root/httpd-2.0.55/support'
make[2]: Leaving directory `/root/httpd-2.0.55/support'
make[1]: Leaving directory `/root/httpd-2.0.55/support'
make[1]: Entering directory `/root/httpd-2.0.55'
Installing configuration files
mkdir /usr/local/apache2/conf
Installing HTML documents
mkdir /usr/local/apache2/htdocs
Installing error documents
mkdir /usr/local/apache2/error
Installing icons
mkdir /usr/local/apache2/icons
mkdir /usr/local/apache2/logs
Installing CGIs
mkdir /usr/local/apache2/cgi-bin
Installing header files
Installing man pages and online manual
mkdir /usr/local/apache2/man
mkdir /usr/local/apache2/man/man1
mkdir /usr/local/apache2/man/man8
mkdir /usr/local/apache2/manual
Installing build system files
make[1]: Leaving directory `/root/httpd-2.0.55'      
对了,我用的是redhat 9.0