第十七周运维作业
1、部署分离的LAMP,部署到二台服务器上,php加载xcache模块
环境:
两台机器:
192.168.47.37 httpd php php-fpm php-mysql
192.168.47.47 mariadb
37上安装httpd、php php-fpm 、php-mysql 基于yum安装
[root@centos7 ~]# yum install php php-fpm php-mysql –y
[root@centos7 html]# systemctl start httpd
[root@centos7 html]# systemctl start php-fpm
[root@centos7 ~]# yum install php-xcache.x86_64
[root@centos7 ~]# cd /var/www/html/
[root@centos7 html]# tar vxf wordpress-5.0.4-zh_CN.tar.gz
[root@centos7 html]# cd wordpress/
[root@centos7 wordpress]# mv wp-config-sample.php wp-config.php
修改配置
47上安装mariadb
[root@centos7 app1]# yum install mariadb-server.x86_64
[root@centos7 ~]# mysql
create database wordpress;
grant all on wordpress.* to worduser@192.168.47.% by identified 'centos';
验证性能:37机上
[root@centos7 wordpress]#ab -c10 -n100 http://192.168.47.37/wordpre/
2、部署wordpress论坛,并实现正常访问登录论坛。
192.168.47.17 上:安装httpd,php,php-mysql,wordpress
[root@centos7 ~]# yum install httpd.x86_64
[root@centos7 ~]# yum install php
[root@centos7 ~]# yum install php-mysql 连接数据库的工具
在192.168.47.27数据库服务器创建数据库及用户(mariadb已安装)
MariaDB [(none)]> create database wpdb; 创建数据库
MariaDB [(none)]> grant all on wpdb.* to wpuser@'192.168.47.%' identified by 'centos'; 授权
MariaDB [(none)]> flush privileges;
在192.168.47.17上安装wordpress工具解压缩并移动到站点默认路径
[root@centos7 data]# tar -vxzf wordpress-5.0.4-zh_CN.tar.gz
[root@centos7 data]# mv wordpress /var/www/html/
[root@centos7 wordpress]# mv wp-config-sample.php wp-config.php
[root@centos7 wordpress]# vim wp-config.php 修改配置文件
登录
点击安装wordpress
显示成功!!!
3、收集apache访问日志,并实现图形化展示。
环境:关闭firewalld 、selinux、时间同步。apache 服务器192.168.47.7,mariadb+rsyslog服务器192.168.47.27,php192.168.47.17
在192.168.47.7上编译安装apache 2.4.46
yum install gcc pcre-devel.x86_64 openssl-devel.x86_64 expat-devel.x86_64 -y
./configure --prefix=/app/httpd24 \
--enable-so \
--enable-ssl \
--enable-cgi \
--enable-rewrite \
--with-zlib \
--with-pcre \
--enable-modules=most \
--enable-mpms-shared=all \
--with-mpm=prefork \
--with-included-apr
make && make install
useradd –r –s /sbin/nologin apache –d /home/apache 增加用户名
下载loganalyzer 4.1.11到/app/httpd24/htdocs目录下并解压缩
tar xvf loganalyzer-4.1.11.tar.gz
cp -a loganalyzer-4.1.11/src /app/httpd24/htdocs/loganalyzer/
cd /loganalyzer
touch config.php
chmod 666 config.php
编译httpd.conf配置
开启
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ProxyRequests off
<VirtualHost *:80>
DocumentRoot "/app/httpd24/htdocs/loganalyzer"
ServerName www.loglyzer.com
<directory /app/httpd24/htdocs/loganalyzer>
require all granted
</directory>
ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.47.17:9000/app/php/var/www/loganalyzer/$1
</VirtualHost>
开启模块服务及php页面
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule proxy_module modules/mod_proxy.sor
systemctl start httpd.service
在安装mairadb-server+rsyslog 192.168.47.27
yum install mariadb
grant all on Syslog.* to loguser@'192.168.47.%' identified by 'centos';
yum install rsyslog-mysql
mysql -uroot -h192.168.47.27 -pcentos < /usr/share/doc/rsyslog-8.24.0/mysql-createDB.sql
[root@centos7 ~]# vim /etc/rsyslog.conf
#### MODULES ####
$ModLoad ommysql
#### RULES ####
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none :ommysql:localhost,Syslog,loguser,centos
systemctl start mairadb
在192.168.47.17上安装php7.3.25
./configure --prefix=/app/php \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--enable-mbstring \
--enable-xml \
--enable-sockets \
--enable-fpm \
--enable-maintainer-zts \
--disable-fileinfo
make && make install
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
配置www.conf
[root@centos7 data]# cd /app/php/etc/php-fpm.d/
允许任何主机访问
useradd –r –s /sbin/nologin php-fpm –d /home/php-fpm
systemctl start php-fpm
mkdir –p /app/php/var/www
在7机上远程移动loganalyzer到/app/php/var/www/下
[root@centos7 htdocs]# scp -r loganalyzer/ @192.168.47.17:/app/php/var/www/
[root@centos7 loganalyzer]# pwd
/app/php/var/www/loganalyzer
最后在192.168.47.7机浏览器上输入www.loglyzer.com
点击“here”
完成