LAMP-php5.3.27配置环境
安装之前检查mysql和apache是否正常启动
安装准备
yum install zlib libxml libjpeg freetype libpng gd curl zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel openssl-devel libxslt-devel -y
tar zxf libiconv-1.14.tar.gz cd libiconv-1.14 ./configure --prefix=/usr/local/libiconv make make install cd ../
编译
./configure --prefix=/application/php5.3.27 --with-apxs2=/application/apache/bin/apxs --with-mysql=mysqlnd --with-xmlrpc --with-openssl --with-zlib --with-freetype-dir --with-gd --with-jpeg-dir --with-png-dir --with-iconv-dir=/usr/local/libiconv --enable-short-tags --enable-sockets --enable-zend-multibyte --enable-soap --enable-mbstring --enable-static --enable-gd-native-ttf --with-curl --with-xsl --enable-ftp --with-libxml-dir
./configure \ --prefix=/application/php5.3.27 \ --with-apxs2=/application/apache/bin/apxs \ #通过dso方式添加apache的php模块,要指定正确的路径 --with-mysql=/application/mysql \ #指定之前mysql的安装路径,如果没有安装mysql用 --with-mysql=mysqlnd \ --with-xmlrpc \ --with-openssl \ --with-zlib \ --with-freetype-dir \ --with-gd \ --with-jpeg-dir \ --with-png-dir \ --with-iconv=/usr/local/libiconv \ --enable-short-tags \ --enable-sockets \ --enable-zend-multibyte \ --enable-soap \ --enable-mbstring \ --enable-static \ --enable-gd-native-ttf \ --with-curl \ --with-xsl \ --enable-ftp \ --with-libxml-dir
如果编译中有如下报错
configure: error: Cannot find OpenSSL's <evp.h> 解决办法:yum -y install openssl-devel -y
编译继续,报错
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution 解决办法:yum -y install libxslt-devel
以上报错,建议在安装前就yum安装上
然后
make && make install
安装完毕检查
[root@study php-5.3.27]# ln -s /application/php5.3.27/ /application/php [root@study php-5.3.27]# ll !$ ll /application/php lrwxrwxrwx 1 root root 23 Sep 29 12:00 /application/php -> /application/php5.3.27/ [root@study php-5.3.27]# ll /application/apache/modules/ total 28888 -rw-r--r-- 1 root root 9115 Sep 27 17:55 httpd.exp -rwxr-xr-x 1 root root 29568245 Sep 29 11:59 libphp5.so [root@study php-5.3.27]# grep libphp5.so /application/apache/conf/httpd.conf LoadModule php5_module modules/libphp5.so
ls php.ini-* diff `ls php.ini-*` 将php配置文件cp到默认的路径下 cp php.ini-production /application/php/lib/php.ini ll /application/php/lib/php.ini
在修改apache主配置文件,整合php
vim /application/apache/conf/httpd.conf 在AddType application/x-compress .Z(大概309行) AddType application/x-gzip .gz .tgz 两行下面添加两条内容 AddType application/x-httpd-php .php .phtml AddType application/x-httpd-php-source .phps
再将(大概67行)
User daemon Group daemon
修改为
User shnne Group shnne
添加默认首页(大概168行)
<IfModule dir_module> DirectoryIndex index.php index.html </IfModule>
检查语法的时候出现以下报错
[root@study logs]# /application/apache/bin/apachectl -t Syntax error on line 311 of /application/apache2.2.27/conf/httpd.conf: Invalid command 'AddType\xc2\xa0application/x-httpd-php', perhaps misspelled or defined by a module not included in the server configuration
可能是有特殊字符,比如空格不对,或者是模块问题。
/application/apache/bin/apachectl -t /application/apache/bin/apachectl graceful
然后在测试网站
echo "<?php phpinfo();?>" > /var/html/bbs/index.php
测试数据库
<?php //$link_id=mysql_connect('主机名','用户','密码'); $link_id=mysql_connect('localhost','root','234') or mysql_error(); if($link_id){ echo "mysql successful !"; }else{ echo mysql_error(); } ?>
网友留言(0 条)