天天看点

apache2+mysql5+php5+gd安装

安装zlib-1.2.3

./configure --enable-shared

make

make install

安装libxml-2.6.3

./configure --prefix=/usr/local/libxml2 --with-zlib --with-http --enable-shared

make

make install

安装gettext-0.17

 ./configure --prefix=/usr/local/gettext --enable-shared

make

make install

安装png

./configure  --prefix=/usr/local/png --enable-shared

make

make install

安装jpeg

 ./configure --prefix=/usr/local/jpeg --enable-shared

 make

  mkdir -p /usr/local/jpeg/include

  mkdir -p /usr/local/jpeg/lib

  mkdir -p /usr/local/jpeg/bin

  mkdir -p /usr/local/jpeg/man/man1

  make install

安装freetype

./configure --prefix=/usr/local/freetype --enable-shared

 make

make install

tar zxvf gd-2.0.35.tar.gz

cd gd-2.0.35

./configure --prefix=/usr/local/libgd --with-png=/usr/local/libpng --with-freetype=/usr/local/freetype  --with-jpeg=/usr/local/libjpeg --with-fontconfig=/usr/local/fontconfig

看到下面的信息, 呵呵  很多都显示支持了

Support for PNG library:          yes

Support for JPEG library:         yes

Support for Freetype 2.x library: yes

Support for Fontconfig library:   yes

Support for Xpm library:          no

Support for pthreads:             yes

make

make install

============================================================

apache2.2.9+mysql5+php5在centos-5.2上的安装:

apache+mysql+php

解压缩mysql安装包,进入mysql文件夹。

mysql5.2.6

./configure --prefix=/usr/local/mysql   --localstatedir=/var/lib/mysql   --with-comment=Source   --with-server-suffix=-Community   --with-mysqld-user=mysql   --without-debug   --with-big-tables   --with-charset=latin1   --with-collation=latin1_swedish_ci   --with-extra-charsets=all   --with-pthread   --enable-static   --enable-thread-safe-client   --with-client-ldflags=-all-static   --with-mysqld-ldflags=-all-static   --enable-assembler   --without-innodb   --without-ndb-debug

make

make install

# useradd mysql //添加 mysql 用户

# cd /usr/local/mysql

# bin/mysql_install_db --user=mysql

# chown -R root:mysql . //设置权限,注意后面有一个 "."

# chown -R mysql /var/lib/mysql //设置 mysql 目录权限

# chgrp -R mysql . //注意后面有一个 "."

# cp share/mysql/my-huge.cnf /etc/my.cnf

初始化表

# /usr/local/mysql/scrīpts/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服务了

二、安装apache2

解压缩apache安装包,进入apache文件夹。

安装:

apache2.2.9

  ./configure --prefix=/usr/local/apache2 --enable-http  --enable-modules=all --enable-rewrite --enable-so --enable-cgi --enable-cgid --enable-deflate=shared --enable-cache --enable-file-cache

make

make install

注解:

./configure //配置源代码树

--prefix=/usr/local/apache2 //体系无关文件的顶级安装目录PREFIX ,也就Apache的安装目录。

--enable-module=so //打开 so 模块,so 模块是用来提 DSO 支持的 apache 核心模块

--enable-deflate=shared //支持网页压缩

--enable-expires=shared //支持 HTTP 控制

--enable-rewrite=shared //支持 URL 重写

--enable-cache   //支持缓存

--enable-file-cache   //支持文件缓存

--enable-mem-cache   //支持记忆缓存

--enable-disk-cache   //支持磁盘缓存

--enable-static-support //支持静态连接(默认为动态连接)

--enable-static-htpasswd //使用静态连接编译 htpasswd - 管理用于基本认证的用户文件

--enable-static-htdigest //使用静态连接编译 htdigest - 管理用于摘要认证的用户文件

--enable-static-rotatelogs //使用静态连接编译 rotatelogs - 滚动 Apache 日志的管道日志程序

--enable-static-logresolve //使用静态连接编译 logresolve - 解析 Apache 日志中的IP地址为主机名

--enable-static-htdbm //使用静态连接编译 htdbm - 操作 DBM 密码数据库

--enable-static-ab //使用静态连接编译 ab - Apache HTTP 服务器性能测试工具

--enable-static-checkgid //使用静态连接编译 checkgid

--disable-cgid //禁止用一个外部 CGI 守护进程执行CGI脚本

--disable-cgi //禁止编译 CGI 版本的 PHP

--disable-userdir //禁止用户从自己的主目录中提供页面

--with-mpm=worker // 让apache以worker方式运行

--enable-authn-dbm=shared // 对动态数据库进行操作。Rewrite时需要。

三、安装php5

解压缩php安装包,进入php文件夹。

安装:

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-zlib-dir --with-libxml-dir=/usr/local/libxml2/ --with-gd=/usr/local/gd --with-freetype-dir=/usr/local/freetype/ --with-jpeg-dir=/usr/local/jpeg/ --with-png-dir=/usr/local/png/ --enable-mbstring --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-gd-native-ttf --with-gettext=/usr/local/gettext/ --enable-magic-quotes --enable-sockets

make

make install

make clean

cp php.ini-dist /usr/local/php/lib/php.ini

四、收尾工作

vi /usr/local/apache/conf/httpd.conf

使apache支持php,增加

LoadModule php5_module modules/libphp5.so

AddType application/x-httpd-php .php

修改DirectoryIndex index.html index.php

找到这一段:

# AllowOverride controls what directives may be placed in .htaccess files.

# It can be "All", "None", or any combination of the keywords:

# Options FileInfo AuthConfig Limit

#

AllowOverride none

更改为AllowOverride all

允许apache rewrite

重启apache:/usr/local/apache2/bin/httpd -k restart

xml/libxml/zlib/gd/png/freetype/jpeg/

在编译gd的时候png报错:

gd_png.c:791: syntax error before "for"

gd_png.c:793: warning: parameter names (without types) in function declaration

gd_png.c:793: warning: data definition has no type or storage class

gd_png.c:794: syntax error before '}' token

gd_png.c:798: warning: parameter names (without types) in function declaration

gd_png.c:798: warning: data definition has no type or storage class

gd_png.c:799: syntax error before '}' token

gd_png.c:802: syntax error before '&' token

gd_png.c:802: warning: data definition has no type or storage class

gd_png.c:404: storage size of `open' isn't known

[color=Red]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

[[email protected] gd-2.0.26gif]# [/color]

解決方法为:

vi gd_png.c

找到「png.h」改成「/usr/local/libpng2/include/png.h」)

*******************************************************************************************************************

在交叉编译的jpeg时候如果出现以下的错误信息:

./libtool --mode=compile arm_920t_le-gcc -O2  -I. -c ./jcapimin.c

make: ./libtool: Command not found

解决方法:

#wget:http://ftp.gnu.org/gnu/libtool/libtool-2.2.6a.tar.gz

#./configure

#make

#make install

#cd jpeg

#cp /usr/share/libtool/config.sub .

#cp /usr/share/libtool/config.guess .

参考地址:http://www.trylife.cn/error-jpeg/

在编译php的时候会有:

CC=/usr/local/920t_le/bin/arm_920t_le-gcc ./configure --prefix=/usr/local/php/test --host=arm-linux --with-zlib-dir   --with-libxml-dir=/usr/local/libxml/  --with-gd=/usr/local/php/ --with-freetype-dir=/usr/local/php/ --with-jpeg-dir=/usr/local/php/ --with-png-dir=/usr/local/php/ --enable-mbstring --with-gettext=/usr/local/php/ --enable-sockets

 

 

Configuring extensions

checking whether to enable LIBXML support... yes

checking libxml2 install dir... /usr/local/libxml/

checking for xml2-config path... /usr/local/libxml//bin/xml2-config

checking whether libxml build works...

checking for OpenSSL support... no

checking for Kerberos support... no

checking for PCRE support... yes

checking for ZLIB support... no

checking if the location of ZLIB install directory is defined... yes

checking for gzgets in -lz... no

configure: error: ZLIB extension requires zlib >= 1.0.9

cat config.log

/usr/local/libxml/lib conftest.c -lz  -lm  -lxml2 -lz -lm 1>&5

/usr/local/920t_le/bin/../lib/gcc/arm-linux/3.4.4/../../../../arm-linux/bin/ld:           skipping incompatible /usr/local/php/lib//libxml2.so when searching for -lxml2

/usr/local/920t_le/bin/../lib/gcc/arm-linux/3.4.4/../../../../arm-linux/bin/ld:           skipping incompatible /usr/local/php/lib//libxml2.a when searching for -lxml2

/usr/local/920t_le/bin/../lib/gcc/arm-linux/3.4.4/../../../../arm-linux/bin/ld:           skipping incompatible /usr/local/libxml/lib/libxml2.so when searching for -lxml2

/usr/local/920t_le/bin/../lib/gcc/arm-linux/3.4.4/../../../../arm-linux/bin/ld:           skipping incompatible /usr/local/libxml/lib/libxml2.a when searching for -lxml2

/usr/local/920t_le/bin/../lib/gcc/arm-linux/3.4.4/../../../../arm-linux/bin/ld:           cannot find -lxml2

collect2: ld returned 1 exit status

configure: failed program was:

#line 23196 "configure"

#include "confdefs.h"

char gzgets();

int main() {

gzgets()

; return 0; }

 

解决办法:重新安装一遍libxml,安装的时候,在指定C编译器的同时,export PATH 交叉编译的编译器路径

类似 :export PATH="/usr/local/920t_le/armlinux/bin/:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/920t_le/bin"

然后在configure

 

问题:httpd: Syntax error on line 53 of /usr/local/apache/conf/httpd.conf: Cannot load /usr/local/apache/modules/libphp5.so into server: /usr/local/apache/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

解决办法:

原因是Linux有一个SELinux保护模式引起的。

1.关闭SELINUX的方法:

vi /etc linux/config 将SELINUX=enforcing 改成SELINUX=disabled 需要重启

2.不关闭SELINUX的方法:

# setenforce 0

# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so

# service httpd restart

# setenforce 1

或者

手工编译安装php后,如果一切顺利解决了的话,重启apache时,libphp5.so: cannot restore segment prot after reloc: Permission denied 错误:如果你是开着seliunx 的话,运行下面的命令: chcon -t texrel_shlib_t /usr/local/apache/modules/libphp5.so <具体chcon 的命令的意思,可以自己man一下,它是selinux有关的命令,更改文件的标签。ls命令在命令后加个 -Z 或者加 –context 查看标签> 如果 没有开selinux 的话,找到libphp5.so,然后chmod 777 libphp5.so 源自:http://www.phpfreaks.com/forums/index.php?topic=133131.0;wap2

Cannot load /www/modules/libphp5.so into server error

(1/1)

bigb89 : Hi, I am trying to install PHP and configure it to work with Apache. So far I have Apache 2 and MySQL 5 working just fine, but after intalling PHP I tried to restart Apache and I get the following error: Cannot load /www/modules/libphp5.so into server: /www/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied. What's causing this error is the following line on my httpd.conf file: LoadModule php5_module        modules/libphp5.so. Could anyone explain to me what's causing this error and how can I fix it? Thanks in advance!

rlee923 : Hi, I assume you are using one of those linux with Selinux enabled. The problem is caused by the security system - selinux, blocking it's access to libph5.so. chcon -t texrel_shlib_t /usr/local/apache/modules/libphp5.so This is the magic line of the code, change the path so it points to the directory where you've installed apache2 if necessary.

 

本文来自:http://blog.csdn.net/do2jiang/archive/2009/12/02/4923266.aspx