|
Linux下源代码安装apache+mysql+php
/*******************************
* I am pefocus,pefocus is me !*
*******************************/
编译环境:RedHat Enterprise AS 5,开启SELlinux
所需要的软件:apache,php,phpmyadmin,mysql,GD及库相关
libpng-1.2.24.tar.bz2
zlib-1.2.3.tar.gz
freetype-2.3.5.tar.gz
libxslt-1.1.22.tar.gz
jpegsrc.v6b.tar.gz
gd-2.0.36RC1.tar.bz2
libxml2-2.6.30.tar.gz
下载地址:
http://www.apache.org
http://www.php.net
http://www.mysql.com
http://www.ijg.org/files/jpegsrc.v6b.tar.gz
http://www.zlib.net/zlib-1.2.3.tar.gz
http://prdownloads.sourceforge.n ... fig.tar.gz?download
http://easynews.dl.sourceforge.n ... etype-2.1.3.tar.bz2
http://telia.dl.sourceforge.net/ ... etype-2.1.3.tar.bz2
1.安装apache
tar -xvf httpd-2.2.0.tar.gz
cd httpd-2.2.0
./configure --prefix=/usr/local/apache2 --enable-module=so
make
make install
设置apache自启动:
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
然后vi /etc/init.d/httpd
在第3行加入
# chkconfig: 2345 70 30
# processname: httpd
注意:#号不能去掉!
最后chkconfig --add httpd
2.freetype
tar vjf freetype-2.1.3.tar.bz2
cd freetype-2.1.3
./configure
make
make install
3.jpeg
tar xvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
./configure --enable-shared --enable-static
make
mkdir -v /usr/local/man
mkdir -v /usr/local/man/man1
make install
4.zlib
tar xvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install
5.libpng
./configure
make
make test
make install
6.gd2
tar xvf gd-2.0.27.tar.gz
cd gd-2.0.27/
./configure --prefix=/usr/local/gd2
make
make install
7.mysql
groupadd mysql
useradd -g mysql mysql
cd /data/ ----这是我安装mysql的目录,可根据实际情况更改,如cd /usr/local/
tar xvf mysql-5.0.41-linux-i686-glibc23.tar.gz
cd mysql-5.0.41-linux-i686-glibc23/
chown -R mysql .
chgrp -R mysql .
./scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
./bin/mysqld_safe --user=mysql &
注意:安装完成后,为root用户设置密码 !
运行以下命令:
./bin/mysqladmin -u root password 'new-password'或者
./bin/mysqladmin -u root -h hostname password 'new-password'
设置mysql自启动:
cp support-files/mysql.server /etc/init.d/mysql
chmod +x mysql
chkconfig --add mysql
运行mysql:
/etc/init.d/mysql star|stop|restart或者
service mysql star|stop|restart
8.php
安装php的时候,系统默认缺少两个组件 FLEX,libxml2
tar xvf php-5.2.5.tar.gz
cd php-5.2.5/
./configure --with-gd=/usr/local/gd2 --with-apxs2=/usr/local/apache2/bin/apxs --with-xml --with-mysql=/data/mysql5
make
make install
...
Installing PEAR environment: /usr/local/lib/php/
/usr/local/php-5.2.5/sapi/cli/php: error while loading shared libraries: /usr/local/gd2/lib/libgd.so.2: cannot restore segment prot after reloc: Permission denied
make[1]: *** [install-pear-installer] Error 127
make: *** [install-pear] Error 2
安装出错,输入tail /var/log/messages
...
Mar 3 06:40:46 localhost setroubleshoot: SELinux is preventing /usr/local/php-5.2.5/sapi/cli/php from loading /usr/local/gd2/lib/libgd.so.2.0.0 which requires text relocation. For complete SELinux messages. run sealert -l 6e29749f-3908-480d-bcc1-9042f8a9e846
运行 sealert -l 6e29749f-3908-480d-bcc1-9042f8a9e846
...
The following command will allow this access:
chcon -t textrel_shlib_t /usr/local/gd2/lib/libgd.so.2.0.0
运行 chcon -t textrel_shlib_t /usr/local/gd2/lib/libgd.so.2.0.0
再次运行make install ,安装成功。
cp php.ini-dist /usr/local/lib/php.ini
9.配置apche
记得备份httpd.conf
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak
vi /usr/local/apache/conf/httpd.conf
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
DocumentRoot 改成你希望指定的主目录,如/data/www
IfModule dir_module 在这里加上你希望作为默认首页的文件,我加了index.htm index.php,中间打个空格就可以了
如果你想启动apache支持shtml格式,可以这样操作
找到下面这样一段文字
This should be changed to whatever you set DocumentRoot to.
把<Directory "/usr/local/apache/htdocs">改成你的主目录
如果不希望有人能看到网站目录结构,在下面加入Options FollowSymLinks Includes,注意区分大小写
完成这部以后,查找这两行,把前面的#去掉
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
重新启动apache,在www目录下建立文件phpinfo.php
<?php
phpinfo();
?>
运行http://localhost/phpinfo.php,测试。
如果apache不能正常解析php,在http.conf中查找LoadModule php5_module modules/libphp5.so
如果没有则添加。
blog:http://blog.csdn.net/pefocus
/*******************************
* I am pefocus,pefocus is me !*
*******************************/
Email:pefocus@163.com
QQ:393093104 |
|