web服务器会根据这次请求的内容,开启一个fork新进程来运行外部的C程序或者脚本等,这个进程会把处理完的数据返回给Web服务器,最后Web服务器把内容发送给用户,fork退出
Client – (http协议) --> httpd – (cgi协议) --> application server (program file) – (mysql协议) --> mysql
Web服务器收到用户请求时,不会重新开启一个fork进程(进程在web浏览器启动时就开启了,而且不会退出),web服务器直接把内容传递给这个进程( 进程间通信,但fastcgi使用了别的方式,tcp方式通信),这个进程收到请求后进行处理,把结果返回给web服务器,最后自己接着等待下个进程,不会退出。
实验环境:centos8
一台虚拟机:mysql
一台虚拟机:yum安装https2.4,编译安装PHP7.4
[root@htp-php ~]#dnf -y install httpd php-json php-mysqlnd
[root@htp-php ~]#wget https://cn.wordpress.org/latest-zh_CN.zip
[root@htp-php ~]#tar xvf wordpress-5.4.2-zh_CN.tar.gz
[root@htp-php ~]#mv wordpress/* /var/www/html/
[root@htp-php ~]#chown -R apache.apache /var/www/html/
[root@htp-php ~]#wget https://www.php.net/distributions/php-7.4.26.tar.gz
###解压
[root@htp-php ~]#tar xf php-7.4.26.tar.gz
[root@htp-php ~]#yum install gcc make libxml2-devel bzip2-devel libmcrypt-devel
[root@htp-php php-7.4.26]#./configure \
> --prefix=/apps/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 \
> --with-apxs2=/app/httpd/bin/apxs \
> --with-config-file-path=/etc \
> --with-config-file-scan-dir=/etc/php.d \
> --enable-maintainer-zts \
> --disable-fileinfo
[root@htp-php php-7.4.26]#make -j 4 && make install
[root@htp-php ~]#cd php-7.4.26
[root@htp-php php-7.4.26]#
cp php.ini-production /etc/php.ini
[root@htp-php ~]#vim /etc/httpd/conf/httpd.conf
#下面加二行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
#定位至DirectoryIndex index.html, 修改为
DirectoryIndex index.php index.html
[root@htp-php ~]#apachectl restart
[root@mysql ~]#yum install mariadb-server
[root@mysql ~]#systemctl start mariad
mysql> create database wordpress;
mysql> grant all on wordpress.* to wpuser@'10.0.0.%' identified by "magedu";
[root@htp-php ~]#unzip Discuz_X3.4_SC_UTF8【20191201】.zip
[root@htp-php ~]#mv upload/ /var/www/html/forum
[root@htp-php ~]#chown -R apache.apache /var/www/html/forum
实验环境:
一台:rsyslog日志服务器,IP:172.17.8.8
一台:mariadb数据库服务器,IP:172.17.8.18
一台:客户端,IP:172.17.8.28
[root@centos8 ~]#yum install rsyslog-mysql
[root@centos8 ~]#rpm -ql rsyslog-mysql
/usr/lib/.build-id
/usr/lib/.build-id/d7
/usr/lib/.build-id/d7/77fc839aa07e92f0a8858cf3f122996436c7df
/usr/lib64/rsyslog/ommysql.so
/usr/share/doc/rsyslog/mysql-createDB.sql
[root@centos8 ~]#scp /usr/share/doc/rsyslog/mysql-createDB.sql 172.17.8.18:/data/back_`date +%F`
[root@centos8 ~]#yum install mariadb-server
[root@centos8 ~]#yum install mariadb-server
mysql>source /data/mysql-createDB.sql
mysql>grant all ON Syslog.* to 'rsyslog'@'172.17.8.%' identified by 'magedu';
[root@centos8 ~]#vim /etc/rsyslog.conf
#在 MODULES 语言下面添加
module(load="ommysql")
#在RULES语句块加下面行的格式
*.info :ommysql:172.17.8.18,Syslog,rsyslog,magedu
#在日志服务器上生成日志
[root@centos8 ~]#logger "this is a test log"
#在数据库上查询到上面的测试日志
mysql>select count(*) from SystemEvents;