apache php env build

from http://blog.csdn.net/yincg/article/details/8782364


1.1 系统说明
Centos 6.2 (最小化安装)
1.2 软件说明
httpd-2.4.2.tar.gz
apr-util-1.4.1.tar.gz
apr-1.4.6.tar.gz
pcre-8.13.tar.gz
php-5.4.3.tar.bz2
libmcrypt-2.5.8.tar.gz
mhash-0.9.9.9.tar.gz
第2章  Apache搭建说明
2.1 安装依赖包
yum install make openldap-devel ntp vim-enhanced gcc gcc-c++ gcc-g77 flex bison autoconf bzip2-devel ncurses-devel openssl-devel libtool*  zlib-devel libxml2-devel libjpeg-devel libpng-devel libtiff-devel fontconfig-devel freetype-devel libXpm-devel gettext-devel curl-devel curl pam-devel  openldap-devel e2fsprogs-devel krb5-devel libidn libidn-devel -y
2.2 安装apr
tar -zxvf apr-1.4.2.tar.gz
 cd apr-1.4.2.tar.gz
 ./configure  --prefix=/usr/local/apr
make  && make install
2.3 安装apr-util
tar -zxvf apr-util-1.3.10.tar.gz
cd apr-util-1.3.10.tar.gz
 ./configure \
--prefix=/usr/local/apr-util \
--with-apr=/usr/local/apr
 make && make install
2.4 安装pcre
tar -zxvf pcre-8.10.tar.gz
cd pcre-8.10
./configure --prefix=/usr/local/pcre
make && make install
2.5 安装apache
./configure \
--prefix=/usr/local/apache \
--with-apr-util=/usr/local/apr-util/ \
--with-pcre=/usr/local/pcre/ \
--with-apr=/usr/local/apr/
make && make install
2.6 配置文件说明
/usr/local/apache/conf/httpd.conf
DocumentRoot "/usr/local/apache/htdocs"
修改此条可配置项目运行目录。
启动文件
/usr/local/apache/bin/apachectl
第3章  Php搭建说明
3.1 安装libmcrypt
tar xvf libmcrypt-2.5.8.tar.gz
./configure
make && make install
3.2 安装mhash
tar xvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure 
make && make install
3.3 安装php
./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache/bin/apxs \
--with-config-file-path=/usr/local/php/etc 
make && make install 
cp php.ini-production /usr/local/php/etc/php.ini
3.4 错误提示修改说明
configure: error: Cannot find ldap libraries in /usr/lib
ln -s /usr/lib64/libldap* /usr/lib/
configure: error: libjpeg.(a|so) not found.
ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
configure: error: libpng.(a|so) not found.
ln -s /usr/lib64/libpng.so /usr/lib/
第4章  修改配置并测试
4.1 修改apache配置文件支持php
修改DirectoryIndex index.html 为DirectoryIndex index.html index.php
并添加AddType application/x-httpd-php .php
4.2 测试php支持
创建测试php页面test.php,并存放在网站主目录下,
phpinfo();
?>
重启apache服务后,访问http://ip/test.php
看到站点,则说明php搭建完成; 

2,example

 



 

// define variables and set to empty values
$name = $email = $gender = $comment = $website = "";

if ($_SERVER["REQUEST_METHOD"] == "POST")
{
   $name = test_input($_POST["name"]);
   $email = test_input($_POST["email"]);
   $website = test_input($_POST["website"]);
   $comment = test_input($_POST["comment"]);
   $gender = test_input($_POST["gender"]);
}

function test_input($data)
{
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   return $data;
}
?>


PHP Form Validation Example


"> 
   Name:
  


   E-mail:
  


   Website:
  


   Comment:
  


   Gender:
   Female
   Male
  


    


echo "

Your Input:

";
echo $name;
echo "
";
echo $email;
echo "
";
echo $website;
echo "
";
echo $comment;
echo "
";
echo $gender;
?>



 

你可能感兴趣的:(apache php env build)