• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

三台主机搭建LAMP(apache、mariadb、php)

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

实验环境:均是CentOS7

httpd:172.16.254.88   2.4.6

PHP:172.16.250.140 5.4.16

mariadb:172.16.250.94  5.5.52

第三方应用程序是:phpMyAdmin

1、先配置httpd主机:

[root@www localhost]#cd /etc/httpd/conf.d/
[[email protected] localhost]#cat vhost.conf 
DirectoryIndex index.php
<VirtualHost 172.16.254.88:80>
    ServerName  172.16.254.88
    DocumentRoot "/data/www"
    ProxyRequests Off        #关闭正向代理
    ProxyPassMatch ^/(.*\.php)$ fcgi://172.16.250.140:9000/data/www/$1    #表示后缀名为php的动态资源请求的时候转发到ip为172.16.250.140的主机进行处理;
    ProxyPassMatch ^/(pmstatus|ping.*)$ fcgi://172.16.250.140:9000/$1    #测试pmstatus和ping的内置功能
    <Directory "/data/www">
        Options FollowSymLinks
        AllowOverride None
        Require all granted 
    </Directory>
    KeepAlive On
    MaxKeepAliveRequests 100
    KeepAliveTimeout 15
ErrorLog /var/log/httpd/test_error.log
CustomLog /var/log/httpd/test_access.log combined 
</VirtualHost>

 

[[email protected] localhost]#cd /data/www    #网页文件和第三方程序的路径,与PHP服务器上的文件一模一样
[root@www localhost]#ls
index1.php  index.php  phpMyAdmin-4.0.10.20  pma
[root@www localhost]#ll
total 12
-rw-r--r--. 1 root root   13 Jun  3 20:48 index1.php
-rw-r--r--. 1 root root  261 Jun  3 23:35 index.php
drwxr-xr-x. 9 root root 4096 Jun  3 23:18 phpMyAdmin-4.0.10.20
lrwxrwxrwx. 1 root root   21 Jun  4 00:10 pma -> phpMyAdmin-4.0.10.20/  #程序文件的软连接,方便访问
[root@phpMyAdmin-4.0.10.20 localhost]#pwd
/data/www/phpMyAdmin-4.0.10.20
[[email protected] localhost]#cp -av config.sample.inc.php config.inc.php
$cfg['blowfish_secret'] = 'jngkasfnysagfehfcsdkjdfa8b6d'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */  
##添加一些字符串
$cfg['Servers'][$i]['host'] = '172.16.250.94';  #配成mariadb的地址
[root@www localhost]#pwd
/data/www [root@www localhost]#cat index.php <html> <title>test</title> <body> <h2> CentOS7 Text</h2> <?php phpinfo(); ?> </body> </html>

 

[root@libraries localhost]#pwd
/data/www/phpMyAdmin-4.0.10.20/libraries
  * MySQL hostname or IP address
  *
  * @global string $cfg['Servers'][$i]['host']
  */
 $cfg['Servers'][$i]['host'] = '172.16.250.94';  ##修改mariadb的地址

 

2、PHP主机:

[root@www localhost]#yum install -y php php-fpm php-mysql
[root@www localhost]#cd /etc/php-fpm.d/
[root@php-fpm.d localhost]#cat www.conf
; Start a new pool named 'www'.
[www]

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 172.16.250.140:9000    #本服务器地址

; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: -1
;listen.backlog = -1
 pm.status_path = /pmstatus  #测试本服务器的进程状态

  ping.path = /ping    #ping的测试

  ping.response = pong  #pong的回应,测试服务器的通讯状态


curity feature and should be used whenever 
;       possible. However, all PHP paths will be relative to the chroot
;       (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot = 
 
; Chdir to this directory at the start. This value must be an absolute path.
; Default Value: current directory or / when chroot
chdir = /data/www    #第三方程序存放目录和httpd的/data/www中的文件一模一样

; Set session path to a directory owned by process user
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session

3、mariadb主机:

[root@~ localhost]#yum -y install mariadb-server
[[email protected] localhost]#pwd
/etc/my.cnf.d
[[email protected] localhost]#cat server.cnf 
#
# this is only for the mysqld standalone daemon
[mysqld]
skip_name_resolve=ON
innodb_file_per_table=ON

 

#给用户授权连接,同样的给httpd的用户也要授权
[[email protected] localhost]#mysql -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 3 Server version: 5.5.52-MariaDB MariaDB Server Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.250.94' IDENTIFIED BY '123456';

最后测试展示:输入

http://172.16.254.88/pma/index.php

输入:http://172.16.254.88/pmstatus

输入:http://172.16.254.88/

输入:http://172.16.254.88/ping

 

  


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP autoload机制详解发布时间:2022-07-10
下一篇:
10个值得深思的PHP面试问题发布时间:2022-07-10
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap