CentOS7LAMP部署流程

(1)配置概要:
  1、 172.18.17.7主机运行httpd+php服务(php为模块工作模式)
  配置两台虚拟主机:wordpress个人博客系统、PHPmyadmin远程控制mysql

2、172.18.17.8主机运行mariadb服务(mysql)

(2)配置流程:

首先配置172.18.17.7主机:http服务           
  1、安装程序:

[[email protected]‘s linux ~]# yum install httpd php php-mysql php-mbstring

========================================================================================
 Package               Arch            Version                      Repository     Size
========================================================================================
Installing:
 httpd                 x86_64          2.4.6-40.el7.centos          base          2.7 M
 php                   x86_64          5.4.16-36.el7_1              base          1.4 M
 php-mbstring          x86_64          5.4.16-36.el7_1              base          503 k
 php-mysql             x86_64          5.4.16-36.el7_1              base           99 k

Transaction Summary
=======================================================================================

httpd:提供web服务

php:安装后自动编译为httpd的模块,用于处理动态资源php脚本

php-mbstring:此程序包为phpMyAdmin远程控制mysql所必须的

php-mysql:php驱动mysql的库文件程序包

2、服务配置

包都安装完成之后,进入下一步的配置阶段:

(1)添加虚拟主机:(基于FQDN)

虚拟主机有三种配置方式:一种是基于不同ip,相同端口(80),二是相同IP不同端口,三是同一IP不同主机名(FQDN),不管何种配置方式,最后解析到的主机只有一台,但是在请求报文首部信息会有不同!以下,仅演示基于FQDN的配置方式

编辑:/etc/httpd/conf.d/vhost.conf文件

[[email protected]‘s linux ~]# vim /etc/httpd/conf.d/vhost.conf 
# 添加如下内容,基于FQDN的虚拟主机配置
<VirtualHost 172.18.17.7:80>  # 固定语法 <VirtualHost ip:port>可忽略大小写
    ServerName   # 很重要,基于FQDN的虚拟主机必须要有主机名  
    DocumentRoot "/www/host/htdoc" # 虚拟主机根目录,可指定路径 
<Directory "/www/host/htdoc">   # 对虚拟主机根目录的权限设置
    Options FollowSymLinks    # FollowSymLinks  表示可以访问符号连接资源
    require all Granted     # 目录的权限设置
</Directory>               
</VirtualHost>

<VirtualHost 172.18.17.7:80>
    ServerName www.myadmin.com
    DocumentRoot "/www/host2/htdoc"
<Directory "/www/host2/htdoc">
    Options FollowSymLinks
    require all Granted
</Directory>
</VirtualHost>

Options:为个目录的选项,可以指定多个特性

如:Index,启动资源索引,其作用是在用户在访问指定的URL不存在时,返回web资源索引,此选项

非常危险,不建议启用,否则源码则会web源码暴露,后果很严重

访问权限设定:

Require all Granted/deny, Granted表示允许,all表示所有,deny表示拒绝

需要注意的是:CentOS7是默认拒绝所有主机访问DocumentRoot的资源,所以,配置虚拟主机必须要配置此先参数

(2)为虚拟主机创建配置文件中定义的资源目录并

[[email protected]‘s linux ~]# mkdir/www/{host,host2}/htdoc

(3)添加测试资源

[[email protected]‘s linux ~]# vim /www/host/htdoc/index.php
# 前面这段是测试php与mysql连通性的PHP代码
<?php
    $conn = mysql_connect(‘172.18.17.8‘,‘admin‘,‘admin‘); # ip填写mysql主机ip
    if ($conn)                                          # 用户为mysql所授权的用户,密码空
        echo "DATABASE Connet OK";
    else
        echo "DATABASE Connet Failure";
?>
# 测试php是否正常工作的php代码
<?php
    phpinfo() #此函数调用会显示php的详细信息
?>

(4)配置httpd主配置文件

编辑:/etc/httpd/conf/httpd.conf

[[email protected]‘s linux ~]# vim /etc/httpd/conf/httpd.conf
# 找到 DocumentRoot "/var/www/html" ,#将其注释掉,一般使用虚拟机都要注释掉,避免冲突
#DocumentRoot "/var/www/html"

# 添加php主页索引
DirectoryIndex index.php index.html # 将index.php添加在前头,这样就会默认访问此类资源索引

# 取消服务器名称注释

(5)启动服务,测试是否正常

# 检测配置文件语法有没有错误
[[email protected]‘s linux ~]# httpd -t
# 语法无误启动服务
[[email protected]‘s linux ~]# systemctl start httpd.service

打开网页查看服务是否正常   

http服务测试正常,php模块也能正常工作,但是,如你所见,mysql的连接是失败,因为我们还mysql的服务器还没有配置

(5)获取wordpress和phpmyadmin

博主的是在局域网中ftp服务器中下载的

wordpress配置:

# 下载并解压至/www/host/htdoc
# cd 到wordpress目录 ,配置文件如下
[[email protected]‘s linux wordpress]# ls
index.php        wp-blog-header.php    wp-cron.php        wp-mail.php
license.txt      wp-comments-post.php  wp-includes        wp-settings.php
readme.html      wp-links-opml.php     wp-signup.php
wp-activate.php  wp-config-sample.php  wp-load.php        wp-trackback.php
wp-admin         wp-content            wp-login.php       xmlrpc.php

# 复制配置文件以上的 wp-config-sample.php 为 wp-config.php
[[email protected]‘s linux wordpress]# cp wp-config-sample.php  wp-config.php

# 编辑配置文件
[[email protected]‘s linux wordpress]# vim wp-config.php
// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress数据库的名称 */
define(‘DB_NAME‘, ‘wpdb‘);  # 此填写mysql所要授权数据库的名字(后面会配置)

/** MySQL数据库用户名 */

define(‘DB_USER‘, ‘wpuser‘); # 填写数据库的用户名

/** MySQL数据库密码 */
define(‘DB_PASSWORD‘, ‘wppasswd‘); # 填写数据的密码

/** MySQL主机 */
define(‘DB_HOST‘, ‘172.18.17.8‘); # 填写mysql主机的ip

/** 创建数据表时默认的文字编码 */
define(‘DB_CHARSET‘, ‘utf8‘);

/** 数据库整理类型。如不确定请勿更改 */
define(‘DB_COLLATE‘, ‘‘);

phpmyadmin配置:

# 将包下载并解压至/www/host2/htdoc
# cd 到 文件目录
# 创建符号连接
[[email protected]‘s linux htdoc]# ln -s phpMyAdmin-4.4.14.1-all-languages myadmin
[[email protected]‘s linux htdoc]# ls
index.php  phpMyAdmin-4.4.14.1-all-languages 
myadmin    phpMyAdmin-4.4.14.1-all-languages.zip  

#cd 至myadmin 目录里面,修改配置文件
[[email protected]‘s linux htdoc]# cp config.sample.inc.php config.inc.php

#编辑配置文件
[[email protected]‘s linux htdoc]# vim config.inc.php
$cfg[‘blowfish_secret‘] = ‘o71mI9rimj6syc00fT3g‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
                #单引号填写随机密码,可使用openssl rand -base64 15(密码长度)生成
                        
/*
 * Servers configuration
 */
$i = 0;

/*
 * First server
 */
$i++;
/* Authentication type */
$cfg[‘Servers‘][$i][‘auth_type‘] = ‘cookie‘;
/* Server parameters */
$cfg[‘Servers‘][$i][‘host‘] = ‘172.18.17.8‘;  # 数据库主机ip 
$cfg[‘Servers‘][$i][‘connect_type‘] = ‘tcp‘;
$cfg[‘Servers‘][$i][‘compress‘] = false;
$cfg[‘Servers‘][$i][‘AllowNoPassword‘] = false;




172.18.17.8主机配置:mysql服务

(1)yum安装程序

[[email protected]‘s linux ~]# yum install mariadb-server

========================================================================================
Installing:
 mariadb-server               x86_64      1:5.5.44-2.el7.centos         base       11 M
Installing for dependencies:
 mariadb                      x86_64      1:5.5.44-2.el7.centos         base      8.9 M
 perl-Compress-Raw-Bzip2      x86_64      2.061-3.el7                   base       32 k
 perl-Compress-Raw-Zlib       x86_64      1:2.061-4.el7                 base       57 k
 perl-DBD-MySQL               x86_64      4.023-5.el7                   base      140 k
 perl-DBI                     x86_64      1.627-4.el7                   base      802 k
 perl-IO-Compress             noarch      2.061-2.el7                   base      260 k
 perl-Net-Daemon              noarch      0.48-5.el7                    base       51 k
 perl-PlRPC                   noarch      0.2020-14.el7                 base       36 k

Transaction Summary
========================================================================================

一大推依赖包,只要有yum在且yum源配置没有问题,可以轻松解决

(2)启动服务,执行安全安装操作

[[email protected]‘s linux ~]# systemctl start mariadb
# 查看监听端口,3306为mariaDB的默认监听端口
[[email protected]‘s linux ~]# ss -tnl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN     0      50               *:3306                         *:*                  
LISTEN     0      128              *:22                           *:*                  
LISTEN     0      128             :::22                          :::*   

执行安全安装操作  
[[email protected]‘s linux ~]# mysql_secure_installation 

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y  # 设置管理员登陆秘密(此密码和linux系统的root没关系)

New password: 
Re-enter new password:    # 输入密码即可
Password updated successfully!
Reloading privilege tables..
 ... Success!

Remove anonymous users? [Y/n] y  # 是否移除匿名用户(在执行安全安装之前不需要密码登陆)
 ... Success!                    # 允许匿名登陆时很危险的,建议移除

Disallow root login remotely? [Y/n] n  # 是否不允许管理员账号远程登陆,一般情况下建议不允许
 ... skipping.                        

Remove test database and access to it? [Y/n] y # 移除测试数据库
 - Dropping test database... 
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y    # 重载权限表
 ... Success!

Cleaning up...

All done!  If you‘ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

强烈建议在mariaDB安装完成后执行安全安装操作,这样可以使得数据库更安全

(3)创建所需数据库并授权

[[email protected]‘s linux ~]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 66
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE wpdb; # 创建wordpress的数据库
Query OK, 1 row affected (0.02 sec)   

# 授权wordpress数据库
MariaDB [(none)]> GRANT ALL ON wpdb.* TO [email protected] IDENTIFIED BY ‘wppasswd‘;
Query OK, 0 rows affected (0.01 sec)

#授权远程访问主机(phpMyadmin)
MariaDB [(none)]> GRANT ALL ON *.* TO [email protected]‘172.18.17.7‘ IDENTIFIED BY ‘admin‘; 
Query OK, 0 rows affected (0.01 sec)

(4)支持所有配置基本完毕:验证结果

1、验证数据库联通

2、查看wordpress是否正常

不知为何,我的phpmyadmin显示不大正常,能跑起来就行!配置到此结束!

最后补充一下:             
phpMyadmin常见错误:
    1.缺少mbstring插件

yum 安装php-mbstring即可

2.丢失session目录

一般 在/var/lib/php/session ,没有则创建即可

时间: 2024-08-06 15:42:33

CentOS7LAMP部署流程的相关文章

OpenStack Swift集群部署流程与简单使用

转载:http://www.cnblogs.com/fczjuever/p/3224022.html 之前介绍了<OpenStack Swift All In One安装部署流程与简单使用>,那么接下来就说一说Swift集群部署吧. 1. 简介 本文档详细描述了使用两台PC部署一个小型Swift集群的过程,并给出一些简单的使用实例.本文档假定如下前提条件: 使用Ubuntu操作系统. 每台机器都运行Swift的所有服务,既是Proxy Server,又是Storage Server,用户可以向

activiti自定义流程之Spring整合activiti-modeler5.16实例(四):部署流程定义

注:(1)环境搭建:activiti自定义流程之Spring整合activiti-modeler5.16实例(一):环境搭建        (2)创建流程模型:activiti自定义流程之Spring整合activiti-modeler5.16实例(二):创建流程模型        (3)流程模型列表展示:activiti自定义流程之Spring整合activiti-modeler5.16实例(三):流程模型列表展示 1.maven导包及spring的一些基本配置与之前的没有什么变化,依旧沿用就

activiti自定义流程之整合(四):整合自定义表单部署流程定义

综合前几篇博文内容,我想在整合这一部分中应该会有很多模块会跳过不讲,就如自定义表单的表单列表那一块,因为这些模块在整合的过程中都几乎没有什么改动,再多讲也是重复无用功. 正因为如此,在创建了流程模型之后,模型列表的展示也是和之前的没有什么区别,而且都是很简单的后台查询以及前台展示,这一部分也就不过多的讲了. 模型列表页面如下: 至于其中的修改和删除也没什么多讲的,删除很简单,而修改也是activiti-modeler实现的主要功能,我们只需要跳转过去就行. 重要的部分在于部署,因为点击部署到达后

2017.2.28 activiti实战--第五章--用户与组及部署管理(二)部署流程资源

学习资料:<Activiti实战> 第五章 用户与组及部署管理(二)部署流程资源 内容概览:讲解流程资源的读取与部署. 5.2 部署流程资源 5.2.1 流程资源 流程资源常用的有以下几种: 1 流程定义文件:拓展名为bpmn20.xml和bpmn 2 流程定义的图片:拓展名为PNG 3 表单文件:拓展名为form 4 规则文件:拓展名为drl 部署流程资源的时候,要注意一点: 引擎会根据不同的拓展名进行不同的处理.bpmn或bpmn20.xml类型的文件,会在ACT_RU_PROCDEF(流

activiti自己定义流程之整合(四):整合自己定义表单部署流程定义

综合前几篇博文内容.我想在整合这一部分中应该会有非常多模块会跳过不讲,就如自己定义表单的表单列表那一块,由于这些模块在整合的过程中都差点儿没有什么修改,再多讲也是反复无用功. 正由于如此,在创建了流程模型之后.模型列表的展示也是和之前的没有什么差别.并且都是非常easy的后台查询以及前台展示.这一部分也就只是多的讲了. 模型列表页面例如以下: 至于当中的改动和删除也没什么多讲的,删除非常easy,而改动也是activiti-modeler实现的主要功能.我们仅仅须要跳转过去即可. 重要的部分在于

Activiti 部署流程定义及相关的表(classpath部署、zip部署)

package com.mycom.processDefinition; import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngines; import org.activiti.engine.repository.Deployment; import org.junit.Test; public class ProcessDefinitionTest { ProcessEngine proc

Rails 应用使用 Capistrano2 部署流程

Capistrano 2 首次部署流程 修改 config/deploy.rb 和 config/deploy/production.rb bundle exec cap production deploy:setup bundle exec cap production deploy:check bundle exec cap production deploy:cold 配置 Nginx ln -s /opt/app/ruby/aaa-cms/current/config/nginx.con

inotify+rsync及sersync部署流程

inotify+rsync部署流程: 第一步:完成部署rsync守护进程服务 第二步:确认inotify软件是否安装扩展yum源(扩展的仓库):epel(企业级linux的yum源的扩展仓库)? 阿里云epel源:通过访问阿里yum源镜像地址获取? 直接安装epel源方式:yum install epel-releaseyum install inotify-tools -y/usr/bin/inotifywait --- 开启实时监控服务,监控目录或文件的数据变化/usr/bin/inotif

git开发部署流程

Git 开发部署流程 采用业界成熟方案 Git Flow 分支方式进行开发:一个经典的 Git 开发/部署流程包括几个环境:本地开发环境.线上测试环境.线上生产环境,分别对应git的本地工作环境.develop 分支.master 分支 无图言屌 本地开发环境 : 本地仓库分支工作环境 线上测试环境 : 远程 develop 分支 线上生产环境 : 远程 master 分支 先在本地进行开发,做一次完整的提交 push 到 develop 分支,进行线上测试,一切正常 push 到 master