为了账号安全,请及时绑定邮箱和手机立即绑定

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

标签:
PHP

php安装顺序:先安装apache 再安装php

cd ../php-NN./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysqlmakemake install

参照手册:http://php.net/manual/zh/install.unix.apache2.php


#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-jpeg-dir --with-png-dir --with-freetype-dir --with-gd

--with-apxs2=/usr/local/apache2/bin/apxs --with-mysql


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

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消