lamp分离部署

很多人在搭建的时候都是使用的一台机器来部署LAMP环境,但是我们在实际的工作中一般都是分离部署的。也就是说apache、mysql、php都在单独的一台服务器伤,分离部署自己跑自己的服务,提高效率!

环境说明

系统 服务 IP地址
centos7 Apache 192.168.32.125
centos7 Mysql 192.168.32.130
centos7 PHP 192.168.32.135

三台服务器均已关闭防火墙和selinux

1. 安装httpd

  1. //配置YUM源
  2. [root@node-1 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  3. [root@node-1 ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
  4. [root@node-1 ~]# sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
  5. [root@node-1 ~]# yum -y install epel-release wget vim
  6. //安装开发工具包
  7. [root@node-1 ~]# yum groups mark install 'Development Tools'
  8. //[root@node-1 ~]# useradd -r -M -s /sbin/nologin apache
  9. [root@node-1 ~]# id apache
  10. uid=998(apache) gid=996(apache) groups=996(apache)
  11. //安装依赖包
  12. [root@node-1 ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++
  13. //下载和安装apr以及apr-util
  14. [root@node-1 ~]# wget http://mirror.bit.edu.cn/apache/apr/apr-1.7.0.tar.gz
  15. [root@node-1 ~]# wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
  16. [root@node-1 ~]# ls
  17. anaconda-ks.cfg apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz
  18. [root@node-1 ~]# tar xf apr-1.7.0.tar.gz
  19. [root@node-1 ~]# tar xf apr-util-1.6.1.tar.gz
  20. [root@node-1 ~]# cd apr-1.7.0
  21. [root@node-1 apr-1.7.0]# ./configure --prefix=/usr/local/apr
  22. ......
  23. [root@node-1 apr-1.7.0]# make && make install
  24. ......
  25. [root@node-1 apr-1.7.0]# cd ../apr-util-1.6.1
  26. [root@node-1 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
  27. ......
  28. [root@node-1 apr-util-1.6.1]# make && make install
  29. ......
  30. //编译安装httpd
  31. [root@node-1 ~]# cd
  32. [root@node-1 ~]# wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.43.tar.gz
  33. [root@node-1 ~]# tar xf httpd-2.4.43.tar.gz
  34. [root@node-1 ~]# ls
  35. anaconda-ks.cfg apr-1.7.0 apr-1.7.0.tar.gz apr-util-1.6.1 apr-util-1.6.1.tar.gz httpd-2.4.43 httpd-2.4.43.tar.gz
  36. [root@node-1 ~]# cd httpd-2.4.43
  37. [root@node-1 httpd-2.4.43]# ./configure --prefix=/usr/local/apache \
  38. --sysconfdir=/etc/httpd24 \
  39. --enable-so \
  40. --enable-ssl \
  41. --enable-cgi \
  42. --enable-rewrite \
  43. --with-zlib \
  44. --with-pcre \
  45. --with-apr=/usr/local/apr \
  46. --with-apr-util=/usr/local/apr-util/ \
  47. --enable-modules=most \
  48. --enable-mpms-shared=all \
  49. --with-mpm=prefork
  50. [root@node-1 httpd-2.4.43]# make && make install
  51. ......
  52. //安装后配置
  53. [root@node-1 httpd-2.4.43]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
  54. [root@node-1 httpd-2.4.43]# source /etc/profile.d/httpd.sh
  55. [root@node-1 httpd-2.4.43]# ln -s /usr/local/apache/include/ /usr/include/httpd
  56. [root@node-1 httpd-2.4.43]# echo 'MANPATH /usr/local/apache/man' >> /etc/man_db.conf
  57. //取消ServerName前面的注释
  58. [root@node-1 httpd-2.4.43]# sed -i '/#ServerName/s/#//g' /etc/httpd24/httpd.conf
  59. //启动apache
  60. [root@node-1 httpd-2.4.43]# apachectl start
  61. [root@node-1 httpd-2.4.43]# ss -tanl
  62. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  63. LISTEN 0 100 127.0.0.1:25 *:*
  64. LISTEN 0 128 *:22 *:*
  65. LISTEN 0 100 [::1]:25 [::]:*
  66. LISTEN 0 128 [::]:80 [::]:*
  67. LISTEN 0 128 [::]:22
  68. //开机自启
  69. [root@node-1 httpd-2.4.43]# echo '/usr/local/apache/bin/apachectl start' >> /etc/rc.d/rc.local
  70. [root@node-1 httpd-2.4.43]# chmod +x /etc/rc.d/rc.local

2. 安装mysql

  1. //配置yum源
  2. [root@node-2 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  3. [root@node-2 ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
  4. [root@node-2 ~]# sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
  5. [root@node-2 ~]# yum -y install epel-release wget vim
  6. //安装依赖包
  7. [root@node-2 ~]# yum -y install libaio ncurses-devel openssl-devel openssl cmake mariadb-devel
  8. //创建用户和组
  9. [root@node-2 ~]# useradd -r -M -s /sbin/nologin -u 306 mysql
  10. [root@node-2 ~]# id mysql
  11. uid=306(mysql) gid=306(mysql) groups=306(mysql)
  12. //下载二进制格式的mysql软件包
  13. [root@node-2 ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
  14. [root@node-2 ~]# tar xf mysql-5.7.30-linux-glibc2.12-x86_64.tar.gz
  15. [root@node-2 ~]# mv mysql-5.7.30-linux-glibc2.12-x86_64 /usr/local/mysql
  16. [root@node-2 ~]# ls /usr/local/
  17. bin etc games include lib lib64 libexec mysql sbin share src
  18. //修改目录/usr/local/mysql的属主属组
  19. [root@node-2 ~]# chown -R mysql.mysql /usr/local/mysql
  20. [root@node-2 ~]# ll /usr/local/mysql -d
  21. drwxr-xr-x. 9 mysql mysql 129 Jul 12 06:13 /usr/local/mysql
  22. //添加环境变量
  23. [root@node-2 ~]# ls /usr/local/mysql
  24. bin docs include lib LICENSE man README share support-files
  25. [root@node-2 ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
  26. [root@node-2 ~]# . /etc/profile.d/mysql.sh
  27. [root@node-2 ~]# echo $PATH
  28. /usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
  29. //建立数据存放目录
  30. [root@node-2 ~]# mkdir /opt/data
  31. [root@node-2 ~]# chown -R mysql.mysql /opt/data/
  32. [root@node-2 ~]# ll /opt/
  33. total 0
  34. drwxr-xr-x. 2 mysql mysql 6 Jul 12 06:17 data
  35. //初始化数据库
  36. [root@node-2 ~]# /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/opt/data/
  37. 2020-07-12T10:19:29.467353Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  38. 2020-07-12T10:19:29.712488Z 0 [Warning] InnoDB: New log files created, LSN=45790
  39. 2020-07-12T10:19:29.747790Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
  40. 2020-07-12T10:19:29.802550Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 2bef4383-c429-11ea-bf7a-000c29d7d941.
  41. 2020-07-12T10:19:29.803178Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
  42. 2020-07-12T10:19:30.727678Z 0 [Warning] CA certificate ca.pem is self signed.
  43. 2020-07-12T10:19:30.992055Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
  44. //配置mysql
  45. [root@node-2 ~]# ln -sv /usr/local/mysql/include/ /usr/local/include/mysql
  46. ‘/usr/local/include/mysql -> ‘/usr/local/mysql/include/’
  47. [root@node-2 ~]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
  48. [root@node-2 ~]# ldconfig
  49. //生成配置文件
  50. [root@node-2 ~]# cat > /etc/my.cnf <<EOF
  51. [mysqld]
  52. basedir = /usr/local/mysql
  53. datadir = /opt/data
  54. socket = /tmp/mysql.sock
  55. port = 3306
  56. pid-file = /opt/data/mysql.pid
  57. user = mysql
  58. skip-name-resolve
  59. bind-address=0.0.0.0
  60. EOF
  61. //配置服务启动脚本
  62. [root@node-2 ~]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
  63. [root@node-2 ~]# sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /etc/init.d/mysqld
  64. [root@node-2 ~]# sed -ri 's#^(datadir=).*#\1/opt/data#g' /etc/init.d/mysqld
  65. //配置开机自启
  66. [root@node-2 ~]# chkconfig --add mysqld
  67. [root@node-2 ~]# chkconfig --list
  68. Note: This output shows SysV services only and does not include native
  69. systemd services. SysV configuration data might be overridden by native
  70. systemd configuration.
  71. If you want to list systemd services use 'systemctl list-unit-files'.
  72. To see services enabled on particular target use
  73. 'systemctl list-dependencies [target]'.
  74. mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  75. netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
  76. network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
  77. //启动mysql
  78. [root@node-2 ~]# service mysqld start
  79. Starting MySQL. SUCCESS!
  80. [root@node-2 ~]# ss -tanl
  81. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  82. LISTEN 0 100 127.0.0.1:25 *:*
  83. LISTEN 0 80 *:3306 *:*
  84. LISTEN 0 128 *:22 *:*
  85. LISTEN 0 100 [::1]:25 [::]:*
  86. LISTEN 0 128 [::]:22
  87. //修改密码
  88. [root@node-2 ~]# mysql
  89. Welcome to the MySQL monitor. Commands end with ; or \g.
  90. Your MySQL connection id is 2
  91. Server version: 5.7.30 MySQL Community Server (GPL)
  92. Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
  93. Oracle is a registered trademark of Oracle Corporation and/or its
  94. affiliates. Other names may be trademarks of their respective
  95. owners.
  96. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  97. mysql> set password=password('123456');
  98. Query OK, 0 rows affected, 1 warning (0.00 sec)
  99. mysql> flush privileges;
  100. Query OK, 0 rows affected (0.00 sec)
  101. mysql> quit
  102. Bye

3. 安装php

  1. //配置Yum源
  2. [root@node-3 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  3. [root@node-3 ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
  4. [root@node-3 ~]# sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
  5. [root@node-3 ~]# yum -y install epel-release wget vim
  6. //配置php的源
  7. [root@node-3 ~]# wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
  8. [root@node-3 ~]# rpm -Uvh remi-release-7.rpm
  9. [root@node-3 ~]# yum makecache --enablerepo=remi-php74
  10. //安装依赖包
  11. [root@node-3 ~]# yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libicu-devel libjpeg libjpeg-devel libpng libpng-devel openldap-devel pcre-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel mhash mhash-devel gcc gcc-c++ sqlite-devel oniguruma-devel php74-php-mysqlnd
  12. //下载php
  13. [root@node-3 ~]# wget https://www.php.net/distributions/php-7.4.7.tar.xz
  14. //编译安装php
  15. [root@node-3 ~]# tar xf php-7.4.7.tar.xz
  16. [root@node-3 ~]# cd php-7.4.7
  17. [root@node-3 php-7.4.7]# ./configure --prefix=/usr/local/php7 \
  18. --with-config-file-path=/etc \
  19. --enable-fpm \
  20. --enable-inline-optimization \
  21. --disable-debug \
  22. --disable-rpath \
  23. --enable-shared \
  24. --enable-soap \
  25. --with-openssl \
  26. --enable-bcmath \
  27. --with-iconv \
  28. --with-bz2 \
  29. --enable-calendar \
  30. --with-curl \
  31. --enable-exif \
  32. --enable-ftp \
  33. --enable-gd \
  34. --with-jpeg \
  35. --with-png-dir \
  36. --with-zlib-dir \
  37. --with-freetype \
  38. --with-gettext \
  39. --enable-json \
  40. --enable-mbstring \
  41. --enable-pdo \
  42. --with-mysqli=mysqlnd \
  43. --with-pdo-mysql=mysqlnd \
  44. --with-readline \
  45. --enable-shmop \
  46. --enable-simplexml \
  47. --enable-sockets \
  48. --enable-zip \
  49. --enable-mysqlnd-compression-support \
  50. --with-pear \
  51. --enable-pcntl \
  52. --enable-posix
  53. [root@node-3 php-7.4.7]# make -j $(cat /proc/cpuinfo |grep processor|wc -l)
  54. 编译过程略
  55. [root@node-3 php-7.4.7]# make install
  56. 安装过程略
  57. //安装后配置环境变量
  58. [root@node-3 php-7.4.7]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh
  59. [root@node-3 php-7.4.7]# source /etc/profile.d/php7.sh
  60. [root@node-3 php-7.4.7]# which php
  61. /usr/local/php7/bin/php
  62. [root@node-3 php-7.4.7]# php -v
  63. PHP 7.4.7 (cli) (built: Jul 12 2020 18:47:17) ( NTS )
  64. Copyright (c) The PHP Group
  65. Zend Engine v3.4.0, Copyright (c) Zend Technologies
  66. //配置php-fpm
  67. [root@node-3 php-7.4.7]# cp php.ini-production /etc/php.ini
  68. [root@node-3 php-7.4.7]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
  69. [root@node-3 php-7.4.7]# chmod +x /etc/rc.d/init.d/php-fpm
  70. [root@node-3 php-7.4.7]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
  71. [root@node-3 php-7.4.7]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
  72. //编辑php-fpm的配置文件(/usr/local/php7/etc/php-fpm.conf):
  73. //配置fpm的相关选项为你所需要的值:
  74. [root@node-3 php-7.4.7]# vim /usr/local/php7/etc/php-fpm.conf
  75. .....
  76. .....
  77. pm.max_children = 50 ;最多同时提供50个进程提供50个并发服务
  78. pm.start_servers = 5 ;启动时启动5个进程
  79. pm.min_spare_servers = 2 ;最小空闲进程数
  80. pm.max_spare_servers = 8 ;最大空闲进程数
  81. //启动php-fpm,设置开机自启
  82. [root@node-3 php-7.4.7]# service php-fpm start
  83. Starting php-fpm done
  84. [root@node-3 php-7.4.7]# chkconfig --add php-fpm
  85. [root@node-3 php-7.4.7]# chkconfig --list
  86. 注:该输出结果只显示 SysV 服务,并不包含
  87. 原生 systemd 服务。SysV 配置数据
  88. 可能被原生 systemd 配置覆盖。
  89. 要列出 systemd 服务,请执行 'systemctl list-unit-files'
  90. 查看在具体 target 启用的服务请执行
  91. 'systemctl list-dependencies [target]'
  92. netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
  93. network 0:关 1:关 2:开 3:开 4:开 5:开 6:关
  94. php-fpm 0:关 1:关 2:开 3:开 4:开 5:开 6:关
  95. //修改监听的端口
  96. [root@node-3 php-7.4.7]# vim /usr/local/php7/etc/php-fpm.d/www.conf
  97. #修改listen = 127.0.0.1:9000为listen = 0.0.0.0:9000
  98. [root@node-3 php-7.4.7]# service php-fpm restart
  99. Gracefully shutting down php-fpm . done
  100. Starting php-fpm done
  101. [root@node-3 php-7.4.7]# ss -tanl
  102. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  103. LISTEN 0 100 127.0.0.1:25 *:*
  104. LISTEN 0 128 *:9000 *:*
  105. LISTEN 0 128 *:22 *:*
  106. LISTEN 0 100 [::1]:25 [::]:*
  107. LISTEN 0 128 [::]:22 [::]:*

4. 配置apache并部署项目

4.1 启用代理模块

在apache httpd 2.4以后已经专门有一个模块针对FastCGI的实现,此模块为mod_proxy_fcgi.so,它其实是作为mod_proxy.so模块的扩展,因此,这两个模块都要加载,编辑httpd.conf文件,取消以下两行内容的注释:

  • LoadModule proxy_module modules/mod_proxy.so
  • LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
  1. //启用httpd的相关模块
  2. [root@node-1 ~]# sed -i '/proxy_module/s/#//g' /etc/httpd24/httpd.conf
  3. [root@node-1 ~]# sed -i '/proxy_fcgi_module/s/#//g' /etc/httpd24/httpd.conf

4.2 配置虚拟主机

  1. //创建网站存放目录的属主
  2. [root@node-1 ~]# chown -R apache.apache /usr/local/apache/htdocs/
  3. [root@node-1 ~]# ll -d /usr/local/apache/htdocs/
  4. drwxr-xr-x. 2 apache apache 24 Jul 12 05:55 /usr/local/apache/htdocs/
  5. //配置虚拟主机
  6. [root@node-1 ~]# vim /etc/httpd24/httpd.conf
  7. //在配置文件的最后加入以下内容
  8. <VirtualHost *:80>
  9. DocumentRoot "/usr/local/apache/htdocs"
  10. ServerName www.test.com
  11. ProxyRequests Off
  12. ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.32.135:9000/project/$1
  13. <Directory "/usr/local/apache/htdocs">
  14. Options none
  15. AllowOverride none
  16. Require all granted
  17. </Directory>
  18. </VirtualHost>
  19. [root@node-1 ~]# vim /etc/httpd24/httpd.conf
  20. //搜索AddType,添加以下内容
  21. # If the AddEncoding directives above are commented-out, then you
  22. # probably should define those extensions to indicate media types:
  23. #
  24. AddType application/x-compress .Z
  25. AddType application/x-gzip .gz .tgz
  26. AddType application/x-httpd-php .php #添加此行
  27. AddType application/x-httpd-php-source .phps #添加此行
  28. //优先解析php
  29. [root@node-1 ~]# sed -i '/ DirectoryIndex/s/index.html/index.php index.html/g' /etc/httpd24/httpd.conf
  30. //重启apache服务
  31. [root@node-1 ~]# apachectl -t
  32. Syntax OK
  33. [root@node-1 ~]# apachectl restart
  34. [root@node-1 ~]# ss -tanl
  35. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  36. LISTEN 0 100 127.0.0.1:25 *:*
  37. LISTEN 0 128 *:22 *:*
  38. LISTEN 0 100 [::1]:25 [::]:*
  39. LISTEN 0 128 [::]:80 [::]:*
  40. LISTEN 0 128 [::]:22 [::]:*

4.3 部署PbootCMSPHP企业网站开发建设管理系统

在gitee上找的的排行首位的php网站,依次为例

部署PbootCMSPHP企业网站开发建设管理系统

https://gitee.com/hnaoyun/PbootCMS?_from=gitee_search

如果需要启用Mysql版本,请导入目录下数据库文件/static/backup/sql/xxx.sql,同时请注意使用最新日期名字的脚本文件,并修改config/database数据库连接文件信息。

系统后台默认访问路径:http://ip/admin.php 账号:admin 密码:123456,

  1. //gitee上下载软件包(可能需要验证码,请在网页上下载后上传至PHP服务器)
  2. [root@node-3 ~]# mkdir tmp
  3. [root@node-3 ~]# cd tmp/
  4. [root@node-3 tmp]# wget https://gitee.com/hnaoyun/PbootCMS/repository/archive/3.X.zip?ref=3.X&sha=4b8a380276b44bcc37510babea72f1fb7e5e97f6&format=zip&captcha_type=captcha&captcha=msmyaj
  5. [root@node-3 tmp]# ls
  6. hnaoyun-PbootCMS-3.X.zip
  7. [root@node-3 tmp]# unzip hnaoyun-PbootCMS-3.X.zip
  8. hnaoyun-PbootCMS-3.X.zip PbootCMS
  9. [root@node-3 tmp]# cd PbootCMS/
  10. [root@node-3 PbootCMS]# ls
  11. admin.php api.php apps config core data doc favicon.ico index.php LICENSE README.md rewrite robots.txt static template
  12. //将文件移动到虚拟主机配置的访问目录中
  13. [root@node-3 PbootCMS]# mkdir /project
  14. [root@node-3 PbootCMS]# chmod 777 /project #尽量不要给777
  15. [root@node-3 PbootCMS]# mv * /project/
  16. [root@node-3 PbootCMS]# ls /project/
  17. admin.php api.php apps config core data doc favicon.ico index.php LICENSE README.md rewrite robots.txt static template
  18. //将静态目录上传到apache服务器的访问目录
  19. [root@node-3 PbootCMS]# cd /project/
  20. [root@node-3 project]# scp -r static/ 192.168.32.125:/usr/local/apache/htdocs/
  21. The authenticity of host '192.168.32.125 (192.168.32.125)' can't be established.
  22. ECDSA key fingerprint is SHA256:jIyeHFElG0AZhhfDgIPwju+oKhffoopGo6SKfQU+RzY.
  23. ECDSA key fingerprint is MD5:f1:63:f9:6e:9d:e5:4f:33:07:5a:25:40:ee:aa:77:9e.
  24. Are you sure you want to continue connecting (yes/no)? yes
  25. Warning: Permanently added '192.168.32.125' (ECDSA) to the list of known hosts.
  26. root@192.168.32.125's password:
  27. 0cb2353f8ea80b398754308f15d1121e_20200705235534_pbootcms.sql 100% 114KB 20.0MB/s 00:00
  28. logo.png 100% 8240 12.8MB/s 00:00
  29. nopic.png 100% 8209 16.3MB/s 00:00
  30. 1523439379569611.png 100% 107KB 13.2MB/s 00:00
  31. 1523498765110892.jpeg 100% 20KB 24.9MB/s 00:00
  32. 1523498882600766.jpg 100% 16KB 23.5MB/s 00:00
  33. 1523498883237191.png 100% 144KB 45.2MB/s 00:00
  34. ......
  35. [root@node-3 project]# scp -r template/ 192.168.32.125:/usr/local/apache/htdocs/
  36. root@192.168.32.125's password:
  37. swiper.css 100% 22KB 20.4MB/s 00:00
  38. swiper.min.css 100% 19KB 20.8MB/s 00:00
  39. swiper.esm.bundle.js 100% 209KB 58.9MB/s 00:00
  40. swiper.esm.js 100% 210KB 69.9MB/s 00:00
  41. swiper.js 100% 257KB 45.4MB/s 00:00
  42. swiper.min.js 100% 118KB 23.0MB/s 00:00
  43. swiper.min.js.map
  44. ......
  45. [root@node-3 project]# scp -r apps/ 192.168.32.125:/usr/local/apache/htdocs/
  46. root@192.168.32.125's password:
  47. ......
  48. jquery.js 100% 95KB 51.7MB/s 00:00
  49. laydate.js 100% 27KB 26.2MB/s 00:00
  50. layedit.js 100% 12KB 8.1MB/s 00:00
  51. layer.js 100% 22KB 24.3MB/s 00:00
  52. laypage.js 100% 4472 7.3MB/s 00:00
  53. laytpl.js 100% 1836 3.7MB/s 00:00
  54. mobile.js 100% 31KB 37.5MB/s 00:00
  55. ......省略.....
  56. //将数据库文件上传的数据库服务器
  57. [root@node-3 project]# scp static/backup/sql/0cb2353f8ea80b398754308f15d1121e_20200705235534_pbootcms.sql 192.168.32.130:/root/
  58. root@192.168.32.130's password:
  59. 0cb2353f8ea80b398754308f15d1121e_20200705235534_pbootcms.sql 100% 114KB 42.4MB/s 00:00
4.4.1 数据库服务器授权

关于数据库的官方说明:

如果需要启用Mysql版本,请导入目录下数据库文件/static/backup/sql/xxx.sql,同时请注意使用最新日期名字的脚本文件,并修改config/database数据库连接文件信息

  1. 修改config/database数据库连接文件信息
  2. vim查看文件原版配置
  3. [root@node-3 project]# vim config/database.php
  4. <?php
  5. /**
  6. * 主数据库连接参数,未配置的参数使用框架惯性配置
  7. * 如果修改为mysql数据库,请同时修改type和dbname两个参数
  8. */
  9. return array(
  10. 'database' => array(
  11. 'type' => 'sqlite', // 数据库连接驱动类型: mysqli,sqlite,pdo_mysql,pdo_sqlite
  12. 'host' => '127.0.0.1', // 数据库服务器
  13. 'user' => 'pboot', // 数据库连接用户名
  14. 'passwd' => '123456', // 数据库连接密码
  15. 'port' => '3306', // 数据库端口
  16. // 'dbname' => 'pbootcms' // 去掉注释,启用mysql数据库,注意修改前面的连接信息及type为mysqli
  17. 'dbname' => '/data/pbootcms.db' // 去掉注释,启用Sqlite数据库,注意修改type为sqlite
  18. )
  19. );
  20. ###修改后的配置
  21. <?php
  22. /**
  23. * 主数据库连接参数,未配置的参数使用框架惯性配置
  24. * 如果修改为mysql数据库,请同时修改type和dbname两个参数
  25. */
  26. return array(
  27. 'database' => array(
  28. 'type' => 'mysqli', // 数据库连接驱动类型: mysqli,sqlite,pdo_mysql,pdo_sqlite
  29. 'host' => '192.168.32.130', // 数据库服务器
  30. 'user' => 'pboot', // 数据库连接用户名
  31. 'passwd' => '123456', // 数据库连接密码
  32. 'port' => '3306', // 数据库端口
  33. 'dbname' => 'pbootcms' // 去掉注释,启用mysql数据库,注意修改前面的连接信息及type为mysqli
  34. 'dbname' => '/data/pbootcms.db' // 去掉注释,启用Sqlite数据库,注意修改type为sqlite
  35. )
  36. );
  37. //查看数据库文件,找到数据库名,数据库名字为pbootcms
  38. -- Online Database Management SQL Dump
  39. -- 数据库名: pbootcms
  40. -- 生成日期: 2020-07-05 23:55:34
  41. -- PHP 版本: 5.6.33
  42. SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  43. SET time_zone = "+08:00";
  44. SET NAMES utf8;
  45. -- --------------------------------------------------------
  46. --
  47. -- 表的结构 `ay_area`
  48. --
  49. DROP TABLE IF EXISTS `ay_area`;
  50. CREATE TABLE `ay_area` (
  51. `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '区域编号',
  52. `acode` varchar(20) NOT NULL COMMENT '区域编码',
  53. .........以下省略..........
  54. //在数据库服务器上授权用户
  55. [root@node-2 ~]# mysql -uroot -p123456
  56. mysql: [Warning] Using a password on the command line interface can be insecure.
  57. Welcome to the MySQL monitor. Commands end with ; or \g.
  58. Your MySQL connection id is 7
  59. Server version: 5.7.30 MySQL Community Server (GPL)
  60. Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
  61. Oracle is a registered trademark of Oracle Corporation and/or its
  62. affiliates. Other names may be trademarks of their respective
  63. owners.
  64. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  65. mysql> create database pbootcms;
  66. Query OK, 1 row affected (0.02 sec)
  67. mysql> grant all on pbootcms.* to 'pboot'@'192.168.32.135' identified by '123456';
  68. Query OK, 0 rows affected, 1 warning (0.00 sec)
  69. mysql> flush privileges;
  70. Query OK, 0 rows affected (0.00 sec)
  71. mysql> use pbootcms
  72. Database changed
  73. mysql> source 0cb2353f8ea80b398754308f15d1121e_20200705235534_pbootcms.sql
  74. ......
  75. ......
  76. ......
  77. Query OK, 5 rows affected (0.00 sec)
  78. Records: 5 Duplicates: 0 Warnings: 0
  79. Query OK, 0 rows affected, 1 warning (0.00 sec)
  80. Query OK, 0 rows affected (0.00 sec)
  81. Query OK, 1 row affected (0.00 sec)
  82. Query OK, 0 rows affected, 1 warning (0.00 sec)
  83. Query OK, 0 rows affected (0.00 sec)
  84. Query OK, 1 row affected (0.00 sec)
  85. mysql> quit
  86. Bye
  87. #重启各服务
  88. [root@node-1 ~]# apachectl restart
  89. [root@node-1 ~]# ss -tanl
  90. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  91. LISTEN 0 100 127.0.0.1:25 *:*
  92. LISTEN 0 128 *:22 *:*
  93. LISTEN 0 100 [::1]:25 [::]:*
  94. LISTEN 0 128 [::]:80 [::]:*
  95. LISTEN 0 128 [::]:22 [::]:*
  96. [root@node-2 ~]# service mysqld restart
  97. Shutting down MySQL.. SUCCESS!
  98. Starting MySQL. SUCCESS!
  99. [root@node-2 ~]# ss -tanl
  100. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  101. LISTEN 0 100 127.0.0.1:25 *:*
  102. LISTEN 0 80 *:3306 *:*
  103. LISTEN 0 128 *:22 *:*
  104. LISTEN 0 100 [::1]:25 [::]:*
  105. LISTEN 0 128 [::]:22 [::]:*
  106. [root@node-3 project]# service php-fpm restart
  107. Gracefully shutting down php-fpm . done
  108. Starting php-fpm done
  109. [root@node-3 project]# ss -tanl
  110. State Recv-Q Send-Q Local Address:Port Peer Address:Port
  111. LISTEN 0 100 127.0.0.1:25 *:*
  112. LISTEN 0 128 *:9000 *:*
  113. LISTEN 0 128 *:22 *:*
  114. LISTEN 0 100 [::1]:25 [::]:*
  115. LISTEN 0 128 [::]:22 [::]:*
4.4.2 访问网站

4.4.3 登录网站后台

访问后台地址,用户名:admin ,密码:123456

http://192.168.32.125/admin.php

按要求修改密码

修改密码后就可以在后台进行各种调整了

lamp分离部署的更多相关文章

  1. lamp的动静分离部署

    一.lamp分离部署工作图 二.LAMP的安装与配置 1.环境准备 2.对 PHP 服务器进行部署 #以下为安装PHP及其依赖 [root@php ~ ]# .tar.gz -C /usr/src [ ...

  2. 【转】Nginx+php-fpm+MySQL分离部署详解

    转:http://www.linuxidc.com/Linux/2015-07/120580.htm Nginx+php-fpm+MySQL分离部署详解 [日期:2015-07-26] 来源:Linu ...

  3. LAMP应用部署

    LAMP+wordpress 部署博客 软件安装 yum -y install httpd yum -y install php yum -y install php-mysql yum -y ins ...

  4. 001.Amoeba读写分离部署

    一 Amoeba简介 Amoeba(变形虫)项目,该开源框架于2008年 开始发布一款 Amoeba forMysql软件.这个软件致力于MySQL的分布式数据库前端代理层,它主要在应用层访问MySQ ...

  5. LNMP下动静分离部署phpmyadmin软件包

    LNMP环境肯定是先要配置好的.可以参考我之前的博客.那我们直接进行配置,我这里使用了三台机器进行动静分离部署,第一台负责nginx反向代理,第二台负责php-fpm应用程序以及mariadb的服务器 ...

  6. HHvm建站环境搭建方法:Nginx,Mariadb,hhvm及lnmp/lamp安装部署

    HHVM起源于Facebook公司,是一个开源的PHP虚拟机,使用JIT的编译方式以及其他技术,让PHP代码的执行性能大幅提升.HHVM提升PHP性能的途径,采用的方式就是替代Zend引擎来生成和执行 ...

  7. LAMP 一键部署

    LAMP 一键部署 部署http #!/bin/bash ### global variables export lamp_repo=http://192.168.1.5/lamp/ export l ...

  8. windows下Redis 主从读写分离部署

    原文:windows下Redis 主从读写分离部署 1.可直接下载window下的运行文件(下面这个链接) 也可以浏览github 查看相应的版本说明文档 https://github.com/Ser ...

  9. nginx实现前后台分离部署

    2.1         前后台分离部署 (一)       组网图 (二)       简要说明: 如标题所示,至于为什么要前后台分离部署,个人理解的原因有三 (一)   便于部署 前台代码由ngin ...

随机推荐

  1. Linux 字符处理之【grep】

    参数: -i: 不区分大小写 -c: 统计包含匹配的行数 -n: 输出行号 -v: 反向匹配 示例文件: (example.txt) The cat's name is Tom, what's the ...

  2. SpringBoot+Mybatis一级缓存和二级缓存详解

    本文主要介绍在SpringBoot项目中如何使用Mybatis的一级.二级缓存,为了演示方便,本文的数据库采用H2内存数据库,数据库连接池默认使用SpringBoot2.X自带的hikariCP. 正 ...

  3. Springboot下实现阿里云短信验证功能(含代码)

    Springboot下实现阿里云短信验证功能 一 开通阿里云短信服务 阿里云官网注册登录 找到短信服务并开通 打开短信服务的管理台 在国内消息那栏中添加签名管理和模板管理(按照格式要求去写) 在右上角 ...

  4. MobileNetV1/V2/V3简述 | 轻量级网络

    MobileNet系列很重要的轻量级网络家族,出自谷歌,MobileNetV1使用深度可分离卷积来构建轻量级网络,MobileNetV2提出创新的inverted residual with line ...

  5. redis必知会

    Redis 是单进程单线程的? Redis 是单进程单线程的,redis 利用队列技术将并发访问变为串行访问,消 除了传统数据库串行控制的开销. Redis 的持久化机制是什么?各自的优缺点? Red ...

  6. 【其他-小技巧-Uipath】VB语法操作DataTable分组并求和

    需要对DataTable分组求和的语法:VB.net 和C#中还有点不太一样.最后试了好多方法,要这么写 我的dataTabel数据: (From p In dataTabel.AsEnumerabl ...

  7. 公众号迁移 原有数据库openid 更新主体openid

    今天一个两年前做的公众号项目 要更改主体,随之而来的是公众号的迁移. 公众号迁移后关注的粉丝也会对应的进行迁移,还会给粉丝发送相关通知. 大体流程如下图 迁移的具体步骤我就不细说了.今天主要说的是 迁 ...

  8. Python Ethical Hacking - MODIFYING DATA IN HTTP LAYER(3)

    Recalculating Content-Length: #!/usr/bin/env python import re from netfilterqueue import NetfilterQu ...

  9. P1039 侦探推理(洛谷)

    昨天做了一个非常神奇的题,告诉我们做题之前一定要好好检测评测姬! 明明同学最近迷上了侦探漫画<柯南>并沉醉于推理游戏之中,于是他召集了一群同学玩推理游戏.游戏的内容是这样的,明明的同学们先 ...

  10. springAOP的三种实现方式

    springAOP的实现方式 三种 纯XML方式,XML+注解,纯注解方式. Spring 实现AOP思想使⽤的是动态代理技术 默认情况下, Spring会根据被代理对象是否实现接⼝来选择使⽤JDK还 ...