在LNMP上部署phpMyAdmin

Linux大全评论697 views阅读模式

前言:
    我们已经实现过在lamp架构上部署wordpress博客系统,httpd服务本身支持模块化和fastcgi两种形式连接到php应用(其他方式博主没用过就不提了)。而nginx作为web服务器的话就只能通过fastcgi连接到php应用了。当然,nginx还有一个常用的用处就是作为反向代理,这是后话,以后在提。

正文:
    当web服务承载的用户数量越来越大时,如果我们依然把整个lnmp都部署在一台主机上,肯定是有问题的,所以今天我们直接来实现把nginx,fpm和mysql分别部署在不同的服务器上。我们的环境是有三台CentOS7主机,172.16.53.100部署nginx服务,172.16.53.101部署fpm,172.16.53.102部署mysql。我们现在三个主机上安装相应的程序。

#172.16.53.100
yum install nginx -y
vim /etc/nginx/nginx.conf                    把默认配置先注释掉~不然影响测试。
#    server {
#        listen      80 default_server;
#        listen      [::]:80 default_server;
#        server_name  _;
#        root        /usr/share/nginx/html;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#              root /var/nginx;
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    } 
vim /etc/nginx/            创建一个单独的配置文件
server {
        listen 80;                                监听所有接口的80端口
        server_name           
        location  / {
                root /var/nginx/phpMyAdmin;      静态文件存放的位置
                index index.php;                  自动加载index.php的主页文件
        }
        location ~ \.php$ {                        设置动态php文件去172.16.53.101找
                fastcgi_pass 172.16.53.101:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /var/nginx/phpMyAdmin/$fastcgi_script_name;
                include fastcgi_params;
        }

systemctl start nginx
iptable -vnL                              清空防火墙规则

#172.16.53.101
yum install php-fpm php php-mysql  php-mbstring -y 
分别是fastcgi模块,php环境 连接mysql的模块 中文支持模块
vim /etc/php-fpm.d/
listen 0.0.0.0:9000                      监听所有端口
listen.allowed_clients = 172.16.53.100  运行100主机的访问
mkdir /var/nginx                    我们在此目录下放php程序,请自行下载phpMyAdmin程序
cd /var/nginx
unzip phpMyAdmin-4.4.14.1-all-languages.zip            解压
mv phpMyAdmin-4.4.14.1-all-languages phpMyAdmin        重命名
cp config.sample.inc.php config.inc.php                以默认的配置文件得到我们需要的配置文件
vim config.inc.php                                修改配置文件,只用修改一条。
    $cfg['Servers'][$i]['host'] = '172.16.53.102';  要管理的数据库ip地址。
systemctl start php-fpm
iptable -vnL                              清空防火墙规则

#172.16.53.102
yum install mariadb-server
systemctl start mariadb
mysql                      用mysql命令连接到本地数据库
mysql>grant all on *.* to 'root'@'172.16.%.%' identified by '1234';  设置允许同网段的ip,连接到数据库。
iptable -vnL                              清空防火墙规则

企鹅博客
  • 本文由 发表于 2019年9月8日 13:19:22
  • 转载请务必保留本文链接:https://www.qieseo.com/168932.html

发表评论