安装PHP:配置LAMP平台,测试LAMP协同工作

配置LAMP平台。

准备需要的软件包:
#libmcrypt-2.5.8
#mcrypt-2.6.8
#php-5.3.28
#mhash-0.9.9.9
#ZendGuardLoader-php-5.3-linux-glibc23-i386
如需要Apache 和 Mysql 的安装请点击下方链接:
Apache安装及优化
Mysql数据库的安装及优化
1.安装PHP依赖程序。
[root@Centos /]# yum -y install zlib-devel libxml2-devel
2.安装加密工具libmcrypt。
[root@Centos libmcrypt-2.5.8]# ./configure && make && make install
[root@Centos libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt.* /usr/lib
3.安装mhash。
[root@Centos mhash-0.9.9.9]# ./configure && make && make install
[root@Centos mhash-0.9.9.9]# ln -s /usr/local/lib/libmash* /usr/lib
4.安装mcrtypt。
[root@Centos mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/lib #解决configure配置报错
[root@Centos mcrypt-2.6.8]# ./configure && make && make install
5.配置安装PHP。
1)配置及编译安装php。
[root@Centos php-5.3.28]# ./configure --prefix=/usr/local/php --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-config-file-path=/usr/local/php --enable-mbstring
#–with-mcrypt :加载数据加密等扩展工具支持
#–with-apxs2:设置Apache HTTP Server 提供的apxs模块支持程序的文件位置
#–with-mysql:设置Mysql数据库服务程序的安装位置
# --with-mysqli :添加mysqli扩展支持
#–with-config-file-path :设置PHP的配置文件php.ini将要存放的位置
#–enable-mbstring :启动多字节字符串功能,以便支持中文等代码
[root@Centos php-5.3.28]# make && make install

2)生成php主配置文件 (在安装包里)
[root@Centos php-5.3.28]# cp php.ini-production /usr/local/php/php.init
[root@Centos php-5.3.28]# vim /usr/local/php/php.init
;default_charset = “iso-8859-1”
default_charset = “utf-8”
在这里插入图片描述
3)修改php默认和加载zend加速模块。
[root@Centos /]# tar xzvf /mnt/zendguardloader-php-5.3-linux-glibc23-i386.tar.gz -C /usr/src/
[root@Centos /]# cd /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/
[root@Centos php-5.3.x]# mv ./ZendGuardLoader.so /usr/local/php/lib/php/
[PHP]
zend_extension=/usr/local/php/lib/php/ZendGuardLoader.so
zend_loader.enable=1
在这里插入图片描述
6.配置apache加载php。
1)加载模块。
[root@Centos /]# vim /usr/local/httpd/conf/httpd.conf

DirectoryIndex index.html index.php

#AddType application/x-gzip .tgz
AddType application/x-httpd-php .php
在这里插入图片描述
[root@Centos /]# systemctl restart httpd
2)编写测试php。
[root@Centos /]# vim /usr/local/httpd/htdocs/index.php

<?php phpinfo(); ?>

在这里插入图片描述
在这里插入图片描述
3)测试链接数据库。

<?php $link=mysql_connect('localhost','root','pwd@123'); if($link) echo "yes"; mysql_close( ); ?>

在这里插入图片描述
7.部署phpmyadmin。
1)将phpmyadmin部署到网页的根目录
[root@Centos htdocs]# tar xzvf /mnt/phpmyadmin-3.3.10-all-languages.tar.gz -C /usr/src/
[root@Centos /]# mv /usr/src/phpMyAdmin-3.3.10-all-languages/ /usr/local/httpd/htdocs/phpmyadmin

在这里插入图片描述
在这里插入图片描述

发布了52 篇原创文章 · 获赞 4 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/HCY_2315/article/details/102883365