本节内容:
php gd库的安装与配置。
php 开启url rewrite重写、伪静态配置。
一,所需软件
jpegsrc.v6b.tar.gz
freetype-2.1.10.tar.gz
zlib-1.2.3.tar.gz
libpng-1.2.12.tar.gz
gd-2.0.33.tar.gz
libxml2-2.6.23.tar.bz2
ZendOptimizer-3.3.3-
linux-glibc23-i386.tar.gz
二,安装顺序
1 mysql
2 apache
3 JPEG包
4 TTF包
5 zlib包(libpng包)
6 libpng包
7 GD包
8 XML包(libxml)
9 php
10 Zend
三,安装过程
1,mysql
mysql、php配置,请参考:
win2003系统下apache、php、mysql安装与虚拟主机、目录权限配置
win2003系统下PHP5 图文安装教程
centos6中配置Apache+MySQL+PHP+SSL环境
Apache+Mysql+PHP搭建LAMP平台的教程
(图文)搭建Centos+Apache+PHP+MySQL服务器环境
CentOS安装Apache+PHP+MySQL教程
2,apache
复制代码 代码示例:
# tar zxvf httpd-2.2.6.tar.gz
# cd httpd-2.2.6
# ./configure --prefix=/usr/local/apache2 --enable-so --enable-track-vars --enable-proxy --enable-vhost-
alias --enable-cache --enable-disk-cache --enable-mem-cache --enable-rewrite --enable-mods-shared=all
# make
# make install
3,JPEG包
复制代码 代码示例:
# tar zxvf jpegsrc.v6b.tar.gz
# cd jpeg-6b/
# mkdir /usr/local/jpeg
# mkdir /usr/local/jpeg/bin
# mkdir /usr/local/jpeg/lib
# mkdir /usr/local/jpeg/
include
# mkdir /usr/local/jpeg/man
# mkdir /usr/local/jpeg/man/man1
# ./configure --prefix=/usr/local/jpeg
# make
# make install
# make install-lib
4,TTF包
复制代码 代码示例:
# tar zxvf freetype-2.1.10.tar.gz
# cd freetype-2.1.10
# ./configure --prefix=/usr/local/freetype
# make
# make install
5,zlib包
复制代码 代码示例:
# tar zxvf zlib-1.2.3.tar.gz
# cd zlib-1.2.3
# ./configure
# make
# make install
6,libpng包
复制代码 代码示例:
# tar zxvf libpng-1.2.12.tar.gz
# cd libpng-1.2.12
# ./configure
# make
# make install
7,php gd库
复制代码 代码示例:
# tar zxvf gd-2.0.33.tar.gz
# cd gd-2.0.33
# ./configure
# make
# make install
# cp gd.h /usr/local/lib/
8,XML库(libxml)
复制代码 代码示例:
# tar jxvf libxml2-2.6.23.tar.bz2
# cd libxml2-2.6.23
# ./configure
# make
# make install
9,php
复制代码 代码示例:
# tar zxvf php-5.2.5.tar.gz
# cd php-5.2.5
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-gd --with-jpeg-dir=/usr/local/jpeg --with-ttf --with-freetype-dir=/usr/local/freetype --with-zlib --with-png --with-mysql=/usr/local/mysql/ --with-mbstring --enable-mbstring=all --enable-mbstr-enc-trans --enable-mbregex --enable-track-vars
# make
# make install
# cp php.ini-dist /usr/local/php/lib/php.ini
httpd.conf
复制代码 代码示例:
AddType application/x-httpd-php .php .phtml
10,Zend
复制代码 代码示例:
# tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
# cd ZendOptimizer-3.3.3-linux-glibc23-i386
# ./install.sh
四,创建测试页
复制代码 代码示例:
页面搜索gd,显示如下则表示成功:
GD Support enabled
GD Version bundled (2.0.34 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.1.10
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled
页面搜索Zend显示如下信息
with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies
五,--enable-rewrite
在编译apache时加了个--enable-rewrite,apache伪静态html
例子:
# vim /usr/local/apache2/conf/httpd.conf
在httpd.conf中添加:
复制代码 代码示例:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^/a([0-9]+).html$ /a$1.php [L]
</IfModule>
测试是否成功:
目录下有a1.php a2.php a3.php
当输入a1.html a2.html a3.html时,访问的是以上php文件
在做项目时已其中的链接全写成了html格式。
六,--enable-rewrite 防盗链
复制代码 代码示例:
<Directory "e:/Work/upload">
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://www.123.com/.*$ [NC]
RewriteRule .*/.(ppt|zip|rar|doc|wps)$ http://www.123.com/404.html [L]
</Directory>
七,关于shtml
apache默认是不支持SSI的,需要更改httpd.conf来进行配置。
# vim /usr/local/apache2/conf/httpd.conf
把这两行前面的#去掉
复制代码 代码示例:
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
然后,搜索"Options Indexes FollowSymLinks"
在搜索到的那一行后面添加"Includes"
即将该行改变为:
Options Indexes FollowSymLinks Includes
测试,创建文件test.shtml,内容如下:
<!--#include file="test.php"-->