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

相关推荐

  • zabbix+grafana ——小于初始,大于勤拙@时雨扰扰,几多怅惘,几多忧思

    前边一点小总结,纯属回顾启动大脑所用,毕竟we are no computer! 一个监控系统必须包括4个功能 1)采集数据 2)存储数据 3)故障报警 4)数据可视化显示 zabbix作为一个监控系统,当让也就包含了以上四种zabbix-server-mysql,zabbix-agent,zabbix-get,zabbix-sender,zabbix-we…

    2017-10-09
  • 计算机相关简介和linux相关简介

    一、计算机相关简介与linux的一些概念 计算机系统 由硬件(Hardware)系统和软件(Software)系统两大部分构成: 硬件系统 :CPU(控制器、运算器),内存储器(RAM、ROM),外存储器(硬盘等),输入设备(键盘、鼠标等),输出设备(显示器等),其他设备相关设备。  软件系统 :系统软件(操作系统,数…

    Linux干货 2017-02-18
  • linux进程管理

    进程概念 内核的功用:进程管理、文件系统、网络功能、内存管理、驱动程序、 安全功能等 Process:  运行中的程序的一个 副本,是被 载入内存的一个指令集合     进程ID (Process ID,PID)号码被用来标记各个进程  &…

    Linux干货 2016-09-12
  • 基于samba服务的wordpress站点

    实验要求:             (1) samba server导出/data/app/web,在目录中提供wordpress;     (2) samba  client挂载nfs server导出的文件…

    2017-06-08
  • hbase安装配置(整合到hadoop)

    1.  快速单击安装 在单机安装Hbase的方法。会引导你通过shell创建一个表,插入一行,然后删除它,最后停止Hbase。只要10分钟就可以完成以下的操作。 1.1下载解压最新版本 选择一个 Apache 下载镜像:http://www.apache.org/dyn/closer.cgi/hbase/,下载 HBase Re…

    Linux干货 2015-04-13

评论列表(1条)

  • luoweiro
    luoweiro 2017-02-23 07:28

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