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..."; ?>