1.安装函数库
[root@lamp ~]
[root@lamp ~]
-rw-r--r--. 1 root root 4984397 Aug 4 2018 libiconv-1.14.tar.gz
[root@lamp ~]
[root@lamp ~]
[root@lamp libiconv-1.14]
[root@lamp libiconv-1.14]
2.编译安装PHP
2.1解压安装包
[root@lamp ~]
[root@lamp ~]
2.2编译安装
[root@lamp php-5.3.27]# ./configure --prefix=/usr/local/php5.3.27 --with-apxs2=/application/apache/bin/apxs \
--with-mysql=/application/mysql --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
[root@lamp php-5.3.27]# make && make install
[root@lamp php-5.3.27]# ln -s /application/php5.3.27/ /application/php
报错一:
1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)
The output of /application/apache/bin/apxs follows:
./configure: /application/apache/bin/apxs: /replace/with/path/to/perl/interpreter: bad interpreter: No such file or directory
configure: error: Aborting
解决方法:
[root@lamp php-5.3.27]# vi /application/apache2.2.27/bin/apxs
1 #!/replace/with/path/to/perl/interpreter -w
修改成
1 #!/usr/bin/perl -w
报错二:
configure: error: Cannot find OpenSSL
解决方法:
[root@lamp php-5.3.27]# yum install openssl-devel -y
报错三:
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
解决方法:
[root@lamp php-5.3.27]# yum install libxslt-devel -y
3.编译参数详解
博客链接:点击
4.拷贝php配置文件到默认目录并改名
[root@lamp php-5.3.27]
5.配置Apache支持PHP
[root@lamp php-5.3.27]
[root@lamp apache]
67 User www
68 Group www
168 DirectoryIndex index.php index.html
311 AddType application/x-httpd-php .php .phtml
312 AddType application/x-httpd-source .phps
[root@lamp apache]
[root@lamp apache]
Syntax OK
[root@lamp apache]
[root@lamp html]
[root@lamp www]
<?php
phpinfo()
?>
6.网页访问
7.测试连接mysql
[root@lamp www]
<?php
//$link_id=mysql_connect('主机名','用户','密码');
$link_id=mysql_connect('localhost','root','000000') or mysql_error();
if($link_id){
echo "mysql successful by https://blog.csdn.net/liang_operations!";
}else{
echo mysql_error();
}
?>
8.网页访问