课堂实验

实验:实现Gelera cluster

三台主机
1 yum安装
[mariadb]
name = MariaDB
baseurl = https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-5.5.60/yum/centos7-amd64/
gpgcheck=0

httpd2.2

order deny,allow

allow from 192.168.30.6
deny from 192.168.30.0/24

AuthType Basic
AuthName “welcome to access admin dir”
AuthUserFile “/etc/httpd/conf.d/.httpuser”
require user tom jerry

实验:实现基于用户家目录的验证访问

vim /etc/httpd/conf.d/userdir.conf
<IfModule mod_userdir.c>
UserDir public_html
</IfModule>

#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
#<Directory “/home/*/public_html”>
# AllowOverride FileInfo AuthConfig Limit Indexes
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
# Require method GET POST OPTIONS
#</Directory>

<directory /home/wang/public_html>
authType Basic
AuthName “wang home dir”
AuthUserFile “/etc/httpd/conf.d/.httpuser”
AuthGroupFile “/etc/httpd/conf.d/.httpgroup”
Require group g1
</directory>

实验:实现状态页
#vim /etc/httpd/conf.d/test.conf
<Location “/status”>
SetHandler server-status
Require all granted
</Location>

实验:基于端口号的虚拟主机

listen 81
listen 82
listen 83

<directory /data/>
require all granted
</directory>
<VirtualHost *:81>
DocumentRoot “/data/website1”
ServerName www.a.com
ErrorLog “logs/a.com.error_log”
TransferLog “logs/a.com-access_log”
</VirtualHost>

<VirtualHost *:82>
DocumentRoot “/data/website2”
ServerName www.b.com
ErrorLog “logs/b.com.error_log”
TransferLog “logs/b.com-access_log”
</VirtualHost>

<VirtualHost *:83>
DocumentRoot “/data/website3”
ServerName www.c.com
ErrorLog “logs/c.com.error_log”
TransferLog “logs/c.com-access_log”
</VirtualHost>

实验:基于IP的虚拟主机

<directory /data/>
require all granted
</directory>
<VirtualHost 192.168.30.11:80>
DocumentRoot “/data/website1”
ServerName www.a.com
ErrorLog “logs/a.com.error_log”
TransferLog “logs/a.com-access_log”
</VirtualHost>

<VirtualHost 192.168.30.22:80>
DocumentRoot “/data/website2”
ServerName www.b.com
ErrorLog “logs/b.com.error_log”
TransferLog “logs/b.com-access_log”
</VirtualHost>

<VirtualHost 192.168.30.33:80>
DocumentRoot “/data/website3”
ServerName www.c.com
ErrorLog “logs/c.com.error_log”
TransferLog “logs/c.com-access_log”
</VirtualHost>

实验:基于主机头的虚拟主机

<directory /data/>
require all granted
</directory>
<VirtualHost *:80>
DocumentRoot “/data/website1”
ServerName www.a.com
ErrorLog “logs/a.com.error_log”
TransferLog “logs/a.com-access_log”
</VirtualHost>

<VirtualHost *:80>
DocumentRoot “/data/website2”
ServerName www.b.com
ErrorLog “logs/b.com.error_log”
TransferLog “logs/b.com-access_log”
</VirtualHost>

<VirtualHost *:80>
DocumentRoot “/data/website3”
ServerName www.c.com
ErrorLog “logs/c.com.error_log”
TransferLog “logs/c.com-access_log”
</VirtualHost>
~
实验:实现HTTPS

yum install mod_ssl
vim /etc/httpd/conf.d/ssl.conf
SSLCertificateFile /etc/httpd/conf.d/ssl/httpd.crt
SSLCertificateKeyFile /etc/httpd/conf.d/ssl/httpd.key
SSLCACertificateFile /etc/httpd/conf.d/ssl/cacert.pem

实验:编译安装httpd.2.4.33

www.magedu.com/test.php

LAMP
yum install openssl-devel expat-devel pcre-devel

yum install httpd php php-mysql mairadb-server

systemctl start mariadb httpd

实战:LAMP实现PHPMYadmin
实战:LAMP实现wordpress
实战:编译安装xcache加速php

yum groupinstall “development tools”
yum install php-devel
tar xvf xcache-3.2.0.tar.gz
cd /root/xcache-3.2.0/
phpize
./configure –enable-xcache –with-php-config=/usr/bin/php-config
make -j 4 && make install

cp xcache.ini /etc/php.d/
systemctl restart httpd

实验:LAMP fastcgi模式实现多虚拟主机blog和bbs

bbs 目录权限
setfacl -R -m u:apache:rwx /data/www/

[root@centos7 conf.d]#vim vhosts.conf
<virtualhost *:80>
servername www.bbs.com
documentroot /data/www
DirectoryIndex index.php
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/www/$1
<directory /data/www>
require all granted
</directory>
</virtualhost>

<virtualhost *:80>
servername www.blog.com
documentroot /data/www2
DirectoryIndex index.php
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/www2/$1
<directory /data/www2>
require all granted
</directory>
</virtualhost>

实验:centos7上源码编译安装LAMP的多虚拟主机wordpress,discuz,用lamp.sh脚本实现

环境:
centos7.4
apr-1.6.3.tar.gz
apr-util-1.6.1.tar.gz
httpd-2.4.33.tar.bz2
mariadb-10.2.15-linux-x86_64.tar.gz
php-7.1.18.tar.bz2
wordpress-4.9.4-zh_CN.tar.gz

1安装包:

yum groupinstall “development tools”
yum install pcre-devel openssl-devel expat-devel libxml2-devel bzip2-devel libmcrypt-devel

2 编译安装httpd

./configure –prefix=/app/httpd24 \
–enable-so \
–enable-ssl \
–enable-cgi \
–enable-rewrite \
–with-zlib \
–with-pcre \
–with-included-apr \
–enable-modules=most \
–enable-mpms-shared=all \
–with-mpm=prefork

make && make install

2 配置mysql
tar xvf mariadb-10.2.15-linux-x86_64.tar.gz -C /usr/local/
cd /usr/local/
ln -s mariadb-10.2.15-linux-x86_64/ mysql
useradd -r -s /sbin/nologin mysql
chown -R mysql.mysql mysql/
mkdir /data/mysql -pv
chown mysql.mysql /data/mysql/
vim /etc/profile.d/lamp.sh
PATH=/appl/httpd24/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
. /etc/profile.d/lamp.sh
./scripts/mysql_install_db –datadir=/data/mysql –user=mysql
cp support-files/my-huge.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
vim /etc/my.cnf
datadir=/data/mysql

chkconfig –add mysqld
chkconfig –list
service mysqld start
ss -ntl

mysql >create database wpdb;
mysql >grant all on wpdb.* to wpuser@’192.168.30.%’ identified by ‘centos’;

3编译安装 fastcgi 模式的php

./configure –prefix=/app/php \
–enable-mysqlnd \
–with-mysqli=mysqlnd \
–with-openssl \
–with-pdo-mysql=mysqlnd \
–enable-mbstring \
–with-freetype-dir \
–with-jpeg-dir \
–with-png-dir \
–with-zlib \
–with-libxml-dir=/usr \
–enable-xml \
–enable-sockets \
–enable-fpm \
–with-config-file-path=/etc \
–with-config-file-scan-dir=/etc/php.d \
–enable-maintainer-zts \
–disable-fileinfo

cd /root/srcs/php-7.1.18/
cp php.ini-production /etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig –add php-fpm
chkconfig php-fpm on
cd /app/php/etc
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default php-fpm.d/www.conf
service php-fpm start

vim /etc/profile.d/lamp.sh
PATH=/app/php/bin:/app/php/sbin:/app/httpd24/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root
/bin

vim /app/httpd24/conf/httpd.conf
取消下面两行的注释
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
修改下面行
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
addType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/app/httpd24/htdocs/$1

4 测试

实验:实现loganalyzer展示图形日志
三台主机
rsyslog ,mysql ,loganalyzer

1 rsyslog

yum install rsyslog-mysql
scp /usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql 192.168.30.17:
vim /etc/rsyslog.conf
$ModLoad ommysql
*.info;mail.none;authpriv.none;cron.none :ommysql:192.168.30.17,Syslog,syslog,centos

2 mysql
mysql < mysql-createDB.sql
mysql> grant all on Syslog.* to syslog@’192.168.30.%’ identified by ‘centos’;
mysql> flush privileges;

3 loganalyzer
yum install httpd php php-mysql php-gd
systemctl restart httpd
tar xvf loganalyzer-4.1.6.tar.gz

cp -r loganalyzer-4.1.6/src /var/www/html/log

touch /var/www/html/log/config.php
chmod 666 /var/www/html/log/config.php

http://loganalyzer/log

chmod 644 /var/www/html/log/config.php

QQ截图20180624172451

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/101585

(0)
你的命字你的命字
上一篇 2018-06-24
下一篇 2018-06-24

相关推荐

  • 学习笔记(19)

    学习笔记

    Linux笔记 2018-05-13
  • centos7 网络设定

    从CentOS7开始,网络设定可以不再通过修改各类配置文件,而使用近乎万能的nmcli命令。本文简单介绍该命令的重要使用方法,为后期查询复习做记录。

    Linux笔记 2018-06-12
  • 学习笔记(4)

    学习笔记(4)

    Linux笔记 2018-04-22
  • 喜欢上find

    喜欢上findfind :查找目录下的文件。find 命令其实很好记,会用了,那简直太好玩太方便了-newer查找更改时间比指定文件新的文件-type 按类型查找 (d f l s b c p )D-name 按文件名查找-mtime 按修改时间查找( +2 -2 2)-size 按文件大小查找-perm 按文件权限查找-user 按文件属主来查找-nous…

    2018-04-18
  • 第五周总结

    软RAID   mdadm:为软RAID提供管理界面   为空余磁盘添加冗余   结合内核中的md(multi devices)   RAID设备可命名为/dev/md0、/dev/md1、/dev/md2、/dev/md3等 如果硬盘只分出了一个分区,可以用 dd if=/dev/sdb of=/dev/sdc bs=1 count=66 skip=446…

    Linux笔记 2018-05-01
  • 第九周 加密技术与域名系统

    1、简述常见加密算法及常见加密算法原理,最好使用图例解说  2、搭建apache或者nginx并使用自签证书实现https访问,自签名证书的域名自拟  3、简述DNS服务器原理,并搭建主–辅服务器 4、搭建并实现智能DNS    

    2018-02-01