CentOS 7 RPM包方式安装LAMP

细节要求:

(1) 三者分离于两台主机;

(2) 一个虚拟主机用于提供phpMyAdmin;另一个虚拟主机用于提供wordpress;

(3) 提供xcache加速;

(4) 为phpMyAdmin提供https虚拟主机;

一、准备CentOS 7主机环境以及Repo仓库提供基于rpm安装包方式的程序包安装源

安装主机程序包规划:

主机1:web-server(192.168.1.132)–安装httpd、php、php-mysql、Xcache、phpMyAdmin、wordpress

主机2:db-server(192.168.1.200)–安装mariadb-server

二、web-server程序软件安装

image.png

三、db-server程序软件安装

CentOS 7 RPM包方式安装LAMPimage.png

四、具体部署配置

安装完成以后执行各个服务配置。

a、httpd服务配置,创建虚拟主机,指定根文件路径等

  phpMyAdmin虚拟主机名:pma.test.com,资源路径/usr/share/phpMyAdmin/

  wordpress虚拟主机主机名:wordpress.test.com,资源路径/usr/share/wordpress/

查看当前httpd使用的MPM模型

#cat /etc/httpd/conf.modules.d/00-mpm.conf

CentOS 7 RPM包方式安装LAMPimage.png

#httpd -M

CentOS 7 RPM包方式安装LAMPimage.png

默认使用prefork模式;

查看装载PHP装载的模块

#cat /etc/httpd/conf.modules.d/10-php.conf

CentOS 7 RPM包方式安装LAMPimage.png

#httpd -M

CentOS 7 RPM包方式安装LAMPimage.png

已装载libphp5.so;

启动httpd服务进程并添加到开机自动启动服务进程中

CentOS 7 RPM包方式安装LAMPimage.png

查看httpd服务状态

CentOS 7 RPM包方式安装LAMPimage.png

创建虚拟主机配置文件

#vim /etc/httpd/conf.d/virtualhost.conf

<VirtualHost *:80>

    ServerName www.test.com      –用于测试主站点静态资源访问,以及php动态资源访问

    DocumentRoot   /var/www/html     –默认的html资源路径

</VirtualHost>

<VirtualHost *:80>

    Servername wordpress.test.com     –用于测试wordpress程序

    DocumentRoot   /usr/share/wordpress    –默认的wordpress程序资源路径

</VirtualHost>

<VirtualHost *:443>

    Servername phpmyadmin.test.com     –用于测试phpMyAdmin程序

    DocumentRoot   /usr/share/phpMyAdmin    –默认的phpMyAdmin程序资源路径

</VirtualHost>

b、mariadb数据库配置

启动mariadb服务进程,并加入开机自动启动服务列表

CentOS 7 RPM包方式安装LAMPimage.png

确认mariadb服务进程状态

CentOS 7 RPM包方式安装LAMPimage.png

禁用数据库主机名解析

CentOS 7 RPM包方式安装LAMP#echo 'skip_name_resolve = ON'>/etc/my.cnf

为wordpress程序设置远程访问数据库参数

启用数据库远程客户端访问,设置远程访问用户名‘bdtest’,允许远程访问的主机‘192.168.1.0/24’网段,访问密码‘redhat’,允许访问的数据库‘test’

CentOS 7 RPM包方式安装LAMPMariadb[(none)]>grant all privileges on test.* to bdtest@'192.168.1.%' identified by 'redhat';

开放db-server(数据库服务器)运行远程访问mysql服务

CentOS 7 RPM包方式安装LAMP#firewall-cmd –permanent –add-service=mysql

#firewall-cmd –reload

为phpMyAdmin程序设置远程访问数据库参数

#mysql

Mariadb [(none)]>create database 'pma_db';

Mariadb [(none)]>grant all on pma_db.* to pmatest@'192.168.1.%' identified by 'redhat';

c、安装PHP加速引擎xcache

#yum install php-xcache.x86_64 -y

#systemctl reload httpd.service     –重新装载httpd配置

#通过调用phpinfo()参数显示xcache已启用

CentOS 7 RPM包方式安装LAMPimage.png

d、web-server中配置wordpress程序参数

设置配置文件/etc/wordpress/wp-conf.php,修改与db-server通讯的参数

CentOS 7 RPM包方式安装LAMPimage.png

修改wordpress资源访问权限:/etc/httpd/conf.d/wordpress.conf

CentOS 7 RPM包方式安装LAMPimage.png

针对httpd2.2和2.4不同版本修改原有默认的local本地访问权限,允许all访问,另外如果允许用户上传内容,也可以设置相应参数,目前保留默认设置

CentOS 7 RPM包方式安装LAMPimage.png

通过浏览器访问http://wordpress.test.com,进行首次安装配置界面

CentOS 7 RPM包方式安装LAMPimage.png

初始化安装成功以后,弹出登录界面

CentOS 7 RPM包方式安装LAMPimage.png

输入登录账户信息以后,显示wordpress使用界面如下

CentOS 7 RPM包方式安装LAMPimage.png

查看后台mariadb数据库,显示test数据库新建立了如下表单信息

CentOS 7 RPM包方式安装LAMPimage.png

以上完成wordpress软件安装与配置

e、配置mod_ssl协议模块

#yum install -y mod_ssl    –安装ssl模块

#(umask 077;openssl genrsa -out /etc/pki/CA/private/cakey.pem 2048)   –已web-server作为CA授权服务器,先创建本机私钥

#openssl req -new -x509 -key /etc/pki/CA/private/cakey.pem -out /etc/pki/CA/cacert.pem -days 365    –通过交互式界面生成请求并自签名CA服务器证书

#touch /etc/pki/CA/{index.txt,serial}   –创建CA目录下的文件index.txt(证书数据库索引)以及serial(证书序列号文件)

#echo '01' > /etc/pki/CA/serial      –将刚才自签名发布的首张服务器证书作为01标号记录在serial文件中

#openssl req -new -key /etc/pki/CA/cakey.pem -out ./myserver.csr -days 180   –以本机作为web-server服务器向CA服务器申请签发证书请求

#openssl ca -in ./myserver.csr -out /etc/pki/CA/certs/web-server.cert -days 180    –CA签发web-sever服务器的证书申请,生成web-server服务器证书

#vim /etc/httpd/conf.d/ssl.conf     –修改web-server服务器证书,web-server服务器私钥证书,CA服务器证书所在路径的参数配置

#systemctl reload httpd.service      –重新加载httpd配置文件

f、安装部署phpMyAdmin程序

#yum install -y phpMyAdmin

#vim /etc/httpd/conf.d/phpMyAdmin.conf    –修改PMA程序配置文件

<Directory /usr/share/phpMyAdmin/>

   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>

     # Apache 2.4

     <RequireAny>

       Require all granted

     </RequireAny>

   </IfModule>

   <IfModule !mod_authz_core.c>

     # Apache 2.2

     Order Deny,Allow

     Allow from All

   </IfModule>

</Directory>

<Directory /usr/share/phpMyAdmin/setup/>

   <IfModule mod_authz_core.c>

     # Apache 2.4

     <RequireAny>

      Require all granted

     </RequireAny>

   </IfModule>

   <IfModule !mod_authz_core.c>

     # Apache 2.2

     Order Deny,Allow

        Allow from all

   </IfModule>

</Directory>

#vim /etc/phpMyAdmin/config.inc.php       –编辑PMA配置文件,定义与mariadb数据库相关的参数

$cfg['Servers'][$i]['host']          = '192.168.1.200'; // MySQL hostname or IP address

$cfg['Servers'][$i]['user']          = 'pmatest';          // MySQL user

$cfg['Servers'][$i]['password']      = 'redhat';          // MySQL password (only needed

                                                    // with 'config' auth_type)

测试访问PMA站点

CentOS 7 RPM包方式安装LAMPimage.png

输入访问mariadb数据的用户名,密码(config.inc.php配置脚本中填写的账户信息貌似没有效果),提交后显示相应的数据库信息

CentOS 7 RPM包方式安装LAMPimage.png

以上是基于RPM包安装方式执行的LAMP部署步骤。

原创文章,作者:N24_shishen,如若转载,请注明出处:http://www.178linux.com/68802

(0)
N24_shishenN24_shishen
上一篇 2017-02-16 00:47
下一篇 2017-02-16 10:37

相关推荐

  • LVS+keepalived高可用web集群搭建的疑惑

    参考文章是这一份:http://ox0spy.github.io/debian/2014/06/26/setup-lvs-and-keepalived-on-debian/ 一:操作系统与ip               ip地址形式:19…

    Linux干货 2016-02-14
  • 系统启动和内核管理以及几个重要实验

    Centos启动流程:     1.加载BIOS的硬件信息,获取第一个启动设备     2.读取第一个启动设备MBR的引导加载程序(grub)的启动信息     3.加载核心操作系统的核心信息,核心开始解压缩,并尝试驱动所有的硬件设备 &n…

    Linux干货 2017-05-15
  • N_28 正则表达式的一些基本用法

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。 ~]# cp -r /etc/skel /home/tuser1 ~]# chmod -R -g— -o— /home/tuser1 2、编辑/etc/group文件,添加组hadoop。 ~]#vi…

    Linux干货 2017-12-23
  • 什么叫Linux

    什么叫linux:     Linux是一套免费使用和自由传播的类Unix操作系统,它主要用于基于Intel x86系列CPU的计算机上。这个系统是由全世界各地的成千上万的程序员设计和实现的。其目的是建立不受任何商品化软件的版权制约的、全世界都能自由使用的Unix兼容产品。 谁编写的linux: Linux的出现,最早…

    Linux干货 2017-03-27
  • Redis集群明细文档

    Redis目前版本是没有提供集群功能的,如果要实现多台Redis同时提供服务只能通过客户端自身去实现(Memchached也是客户端实现分布式)。目前根据文档已经看到Redis正在开发集群功能,其中一部分已经开发完成,但是具体什么时候可以用上,还不得而知。文档来源:http://redis.io/topics/cluster-spec 一、介绍   该文档是…

    Linux干货 2015-04-04
  • 在VMware Workstation上安装CentOS 7

    1.新建虚拟机设备设置 2.开启此虚拟机,进行安装设置    需设置4处  时间,SOFTWARE SELECTION,分区,NETWORK & HOST NAME    (1) 首先 时间设置,选中上海时间,设置现在的Windows时间,设置好后,点击Done退出。(下面同意Done保存退…

    2017-07-15

评论列表(1条)

  • luoweiro
    luoweiro 2017-02-23 07:28

    过程详细,不过如果在大家apache的时候能稍微介绍一下不同工作模式差异会更好。