CentOS 7.4下源码编译安装配置LAMP环境详解(3)

libjpeg \
libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 \
libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel
(注意:如果安装过程出错,修改下面文件,添加一行)
vi /usr/local/httpd/bin/apxs
#!/usr/bin/perl –w

二:解压安装包
[root@localhost ~]# tar xjvf php-7.1.10.tar.bz2

三:配置(个性化配置及优化项目)
[root@localhost php-7.1.10]# cd php-7.1.10
[root@localhost php-7.1.10]# ./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/httpd/bin/apxs \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-mysqli \
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-zip

四:编译与安装
[root@localhost php-7.1.10]# make
[root@localhost php-7.1.10]# make install

五:编辑配置文件
[root@localhost php-7.1.10]# cp php.ini-development /usr/local/php/lib/php.ini
//创建配置文件
[root@localhost php-7.1.10]# vi /usr/local/php/lib/php.ini //编辑配置文件
mysqli.default_socket = /usr/local/mysql/mysql.sock //将php与mysql关联
date.timezone = Asia/Shanghai //时区设置
[root@localhost php-7.1.10]# /usr/local/php/bin/php –m //验证安装的模块

六:关联php与apache服务
[root@localhost php-7.1.10]# vi /etc/httpd.conf //编辑Apache配置文件,使httpd支持php网页解析
添加以下两行内容:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
修改以下内容:
DirectoryIndex index.php index.html //此处注意,php文件必须放前面,优先读取
[root@localhost php-7.1.10]# rm -f /usr/local/httpd/htdocs/index.html //删除默认html文件
[root@localhost php-7.1.10]# vi /usr/local/httpd/htdocs/index.php //编辑php测试网页
添加以下内容(php信息)
<?php
phpinfo();
?>
保存退出
[root@localhost php-7.1.10]# systemctl stop httpd
[root@localhost php-7.1.10]# systemctl start httpd //重启httpd服务

七:验证

用win7访问192.168.80.10
(注意:如果访问不了,用netstat检查httpd运行状态)

CentOS 7.4下源码编译安装配置LAMP环境详解

测试数据库
[root@localhost ~]# mysql -u root –p //登录数据库(输入上面设置的root密码)
CREATE DATABASE myadm; //创建数据库myadm
GRANT all ON myadm. TO 'myadm'@'%' IDENTIFIED BY 'admin123'; //授权
GRANT all ON myadm. TO 'myadm'@'localhost' IDENTIFIED BY 'admin123';
flush privileges; //刷新权限

CentOS 7.4下源码编译安装配置LAMP环境详解


//重启mysql服务
[root@localhost ~]# systemctl restart mysqld

//编辑index.php文件(将里面原来内容删除,添加以下内容)
<?php
$link=mysqli_connect('192.168.80.40','myadm','admin123');
if($link) echo "<h1>Success!!</h1>";
else echo "Fail!!";
?>

//重启http服务
[root@localhost ~]# systemctl stop httpd
[root@localhost ~]# systemctl start httpd

//用win7访问服务器地址192.168.80.10

CentOS 7.4下源码编译安装配置LAMP环境详解


//验证成功

第五部分 LAMP架构应用
部署phpMyAdmin系统:
phpMyAdmin是一个使用PHP语言编写,用来管理MYSQL数据库的Web应用系统
一:安装phpMyadmin
[root@localhost ~]# yum install -y unzip
(由于我下载的phpMyadmin是zip格式压缩包,所以要安装unzip命令解压)
//解压phpMyadmin
[root@localhost ~]# unzip phpMyAdmin-4.7.6-all-languages.zip -d /opt/
[root@localhost ~]# cd /opt/
[root@localhost opt]# mv phpMyAdmin-4.7.6-all-languages /usr/local/httpd/htdocs/myadm //将文件移到apache目录下

二:创建phpMyadmin配置文件
[root@localhost opt]# cd /usr/local/httpd/htdocs/myadm/
[root@localhost myadm]# cp config.sample.inc.php config.inc.php

三:编辑配置文件
[root@localhost myadm]# vi config.inc.php
$cfg['Servers'][$i]['host'] = '127.0.0.1'; //把localhost 改成IP
保存退出

四:重启apache服务
[root@localhost myadm]# systemctl stop httpd
[root@localhost myadm]# systemctl start httpd

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/6a7f3ccf075770b394fd74358fe7a3a6.html