apt-get install mysql-server mysql-client
apt-get install apache2
apt-get install php7.0 libapache2-mod-php7.0
sudo apt-get install php7.0-mysql
重启apache
/etc/init.d/apache2 restart
新建index.php文件
<?php
phpinfo();
?>

php连接mysql
<?php
header('Content-type: text/json;charset=utf-8');
$page = $_POST['page'];
$callBack = array();
$conn = new mysqli("localhost","root","","db");
$begin = $page * 10;
$sql = "SELECT * FROM table order by time desc limit $begin,10";
$infoResult = mysqli_query($conn,$sql);
while( $row = mysqli_fetch_array($infoResult) ){
$member = array("id" => $row['id']);
array_push($callBack,$member);
}
mysqli_close($conn);
echo json_encode($callBack);
?>
网友评论