Apache 是基于模块化进行设计的,其中最核心的组件是MPM(Multi Processing Module )多重处理模块,而Apache就是经过此模块来进行对操做系统进程线程的管理。它包含多种工做模式,其中最主要的三种工做模式分别是:php
rpm包的安装位置:html
/bin /sbin /usr/bin /usr/bin
/lib /usr/lib
/etc
/usr/share/{doc,man}
/etc
eg: /usr/local/apr bin sbin lib includes etc share/man
能够参照:https://blog.51cto.com/castiel/2051440mysql
1.1下载源码包linux
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz wegt http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
make && make install apr-uitl 编译 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
编译apr-util时有以下报错:web
使用rpm -qa|grep expat
发现已经安装了expat,因而猜测是否是缺乏相关的子包(-util 程序接口包, -devel程序开发包)包。可是expat并无util包,因而便安装了expat-devel包。错误消失。sql
wget http://www.apache.org/dist/httpd/httpd-2.4.38.tar.bz2
httpd编译参数:数据库
--enable-so 支持共享模块 --enable-ssl 启用ssl --enable-deflate 将HTML页面压缩发送 --enable-proxy-fcgi 工做在FCIG模式 --enable-mpms-shared --with-mpm 设置默认的工做模式 --enable-rewrite 支持HTML重写 --enable-cigd work event 模式依赖
./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --enable-so --enable-rewrite --enable-ssl --enable-cigd --enable-cig --enable-modules=most --enable-mods-shared=most --enable-mpms-shared=all --with-mpm=event --with-apr=/usr/local/apr --wirh-apr-util=/usr/local/apr-util
yum provides pcre-config
wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz
tar xf mysql-8.0.17-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
useradd -r mysql
* bin/mysqld --initialize --defaults-file=/etc/my.cnf --user=mysql # 初始化数据库 * bin/mysql_ssl_rsa_setup # 建立密钥对 my.cnf 简单配置以下:
[client] port=3306 socket=/tmp/mysql.sock [mysqld] port=3306 basedir=/usr/local/mysql datadir=/mydata/mysqldata socket=/tmp/mysql.sock
support-files/mysql.server start
/run/systemd/generator.late/
下生成一个mysql.service 脚本,[Install] WantedBy=multi-user.target
总体内容以下:apache
#Automatically generated by systemd-sysv-generator [Unit] Documentation=man:systemd-sysv-generator(8) SourcePath=/etc/rc.d/init.d/mysqld Description=LSB: start and stop MySQL Before=runlevel2.target Before=runlevel3.target Before=runlevel4.target Before=runlevel5.target Before=shutdown.target After=network-online.target After=remote-fs.target After=ypbind.service After=nscd.service After=ldap.service After=ntpd.service After=xntpd.service After=network-online.target Wants=network-online.target Conflicts=shutdown.target [Service] Type=forking Restart=no TimeoutSec=5min IgnoreSIGPIPE=no KillMode=process GuessMainPID=no RemainAfterExit=yes ExecStart=/etc/rc.d/init.d/mysqld start ExecStop=/etc/rc.d/init.d/mysqld stop ExecReload=/etc/rc.d/init.d/mysqld reload [Install] WantedBy=multi-user.target
4.1 安装所须的依赖包api
yum install bzip2-devel libpng-devel libjpeg-turbo-devel libxslt-devel freetype-devel libzip
./configure --prefix=/usr/local/php --with-fpm-user=webu --with-fpm-group=webu --with-curl --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm
useradd -r webu
cp /data/LAMP/php-7.3.8/sapi/fpm/php-fpm.service /usr/lib/systemd/system/ systemctl daemon-reload #从新加载 systemd 服务
4.5 配置php及fpm-php相关配置文件浏览器
cp /data/LAMP/php-7.3.8/php.ini-production /usr/local/php/etc/php.ini #源码目录下 cp /data/LAMP/php-7.3.8/sapi/fpm/php-fpm /usr/local/php/etc/php-fpm #源码目录下 cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #安装目录下 cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf #安装目录下
<FilesMatch \.php$> SetHandler "proxy:fcgi://127.0.0.1:9000" </FilesMatch> # 添加对php页面的支持(可不加) AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so # 首页默认文件 能够写多个 <IfModule dir_module> DirectoryIndex index.html index.php </IfModule>
<? phpinfo() ?>
<?php $conn=mysqli_connect("localhost","用户","密码"); if($conn) echo "Success..."; else echo "Failure..."; ?>