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
下一篇 2017-02-16

相关推荐

  • Kickstart

    1、安装所需软件包  yum -y install createrepo mkisofs isomd5sum 上传centos6.9原始镜像内容 mkdir /mnt/centos   创建挂载目录 mount -o loop centos6.9 /mnt/centos   上传centos6.9镜像并且挂载至centos目录 mkdir /tmp/iso …

    2018-03-26
  • N26-第十三周

    1、建立samba共享,共享目录为/data,要求:(描述完整的过程)  1)共享名为shared,工作组为magedu;  2)添加组develop,添加用户gentoo,centos和ubuntu,其中gentoo和centos以develop为附加组,ubuntu不属于develop组;密码均为用户名;  3)添加samb…

    Linux干货 2017-06-01
  • 第一周:Linux基础及哲学思想

    1.现代计算机的组成及功能    现代计算机由运算器、控制器、存储器、输入和输出设备5大部分组成。分别担当着计算机的计算,控制,存储,输入和输出等功能. 2.Linux的发行版及其之间的联系与区别     Linux发行版主要分支分为三大系列: Slackware、debian 、redhat  &…

    Linux干货 2016-06-23
  • 第二周作业

    第二周博客作业 1. Linux上常用的文件管理命令及使用 (1) CP命令:复制文件或文件夹语法格式        cp [OPTION]… [-T] SOURCE DEST     …

    Linux干货 2016-12-16
  • Week9’s homework

    Week9's homework 1、写一个脚本(1)判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin)(2)分别统计两类用户的个数;通过字符串比较来实现。 #!/bin/bash # for i in $(cat /etc/passwd |…

    Linux干货 2016-12-24
  • day6总结

    主要内容: useradd与usermod对比 groupadd与groupmod对比 passwd与chage对比 gpasswd与groupmems对比 切换用户 chown与chgrp用法 一般权限与特殊权限 chmod用法   useradd创建用户的初始信息存放在/etc/login.defs和/etc//default/useradd文…

    系统运维 2016-08-08

评论列表(1条)

  • luoweiro
    luoweiro 2017-02-23 07:28

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