php安装(包括链接mysql测试)

#1 安装相关包
yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel

#2 下载php
wget http://cn2.php.net/distributions/php-5.4.38.tar.gz
tar zxf php-5.4.38.tar.gz
cd php-5.4.38

#3 编译安装
./configure --prefix=/application/php-5.4.38  --enable-fpm --with-mcrypt --enable-mbstring --disable-pdo --with-curl --disable-debug  --disable-rpath --enable-inline-optimization --with-bz2  --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli --with-gd --with-jpeg-dir

make && make install
#4
ln -s /application/php-5.4.38/ /application/php
cp php.ini-production  /application/php/lib/php.ini
cd /application/php/etc/
cp php-fpm.conf.default  php-fpm.conf

mkdir /app/logs –p
/application/php/sbin/php-fpm –t
/application/php/sbin/php-fpm
lsof -i :9000

#5 查看扩展
/application/php/bin/php -m

#6 创建web目录
mkdir /data/www -p

#7 测试
/application/php/bin/php test.php


### 在本地装nginx

### 在另一台装mysql并授权
grant all on *.* to ‘root‘@‘192.168.189.%‘ identified by ‘123456‘;
grant all on *.* to ‘yeqing‘@‘192.168.189.%‘ identified by ‘123456‘;
grant all on test.* to ‘yeqing‘@‘192.168.189.%‘ identified by ‘123456‘;
flush privileges;

### 在本地装mysql 去链接mysql服务器
yum install mysql


### 链接mysql
mysql -u root -p -h 192.168.189.131


### 测试链接mysql
<?php
mysql_connect(‘192.168.189.131‘, ‘yeqing‘, ‘123456‘) or die(‘11111111111‘);
mysql_select_db(‘test‘) or die(‘2222222222‘);
mysql_query("set names utf8");
$sql = "select user,host from mysql.user";
$res = mysql_query($sql);
$data = mysql_fetch_array($res);
echo ‘<pre />‘;
print_r($data);
?>

#### 测试链接mysqli
<?php
$link = mysqli_connect(‘192.168.189.131‘, ‘yeqing‘, ‘123456‘,‘mysql‘) or die(‘11111111111‘);
$res  = mysqli_query($link,‘select user,host from mysql.user‘);
$data = mysqli_fetch_array($res);
while($row = mysqli_fetch_array($res)){
  echo $row[‘user‘],‘-->‘,$row[‘host‘],"\r\n";
}
?>

#### 测试
/application/php/bin/php test.php

本文出自 “技术屌丝” 博客,转载请与作者联系!

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。