1.准备以下源码包
apr-1.4.5.tar.gz
apr-util-1.3.12.tar.gz
pcre-8.10.zip
libxml2-sources-2.9.2.tar.gz
httpd-2.4.18.tar.gz
mysql-5.0.22.tar.gz
php-7.0.4.tar.gz
2.安装
apr安装
./configure --prefix=/opt/LAMP/apr
make&&make install
apr-util安装
./configure --prefix=/opt/LAMP/apr-util --with-apr=/opt/LAMP/apr
make&&make install
pcre安装
./configure --prefix=/opt/LAMP/pcre
make&&make install
libxml2安装
./configure --prefix=/opt/LAMP/libxml2
make&&make install
apache安装
./configure --prefix=/opt/LAMP/apache2 --with-apr=/opt/LAMP/apr --with-apr-util=/opt/LAMP/apr-util --with-pcre=/opt/LAMP/pcre --with-libxml2=/opt/LAMP/libxml2 --enable-so --enable-cgi --enable-rewrite
make&&make install
ncurses安装
apt-cache search ncurses
apt-get install libncurses5-dev
mysql安装
./configure --prefix=/opt/LAMP/mysql
make&&make install
php安装
./configure --prefix=/opt/LAMP/php --with-libxml-dir=/opt/LAMP/libxml2 --enable-mysqlnd --with-pdo-mysql=mysqlnd --with-apxs2=/opt/LAMP/apache2/bin/apxs --with-config-file-path=/opt/LAMP
make&&make install
3.配置
php配置
cp php.ini-development /opt/LAMP/php.ini
apache配置
在httpd.conf中添加
LoadModule php7_module modules/libphp7.so
AddType application/x-httpd-php .php
DirectoryIndex index.html index.php
4.测试
-
<?php
-
try{
-
$dbh = new PDO('mysql:host=localhost;port=3306;dbname=xxx', 'xxx', 'xxx',array( PDO::ATTR_PERSISTENT => false));
-
$stmt = $dbh->prepare("SELECT xxx FROM xxx WHERE xxx=:xxx");
-
$stmt->execute(array(':xxx'=>'xxx'));
-
while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
-
echo $row['xxx'];
-
}
-
} catch (PDOException $e) {
-
print "Error!: " . $e->getMessage() . "
";
-
die();
-
}
-
?>
阅读(2457) | 评论(0) | 转发(0) |