实验:实现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
本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/101585