转载来自CSDN:https://blog.csdn.net/m0_50744953/article/details/110350763

LAMP

环境

  • 两台Linux
  • 1:apache+php(IP:192.168.1.1)
  • 2:mysql(IP:192.168.1.2)

配置

  • 首先安装好apache
  • 安装PHP
  • rpm -ivh zlib-devel-1.2.7-17.el7.x86_64.rpm
    rpm -ivh xz-devel-5.2.2-1.el7.x86_64.rpm
    rpm -ivh libxml2-devel-2.9.1-6.el7_2.3.x86_64.rpm
  • 拖进源码包
cd
tar -zxvf libmcrypt-2.5.8.tar.gz  -C /usr/src/
cd /usr/src/libmcrypt-2.5.8/
./configure && make && make install
ln -s /usr/local/lib/libmcrypt.* /usr/lib/
  • hash算法
cd
tar -zxvf mhash-0.9.9.9.tar.gz -C /usr/src/
cd /usr/src/mhash-0.9.9.9/
./configure && make && make install
ln -s /usr/local/lib/libmhash* /usr/lib/
  • 加密
cd
tar -zxvf mcrypt-2.6.8.tar.gz -C /usr/src/
  cd /usr/src/mcrypt-2.6.8/
./configure
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
./configure
make && make install
  • php
cd
tar -zxvf php-5.5.38.tar.gz -C /usr/src/
cd /usr/src/php-5.5.38/
./configure --prefix=/usr/local/php --with-mcrypt --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql  --with-mysqli --with-config-file-path=/usr/local/php --enable-mbstring --enable-sockets
make && make install
cp /usr/src/php-5.5.38/php.ini-development /usr/local/php/php.ini
  • 添加ZendGuardLoader优化模块:
tar -zxvf zend-loader-php5.5-linux-x86_64_update1.tar.gz -C /usr/src/
cd /usr/src/zend-loader-php5.5-linux-x86_64/
ls
cp ZendGuardLoader.so /usr/local/php/lib/php/

vim /usr/local/php/php.ini

 修改:
default_charset = "utf-8”(不修改这个会乱码)
   添加:
zend_extension=/usr/local/php/lib/php/ZendGuardLoader.so  #模块路径
zend_loader.enable=1       #开启模块

vim /usr/local/httpd/conf/httpd.conf

 改:LoadModule php5_module modules/libphp5.so(64行)
   加:AddType application/x-httpd-php .php
   第259行改
   <IfModule dir_module>
DirectoryIndex index.php index.html
   </IfModule>385行
   #AddType application/x-gzip .tgz
AddType application/x-httpd-php .php (添加)

验证连接

验证PHP与Apache连接

vim index.php

  添加:
<?php
phpinfo( );
?>

访问

firefox http://192.168.1.1/

验证PHP与MySQL连接

mv index.php index.php_back
vim index.php

添加:如果分布式部署的话把localhost换成mysql主机ip,并且在mysql上对apache授权
<?php
$link=mysqli_connect('192.168.1.2','root','123.com');                
if($link) echo "恭喜你,数据库连接成功啦!!";                   
?>

注意:MySQL端需要授权

grant all on *.* to 'root'@'192.168.1.1' identified by  '123.com';

访问

[root@localhost htdocs]#firefox http://192.168.1.1/ &

安装phpMyAdmin

[root@localhost ~]#tar -zxvf phpMyAdmin-4.7.2-all-languages.tar.gz -C /usr/src/
[root@localhost ~]#cd /usr/src/
[root@localhost ~]#cp -r phpMyAdmin-4.7.2-all-languages/ /usr/local/httpd/htdocs/phpMyAdmin(自己创建)
[root@localhost ~]#cd /usr/local/httpd/htdocs/phpMyAdmin
[root@localhost ~]#cp config.sample.inc.php config.inc.php 

vim config.inc.php
在这里插入图片描述
修改:
$cfg[‘blowfish_secret’] = ‘a8b7c6d’;
配置文件里添加 创建用户为’root’,设置密码为’123.com’

访问

[root@localhost ~]#firefox http://192.168.1.1/phpMyAdmin &

登录进去后就是mysql图形化界面

天越黑,星星越亮,加油