Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

linux下的apache2 + mysql5 + php4 + gd2 源码完整安装详解

[复制链接]
65971224 发表于 2007-7-12 18:16:11 | 显示全部楼层 |阅读模式
文章来源: http://www.phpbulo.com

1.安装mysql

shell> groupadd -g 500 mysql
shell> useradd -u500 -gmysql -M mysql
shell> tar -xzf mysql.**.tar.gz
shell> cd mysql.**
shell> ./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
shell> make
shell> make install
shell> cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql //开机启动mysql
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> bin/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql var
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &

注意直接执行后会出现下面错误:
Starting mysqld daemon with databases from /usr/local/mysql/data STOPPING server from pid file /usr/local/mysql/data/localhost.localdomain.pid 070514 19:15:13 mysqld ended
需执行 shell> chown -R mysql.mysql data

修改root密码:
use mysql
update user set Password=password("123456") where User="root";
delete from user where User="";

2.apache安装
shell> tar -xzf httpd-2.2.4.tar.gz
shell> cd httpd-2.2.4
shell> ./configure --prefix=/usr/local/apache2 --enable-rewrite=shared --enable-speling=shared --enable-module=so
shell> make
shell> make install

3.iconv安装
shell> ./configure --prefix=/usr/local/iconv
shell> make
shell> make install

4.gd部分安装
zlib包
shell> ./configure --prefix=/usr/local/zlib
shell> make check
shell> make install

libpng包(支持PNG)
shell> ./configure --prefix=/usr/local/libpng
shell> make
shell> make install

jpeg-6b包(支持jpg格式)
shell> ./configure --prefix=/usr/local/jpeg-6b --enable-share --enable-static
shell> make test
shell> make
shell> make install
shell> make install-lib

freetype包(字体支持)
shell> ./configure --prefix=/usr/local/freetype
shell> make
shell> make install

最后安装gd包
shell> ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg-6b --with-zlib-dir=/usr/local/zlib --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype
shell> make
shell> make install

make时会出现
make[2]: *** [gd_png.lo] Error 1
make[2]: Leaving directory `/tmp/gd-2.0.26gif'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/gd-2.0.26gif'
make: *** [all] Error 2
需要复制/usr/local/libpng/include/目录下的cp /usr/local/libpng/include/pngconf.h /home/jong/tmp/gd-2.0.34
cp /usr/local/libpng/include/png.h /home/jong/tmp/gd-2.0.34

5.安装php

shell> ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-gd=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg-6b --with-zlib-dir=/usr/local/zlib --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype --enable-trace-vars -with-mysql=/usr/local/mysql -with-iconv=/usr/local/iconv --enable-mbstring=all --with-curl --enable-track-vars --with-DBA --enable-mbstr-enc-trans --enable-mbregex --with-config-file-path=/usr/local/php --with-xml --with-gettext
shell> make
shell> make install
shell> cp php.ini-dist /usr/local/php/php.ini

编辑apache配置档
shell> cd /usr/local/apache2/conf
shell> vi httpd.conf
在LoadModule php4_module modules/libphp4.so
添加AddType application/x-httpd-php .php

OK,基本的安装已经完成,如果重新起动APACHE出现:/usr/local/apache2/bin/apachectl start Syntax error on line 232 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp4.so into server: /usr/local/apache2/modules/libphp4.so: cannot restore segment prot after reloc: Permission denied
那就要按照下面的方法解决:

编辑/etc/selinux/config,找到这段:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing

把 SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为:
SELINUX=disabled
保存,关闭。

编辑/etc/sysconfig/selinux,找到:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing

如果SELINUX已经是 SELINUX=disabled,那么就不用改了,否则就把SELINUX=enforcing 注释掉,新加一行:
SELINUX=disabled
保存,退出。

如果你碰到其他类似提示:
cannot restore segment prot after reloc: Permission denied
哪应该是SELinux的问题,可以考虑把它关闭。

相关网站:
apache http://www.apache.org
php http://www.php.net
mysql http://www.mysql.org
gd http://www.libgd.org/
png http://www.libpng.org/
zlib http://www.zlib.net/
jpeg ftp://ftp.uu.net/graphics/jpeg/
freetype http://www.freetype.org/ http://savannah.nongnu.org/projects/freetype
dongshanmu 发表于 2007-12-7 22:52:05 | 显示全部楼层

linux+apache+php+mysql 源码安装

天下文章一大抄,看你会不会抄,偶也来发表一篇文章

一:准备软件包,存放/home/xiutuo/software/目录下。

主要软件包,
1. httpd-2.2.6.tar.gz
2. mysql-5.0.45-linux-i686-glibc23.tar.gz  (这个版本是已编译好的压缩包,解压后稍做配置即可使用)
3. php-5.2.5.tar.gz

安装php所需的软件包(其中libxml2是安装php5必须的.)
1. libxml2-(version).tar.gz  --->  http://ftp.gnome.org/pub/GNOME/sources/libxm2
2. libxslt-(version).tar.gz  --->  http://ftp.gnome.org/pub/GNOME/sources/libxslt
3. curl-(version).tar.gz     --->  http://curl.haxx.se/download

GD库所需要软件包(有人说PHP源码包里自带了GD2.0.28和zlib,只要安装GD的三个支持包:jpg,png和freetype,但是我们还是下载)
1. gd-(version).tar.gz       --->  http://www.libgd.org/Main_Page  or  http://www.libgd.org/releases/
2. freetype-(version).tar.gz --->  http://sourceforge.net/projects/freetype
3. jpegsrc.v6b.tar.gz        --->  http://ijg.org/files/jpegsrc.v6b.tar.gz
4. libpng-(version).tar.gz   --->  http://www.libpng.org/pub/png/libpng.html
5. zlib-1.2.3.tar.gz         --->  http://www.zlib.net

把以上所有软件包下载到:/root/Software/目录下.

二:安装mysql

# tar -zvxf mysql-5.0.45-linux-i686-glibc23.tar.gz  
# mkdir -p /usr/local/mysql
# cp -r mysql-5.0.45 /usr/local/mysql
# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysql //开机启动mysql
# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

添加mysql用户及用户组
# groupadd mysql
# useradd -g mysql mysql
修改mysql目录权限
# chown -R root /usr/local/mysql
# chgrp -R mysql /usr/local/mysql
# chown -R mysql /usr/local/mysql/data
生成mysql系统数据库
# /usr/local/mysql/scripts/mysql_install_db --user=mysql&  //启动mysql服务
# /usr/local/mysql/bin/mysqld_safe --user=mysql&
如出现 Starting mysqld daemon with databases from /usr/local/mysql/data 代表正常启动mysql服务了.
按Ctrl + C 跳出修改 mysql 的 root 密码
# /usr/local/mysql/bin/mysqladmin -u root -p password "123456"

三:安装GD库(让PHP支持GIF,PNG,JPEG)
a.安装 jpeg6 建立目录:
# mkdir -p /usr/local/jpeg6
# mkdir -p /usr/local/jpeg6/bin
# mkdir -p /usr/local/jpeg6/lib
# mkdir -p /usr/local/jpeg6/include
# mkdir -p /usr/local/jpeg6/man
# mkdir -p /usr/local/jpeg6/man1
# mkdir -p /usr/local/jpeg6/man/man1
# cd /root/Software/
# tar -zvxf jpegsrc.v6b.tar.gz
# cd jpeg6
# ./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
# make
# make install

b.libpng包(支持PNG)
# cd /root/Software/
# tar -zvxf libpng-(version).tar.gz
# cd libpng-(version)
# ./configure --prefix=/usr/local/libpng
# make
#> make install

c.安装 freetype
# cd /root/Software/
# tar -zvxf freetype-(version).tar.gz
# cd freetype-(version)
# mkdir -p /usr/local/freetype
# ./configure --prefix=/usr/local/freetype
# make
# make install

d.安装zlib
# cd /root/Software/
# tar -zxvf zlib-1.2.3.tar.gz
# cd zlib.1.2.3
# mkdir /usr/local/zlib
# ./configure --prefix=/usr/local/zlib
# make
# make install

e.安装GD库
# cd /root/Software/
# tar -zvxf gd-(version).tar.gz
# mkdir -p /usr/local/gd2
# cd gd-(version)
# ./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg6 --with-zlib-dir=/usr/local/zlib --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype
# make
# make install

e.安装Curl库
# cd /root/Software/
# tar -zxf curl-(version).tar.gz
# mkdir -p /usr/local/curl
# ./configure --prefix=/usr/local/curl
# make
# make install

四:安装apache2
# cd /roo/Software/
# tar -zvxf httpd-2.2.6.tar.gz
# cd httpd-2.2.6
# mkdir -p /usr/local/apache2
# ./configure --prefix=/usr/local/apache --enable-modules=so --enable-rewrite
# make
# make install  
# /usr/local/apache2/bin/apachectl -k start //启动apahce
用浏览器查看http://localhost,得到it works,说明apache已经配置成功了.
# /usr/local/apache2/bin/apachectl -k stop  //停止apache

五:安装php5,php5必须有libxml2支持!
a. 安装libxml2
# cd /root/Software/
# tar -zvxf libxml2-(version).tar.gz
# cd libxml2-(version)
# mkdir -p /usr/local/libxml2
# ./configure --prefix=/usr/local/libxml2
# make
# make install

b.安装 libxslt (可选安装,你可以不安装)
# cd /root/Software/
# tar -zvxf libxslt-(version).tar.gz
# mkdir -p /usr/local/libxslt
# cd libxslt-(version)
# ./configure --prefix=/usr/local/libxslt --with-libxml-prefix=/usr/local/libxml2
# make
# make install

c.安装php5
# cd /root/Software/
# tar -zvxf php-(version).tar.gz
# mkdir -p /usr/local/php5
# cd php-(version)
# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs \
>--with-gd=/usr/local/gd2 --with-jpeg-dir=/usr/local/jpeg6 \
>--with-zlib-dir=/usr/local/zlib \
>--with-png-dir=/usr/local/libpng \
>--with-freetype-dir=/usr/local/freetype -\
>--enable-trace-vars --with-mysql=/usr/local/mysql \
>--enable-mbstring=all --with-curl=/usr/local/curl --enable-mbregex \
>--with-config-file-path=/usr/local/php5 --enable-ftp \
>--enable-soap --with-xsl=/usr/local/libxslt

# make
# make install
# cp php.ini-dist /usr/local/php5/php.ini  (别忘记了呵呵)

六:重新配置apache2让他支持php

# cd /usr/local/apache2/conf
# vim httpd.conf
在LoadModule php5_module modules/libphp5.so
添加AddType application/x-httpd-php  .php

OK,基本的安装已经完成.
重新起动APACHE:
# /usr/local/apache2/bin/apachectl start
如果重新起动APACHE出现:
Syntax error on line 232 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server:
/usr/local/apache2/modules/libphp4.so: cannot restore segment prot after reloc: Permission denied
那就要按照下面的方法解决:

1.chcon  -t  texrel_shlib_t  /usr/local/apache2/modules/*.so

2.编辑/etc/selinux/config,找到这段:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing

把 SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为:
SELINUX=disabled
保存,关闭。

编辑/etc/sysconfig/selinux,找到:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing

如果SELINUX已经是 SELINUX=disabled,那么就不用改了,否则就把SELINUX=enforcing 注释掉,新加一行:
SELINUX=disabled
保存,退出。

ok,web环境apache2+mysql5+php5就介绍到这里。更详细的apache2的配置和mysql配置和php.ini的配置参考相应文档
回复

使用道具 举报

FLASH百强 发表于 2007-12-25 10:09:25 | 显示全部楼层
回复

使用道具 举报

cqfanli 发表于 2007-12-28 23:51:53 | 显示全部楼层
谢谢~~
回复

使用道具 举报

zslunlun 发表于 2008-1-17 20:29:47 | 显示全部楼层
网上的文章都很汗的!!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-11-19 21:21 , Processed in 0.025933 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表