搭建LAMP架构之安装最新版PHP5.5.4
LAMP平台构成组件:Linux、Apache、MySQL、PHP构建PHP运行环境安装前工作:确保没有rpm包PHP,且以源码包安装Apache、MySQL程序(详见搭建LAMP架构之Apache和MySQL)安装GD库和GD库关联程序(gd库要是2.1版本以上)(使之支持加载.jpeg、.png等图片)yum-yinstall\libjpeg-devel\libpng-devel\freetype-devel\zlib-devel\gettext-devel\libXpm-devel\libxml2-devel\fontconfig-devel\openssl-devel\bzip2-devel(还有gcc、gcc-c++、make等开发工具系统中要已安装)解压缩gd-2.1.0.tar.gztarzxvfgd-2.1.0.tar.gz/usr/src到gd源码包目录配置编译并安装./configure--prefix=/usr/local/gdmake&&makeinstall安装PHP解压PHP-5.5.4源码包tarzxvfphp-5.5.4.tar.gz2/usr/src进入php源码包目录配置编译并安装./configure\--prefix=/usr/local/php\--with-apxs2=/usr/local/apache/bin/apxs\--with-gd=/usr/local/gd\--with-gd\--with-mysql=/usr/local/mysql\--with-config-file-path=/etc\--enable-sqlite-utf8\--with-zlib-dir\--with-libxml-dir\--with-freetype-dir\--with-jpeg-dir\--with-png-dir\--with-ttf\--with-iconv\--with-openssl\--with-gettext\--enable-mbstring\--enable-gd-native-ttf\--enable-gd-jis-conv\--enable-static\--enable-zend-multibyte\--enable-inline-optimization\--enable-sockets\--enable-soap\--enable-ftp\--disable-ipv6配置中需注意:--with-apxs2=:指向Apache安装目录下的/bin/apxs--with-gd=:指向GD的安装目录--with-gd:不能省略,不然编译时会出错--with-mysql=:指向MySQL安装目录--with-config-file-path=:指定PHP的配置文件放置目录make&&makeinstallPHP不作为系统程序而存在,就相当于一个插件,协同Apache和MySQL工作。配置文件默认没有,可以把源码包目录下的模板拷过来就可以了(配置文件所在目录在源码包配置时--with-config-file-path=指定的目录,一般指向/etc)cp/usr/src/php-5.5.4/php.ini-production/etc/php.ini重新配置Apache配置文件httpd.conf,使之支持PHPvi/usr/local/apache/conf/httpd.conf添加AddTypeapplication/x-httpd-php.phpAddTypeapplication/x-httpd-php-source.phps为了方便管理,一般把这两行插在AddType配置项一起查看配置项中有没有下面一行配置项,如果没有则添加LoadModulephp5_modulemodules/libphp5.so配置DirectoryIndex首页配置,使Apache支持.php动态首页DirectoryIndexindex.phpindex.html重启Apache服务servicehttpdrestart测试PHP网页是否能正确显示在Apache网站根目录添加Index.php动态首页,viindex.php编辑内容<?phpphpinfo();?>登录网站首页测试测试PHP网页是否能访问MySQl数据库编辑Index.php网页中内容为<?php$link=mysql_connect('192.168.1.1','tom','123');if(!$link)echo"Fail!!";elseecho"Success!!";mysql_close();?>(192.168.1.1为服务器的IP地址,在MySQL数据库中添加授权用户tom,密码为123)如果能访问,显示为Success!!,反之则为Fail!!※自你走后∥那份属于我的孤独∥又重新回到了我身边◆◇ ̄ ̄ 我们这个年代,不需要太多的感情 有的东西失去了就永不再回来 即使哭了我也要笑、即使笑了我也要继续。 拥有、笑过、哭过。太多理由。爱已经腐朽。 如果,你真的不爱我,就告诉我,我不会纠缠你。还你自由!
页:
[1]