Fedora 9.0 Apache+PHP+MYSQL 环境安装
<p>因为F9自带的编译器版本过高(4.3),有的软件编译可能会报错。<br />yum -y install compat-libstdc++-33 compat-libstdc++-296<br />
yum -y install compat-gcc-34 compat-gcc-34-c++<br />
通过下面命令使用3.4版的gcc<br />
export CC=gcc34<br />
<br />
1. <a target="_blank" href="#" class="UBBWordLink">安装</a>Apache<br />
从apache官网下载httpd-2.2.9.tar.gz 并解压。<br />
进入解压目录然后<br />
<a target="_blank" href="#" class="UBBWordLink">安装</a>apr<br />
#cd srclib/apr<br />
#./configure --prefix=/usr/local/apr<br />
#make<br />
#make install<br />
<br />
再<a target="_blank" href="#" class="UBBWordLink">安装</a>apr-util<br />
#cd srclib/apr-util<br />
#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr <br />
#make<br />
#make install<br />
<br />
做完这些准备工作后,开始apache的<a target="_blank" href="#" class="UBBWordLink">安装</a><br />
./configure --prefix=/usr/local/server/apache2.2 --enable-so --enable-mods-shared=all --enable-cgi --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/bin<br />
<br />
2. <a target="_blank" href="#" class="UBBWordLink">安装</a>Mysql<br />
从官网下载mysql-5.0.51a-linux-i686.tar.gz并解压<br />
印象中,我下载的这个版本不需要编译<a target="_blank" href="#" class="UBBWordLink">安装</a>,解压就能用了。<br />
#tar -zvxf mysql-5.0.51a-linux-i686.tar.gz<br />
#mv mysql-5.0.51a /usr/local/mysql<br />
#cd /usr/local/mysql<br />
#groupadd mysql<br />
#useradd -g mysql mysql <br />
#chown -R mysql . // 注意后面有个点<br />
#chgrp -R mysql .<br />
#scripts/mysql_install_db --user=mysql<br />
#chown -R root .<br />
#chown -R mysql data<br />
#bin/mysqld_safe --user=mysql & // 启动<br />
注意官方的这个说明<br />
// 让mysql以后可以随<a target="_blank" href="#" class="UBBWordLink">系统</a>一起启动<br />
To start mysqld at boot time you have to copy<br />
support-files/mysql.server to the right place for your system,usually etc/init.d/<br />
// 运行这个脚本,会有个mysql的配置向导<br />
Alternatively you can run:<br />
./bin/mysql_secure_installation for product use!<br />
<br />
有时候我们想在windows下通过一些mysql前台工具,比如官方的Query Browser, 需要关闭Fedora 9的防火墙,并且在自带的mysql库的user表中添加一些可访问的IP,如果是%,则不限IP访问。<br />
关闭Fedora 防火墙命令:<br />
重启后生效<br />
开启: chkconfig iptables on<br />
关闭: chkconfig iptables off<br />
<br />
<a target="_blank" href="#" class="UBBWordLink">安装</a>中可能遇到的问题:<br />
<br />
如果提示zlib未找到<br />
yum -y install zlib-devel.x86_64<br />
<br />
如果无法找到-lmysqlclient 则<br />
yum install mysql-devel<br />
<br />
<br />
<br />
3. <a target="_blank" href="#" class="UBBWordLink">安装</a>PHP<br />
从PHP官网下载php-5.2.6.tar.gz并解压<br />
<br />
可能需要先<a target="_blank" href="#" class="UBBWordLink">安装</a>libxml<br />
#tar -zxvf libxml2-2.6.26.tar.gz<br />
#./configure --prefix=/usr/local/libxml<br />
#make<br />
#make install<br />
进入php的解压目录<br />
./configure --prefix=/usr/local/apache2.2/php5 --with-apxs2=/usr/local/apache2.2/bin/apxs --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/lcoal/mysql --with-zlib-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-gd --with-libxml-dir=/usr/local/libxml --with-openssl --enable-track-vars<br />
这样编译出来的PHP可以支持大多数PHP的应用, 比如压缩,GD库等等。<br />
如果是64位<a target="_blank" href="#" class="UBBWordLink">系统</a>会出现找不到libpng.so和libjpeg.so, find / -name libpng.so 你会发现在usr/lib64下这两个文件是有的,此时即便你--with-png-dir=/usr/lib64都不行,<a target="_blank" href="#" class="UBBWordLink">解决</a>这个BUG的一个可行的<a target="_blank" href="#" class="UBBWordLink">方法</a>就是把这两个文件拷贝到/usr/lib下,然后--with-png-dir=/usr/lib --with-jpeg-dir=/usr/lib<br />
如果<a target="_blank" href="#" class="UBBWordLink">系统</a>没有这两个文件的,通过yum安装libpng和libjpeg的devel包。<br />
<br />
PHP安装成功后,将<a target="_blank" href="#" class="UBBWordLink">安装</a>目录下的php.ini-dist文件改为php.ini存放的/usr/local/lib下.这个就是PHP的配置文件了!<br />
<br />
4. <a target="_blank" href="#" class="UBBWordLink">安装</a>后,还应做适当的配置<br />
编辑Apache配置文件, 并添加以下一行:<br />
AddType application/x-httpd-php .php<br />
AddType application/x-httpd-php-source .phps<br />
并在DirectoryIndex 一行加上 index.php<br />
配置下你的项目地址(略)<br />
保存文件重启Apache <br />
/usr/local/server/apache2.2/bin/apachectl start<br />
OK,就这样Fedora 9下LAMP环境就搭好了!</p>
頁:
[1]