课堂实验

实验:实现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

相关推荐

  • 命令行展开案例

    [Azuth@azuth ~]$ mkdir /home/Azuth/tmp/{a,b}_{c,d}[Azuth@azuth ~]$ ll /home/Azuth/tmp/total 0drwxrwxr-x. 2 Azuth Azuth 6 May 20 20:35 a_cdrwxrwxr-x. 2 Azuth Azuth 6 May 20 20:35 a_…

    Linux笔记 2018-05-20
  • nmcli命令

    可以用命令行工具 nmcli 来控制 NetworkManager。 在CentOS / RHEL 7中网络管理命令行工具,也叫nmcli。经常使用ifconfig的用户应该在CentOS 7中避免使用ifconfig了。nmcli的功能要强大、复杂的多。 地址配置工具:nmcli nmcli – command-line tool for controll…

    Linux笔记 2018-05-05
  • 磁盘管理知识

    磁盘管理知识 1.tune2fs(调整文件系统参数)      [root@centos6 ~]#tune2fs -i 3 /dev/sdb (interval 间隔,即3天检查一次)      tune2fs 1.41.12 (17-May-2010)      Setting interval between checks to 259200 secon…

    Linux笔记 2018-04-24
  • 小白的随堂笔记(重定向,管道,用户和组,文本工具)

    重定向 把输出和错误输出定向到新文件中 c 操作符号 /> 标准输出重定向 把标准输出重定向到文件(可覆盖原有文件) 2> 错误输出重定向 把错误输出重定向到文件(可覆盖原有文件) &> 把所有输出重定向到文件 >> 所有内容基础上,追加内容 2>> 追加重定向错误输出数据流 &>> 追加…

    2018-04-08
  • 运维制动化之系统安装 实验

      步骤 0:selinux,iptables 1 安装包 2 启服务 3 修改配置文件;reload,restart 4 测试 网卡模式不要桥接: vim /etc/dhcp/dhcpd.conf option domain-name “magedu.org”; option domain-name-servers 114…

    2018-05-25
  • 阿X吃鸡录————第四站

    diff -u a b >ab 生成ab即为补丁,在a或者b文件丢失时 patch -b a/b ab 生成丢失的文件内容 etc/下创建nologin文件会使普通文件无法登陆(普通用户登陆会显示文件中的内容) [-t num ] 判断是否文件在终端被打开(文件描述符) read 对变量赋值 echo -e “ \c” read name 会不产生换行…

    Linux笔记 2018-08-06