赞
踩
[root@master soft]# yum install -y gcc gcc-c++ expat-devel zlib-devel openssl-devel
[root@master soft]# wget http://mirror.bit.edu.cn/apache//apr/apr-1.7.0.tar.gz
[root@master soft]# tar zxvf apr-1.7.0.tar.gz
[root@master soft]# cd apr-1.7.0
[root@master apr-1.7.0]# ./configure --prefix=/share/apr && make -j 8 && make install && echo $?
[root@master soft]# wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
[root@master soft]# tar zxvf apr-util-1.6.1.tar.gz
[root@master soft]# cd apr-util-1.6.1
[root@master apr-util-1.6.1]# ./configure --prefix=/share/apr-util --with-apr=/share/apr && make -j 8 && make install && echo $?
Notice:★★★★
必须是8.x,否则apache httpd 安装找不到pcre-config
[root@master soft]# wget https://ftp.pcre.org/pub/pcre/pcre-8.43.zip
[root@master soft]# unzip pcre-8.43.zip
[root@master soft]# cd pcre-8.43
[root@master pcre-8.43]# ./configure --prefix=/share/pcre8 && make -j 8 && make install && echo $?
[root@master soft]# wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.41.tar.gz
[root@master soft]# tar zxvf httpd-2.4.41.tar.gz
Notice:★★★
重新编译安装,需要删除源文件,重新解压。
[root@master httpd-2.4.41]# env CFLAGS="-Wall -DBIG_SECURITY_HOLE" ./configure --prefix=/share/apache/ --exec-prefix=/share/apache/win/ --bindir=/share/apache/bin --sbindir=/share/apache/sbin --libexecdir=/share/apache/libexec --sysconfdir=/share/apache/conf --sharedstatedir=/share/apache/com --localstatedir=/share/apache/var --runstatedir=/share/apache/run --libdir=/share/apache/lib --includedir=/share/apache/include --oldincludedir=/share/apache/usr/include --datarootdir=/share/apache/share --datadir=/share/apache/data --infodir=/share/apache/info --infodir=/share/apache/locale --mandir=/share/apache/man --docdir=/share/apache/doc/PACKAGE --html=/share/apache/doc/html --dvidir=/share/apache/doc/dvi --pdfdir=/share/apache/doc/pdf --psdir=/share/apache/doc/ps --with-apr=/share/apr --with-apr-util=/share/apr-util --with-pcre=/share/pcre8 --with-mysql=/share/mariadb --enable-so --enable-ssl --enable-deflate --enable-rewrite --enable-headers --enable-expires --enable-cgid --enable-cgi --enable-mods-shared=allable-ssl --enable-mods-shared=all --enable-track-vars && make -j 8 && make install && echo $?
Notice:★★
修改root权限启动httpd的方法有3种:
A.在编译前面加env CFLAGS="-Wall -DBIG_SECURITY_HOLE" 环境变量
B.在/etc/profile和~/.bashrc中加环境遍历
export CFLAGS="-Wall -DBIG_SECURITY_HOLE"
C.修改头文件
[root@master include]# pwd
/share/soft/httpd-2.4.41/include
[root@master include]# vim http
http_config.h http_core.h http_log.h http_protocol.h http_vhost.h
http_connection.h httpd.h http_main.h http_request.h
[root@master include]# vim http_config.h
#ifndef BIG_SECURITY_HOLE
#define BIG_SECURITY_HOLE
#endif
Notice:★★★★
安装完毕一定要查看httpd.conf文件,与yum安装的路径和配置差异较大。
[root@master soft]# echo 'export HTTPD_HOME=/share/apache' >>/etc/profile
[root@master soft]# echo 'export PATH=$HTTPD_HOME/bin:$HTTPD_HOME/sbin:$PATH' >> /etc/profile
[root@master soft]# echo 'export HTTPD_HOME=/share/apache' >> ~/.bashrc
[root@master soft]# echo 'export PATH=$HTTPD_HOME/bin:$HTTPD_HOME/sbin:$PATH' >> ~/.bashrc
[root@master soft]# source /etc/profile ~/.bashrc
[root@master ~]# vim /usr/lib/systemd/system/httpd.service [Unit] Description=The Apache HTTP Server After=network.target remote-fs.target nss-lookup.target Documentation=man:/share/apache/sbin/httpd(8) Documentation=man:/share/apache/sbin/apachectl(8) [Service] Type=forking EnvironmentFile=/share/apache/conf/httpd.conf ExecStart=/share/apache/sbin/httpd $OPTIONS -k start ExecReload=/share/apache/sbin/httpd $OPTIONS -k graceful ExecStop=/share/apache/sbin/httpd $OPTIONS -k stop KillSignal=SIGCONT PrivateTmp=true [Install] WantedBy=multi-user.target
[root@master ~]# systemctl start httpd
[root@master ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2020-02-24 09:14:42 CST; 5s ago
.....................
修改配置文件
[root@master conf]# pwd
/share/apache/conf
[root@master conf]# vim httpd.conf
#将daemon改成root,也可以改成其他的自定义的用户
User root
Group root
#去掉ServerName前的#
ServerName www.example.com:80
[root@master conf]# systemctl restart httpd
检查配置文件路径
[root@node3 ~]# httpd -t -D DUMP_RUN_CFG
ServerRoot: "/share/apache/"
Main DocumentRoot: "/share/apache/data/htdocs"
Main ErrorLog: "/share/apache/var/logs/error_log"
Mutex default: dir="/share/apache/var/logs/" mechanism=default
PidFile: "/share/apache/var/logs/httpd.pid"
Define: DUMP_RUN_CFG
User: name="root" id=0
Group: name="root" id=0
#清理环境 rm -rf /share/apr /share/apr-util /share/pcre8 /share/apache cp -rpfn /etc/{profile.bak,profile} cp -rpfn ~/.bashrcbak ~/.bashrc #环境安装 yum install -y gcc yum install -y gcc-c++ yum install -y expat-devel yum install -y zlib-devel yum install -y openssl-devel yum install -y psmisc yum install -y wget cd /share/soft wget ftp://ftpuser/apr-1.7.0.tar.gz tar zxvf apr-1.7.0.tar.gz cd apr-1.7.0 ./configure --prefix=/share/apr make -j 4 make install echo $? cd /share/soft wget ftp://ftpuser/apr-util-1.6.1.tar.gz tar zxvf apr-util-1.6.1.tar.gz cd apr-util-1.6.1 ./configure --prefix=/share/apr-util --with-apr=/share/apr make -j 4 make install echo $? cd /share/soft wget ftp://ftpuser/pcre-8.43.zip unzip pcre-8.43.zip cd pcre-8.43 ./configure --prefix=/share/pcre8 make -j 4 make install echo $? #下载安装包 cd /share/soft wget ftp://ftpuser/httpd-2.4.41.tar.gz #编译安装httpd tar xf httpd-2.4.41.tar.gz cd httpd-2.4.41 env CFLAGS="-Wall -DBIG_SECURITY_HOLE" ./configure --prefix=/share/apache/ --exec-prefix=/share/apache/win/ --bindir=/share/apache/bin --sbindir=/share/apache/sbin --libexecdir=/share/apache/libexec --sysconfdir=/share/apache/conf --sharedstatedir=/share/apache/com --localstatedir=/share/apache/var --runstatedir=/share/apache/run --libdir=/share/apache/lib --includedir=/share/apache/include --oldincludedir=/share/apache/usr/include --datarootdir=/share/apache/share --datadir=/share/apache/data --infodir=/share/apache/info --infodir=/share/apache/locale --mandir=/share/apache/man --docdir=/share/apache/doc/PACKAGE --html=/share/apache/doc/html --dvidir=/share/apache/doc/dvi --pdfdir=/share/apache/doc/pdf --psdir=/share/apache/doc/ps --with-apr=/share/apr --with-apr-util=/share/apr-util --with-pcre=/share/pcre8 --with-mysql=/share/mariadb --enable-so --enable-ssl --enable-deflate --enable-rewrite --enable-headers --enable-expires --enable-cgid --enable-cgi --enable-mods-shared=allable-ssl --enable-mods-shared=all --enable-track-vars && make -j 8 && make install && echo $? #生成环境变量 #cp -rpfn /etc/{profile,profile.bak} #cp -rpfn ~/.bashrc ~/.bashrcbak echo 'export HTTPD_HOME=/share/apache' >>/etc/profile echo 'export PATH=$HTTPD_HOME/bin:$HTTPD_HOME/sbin:$PATH' >> /etc/profile echo 'export HTTPD_HOME=/share/apache' >> ~/.bashrc echo 'export PATH=$HTTPD_HOME/bin:$HTTPD_HOME/sbin:$PATH' >> ~/.bashrc source /etc/profile ~/.bashrc #生成服务文件 cat<<EOF>/usr/lib/systemd/system/httpd.service Description=The Apache HTTP Server After=network.target remote-fs.target nss-lookup.target Documentation=man:/share/apache/sbin/httpd(8) Documentation=man:/share/apache/sbin/apachectl(8) [Service] Type=forking EnvironmentFile=/share/apache/conf/httpd.conf ExecStart=/share/apache/sbin/httpd $OPTIONS -k start ExecReload=/share/apache/sbin/httpd $OPTIONS -k graceful ExecStop=/share/apache/sbin/httpd $OPTIONS -k stop KillSignal=SIGCONT PrivateTmp=true [Install] WantedBy=multi-user.target EOF #修改配置文件 cp -rpfn /share/apache/conf/{httpd.conf,httpd.conf.bak} sed -i 's/daemon/root/g' /share/apache/conf/httpd.conf sed -i 's/#ServerName/ServerName/g' /share/apache/conf/httpd.conf #验证安装 systemctl start httpd systemctl status httpd
[root@master soft]# yum -y install wget yum -y install vim yum -y install pcre yum -y install pcre-devel yum -y install openssl yum -y install openssl-devel yum -y install libicu-devel yum -y install gcc yum -y install gcc-c++ yum -y install autoconf yum -y install libjpeg yum -y install libjpeg-devel yum -y install libpng yum -y install libpng-devel yum -y install freetype yum -y install freetype-devel yum -y install libxml2 yum -y install libxml2-devel yum -y install zlib yum -y install zlib-devel yum -y install glibc yum -y install glibc-devel yum -y install glib2 yum -y install glib2-devel yum -y install ncurses yum -y install ncurses-devel yum -y install curl yum -y install curl-devel yum -y install krb5-devel yum -y install libidn yum -y install libidn-devel yum -y install openldap yum -y install openldap-devel yum -y install nss_ldap yum -y install jemalloc-devel yum -y install cmake yum -y install boost-devel yum -y install bison yum -y install automake yum -y install libevent yum -y install libevent-devel yum -y install gd yum -y install gd-devel yum -y install libtool-ltdl yum -y install libtool yum -y install libtool-ltdl-devel yum -y install libmcrypt yum -y install libmcrypt-devel yum -y install mcrypt yum -y install mhash yum -y install libxslt yum -y install libxslt-devel yum -y install readline yum -y install readline-devel yum -y install gmp yum -y install gmp-devel yum -y install libcurl yum -y install libcurl-devel yum -y install openjpeg-devel yum -y install libjpeg-turbo yum -y install libjpeg-turbo-devel yum -y install libpng yum -y install freetype yum -y install libpng-devel yum -y install freetype-devel yum -y install icu yum -y install libicu yum -y install libicu-devel yum -y install openldap yum -y install openldap-clients yum -y install openldap-devel o yum -y install penldap-servers yum -y install sqlite-devel yum -y install oniguruma yum -y install oniguruma-devel [root@master soft]# cp -frp /usr/lib64/libldap* /usr/lib/
[root@master soft]# wget https://www.php.net/distributions/php-7.4.3.tar.gz
[root@master soft]# tar xf php-7.4.3.tar.gz
[root@master soft]# cd php-7.4.3/
建议在mariadb后台启动后安装
root@master php-7.4.3]# ./configure --prefix=/share/php/php7.4.3 --with-apxs2=/share/apache/bin/apxs --with-config-file-path=/share/php/php7.4.3/etc --enable-fpm --with-fpm-user=root --with-fpm-group=root --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --with-libmbfl --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-pear --enable-maintainer-zts --with-ldap=shared --without-gdbm --with-mysql-sock=/share/mariadb/mariadb10.5/etc/mysql.sock --enable-sockets && make -j 12 && make install && echo $?
Notice:★★★★
编译问题:cc: Internal error: Killed (program cc1)
内存不够报错。 添加–disable-fileinfo
question1:
configure: error: Cannot find ldap libraries in /usr/lib.
cp -frp /usr/lib64/libldap* /usr/lib/
question2:
configure: error: Package requirements (oniguruma) were not met
wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz
tar -zxf oniguruma-6.9.4.tar.gz
cd oniguruma-6.9.4
./autogen.sh && ./configure --prefix=/usr
make && make install
yum -y install https://mirrors.tuna.tsinghua.edu.cn/centos/7/cloud/x86_64/openstack-queens/Packages/o/oniguruma-6.7.0-1.el7.x86_64.rpm
yum -y install https://mirrors.tuna.tsinghua.edu.cn/centos/7/cloud/x86_64/openstack-queens/Packages/o/oniguruma-devel-6.7.0-1.el7.x86_64.rpm
Notice:★★
mysqldnd即MySQL Native Driver简写,即是由PHP源码提供的mysql驱动连接代码,它的目的是代替旧的libmysql驱动。
为何要使用mysqlnd驱动?
A.libmysql驱动是由mysql AB公司(现在是oracle公司)编写, 并按mysql license许可协议发布,所以在PHP中默认是被禁用的。而mysqlnd是由php官方开发的驱动,以php license许可协议发布,故就规避了许可协议和版权的问题。
B.因为mysqlnd内置于PHP源代码,故你在编译安装php时就不需要预先安装mysql server也可以提供mysql client API (mysql_connect, pdo , mysqli), 这将减化一些工作量.
C. mysqlnd是专门为php优化编写的驱动,它使用了PHP本身的特性,在内存管理,性能上比libmysql更有优势. php官方的测试是:libmysql将每条记录在内存中保存了两份,而mysqlnd只保存了一份
D. 一些新的或增强的功能
增强的持久连接
引入特有的函数mysqli_fetch_all()
引入一些性能统计函数mysqli_get_cache_stats(), mysqli_get_client_stats(),
mysqli_get_connection_stats(),
使用上述函数,可很容易分析mysql查询的性能瓶颈!
SSL支持(从php 5.3.3开始有效)
压缩协议支持
命名管道支持(php 5.4.0开始有效)
Notice:★★
yum 安装php会将httpd一起安装包
参考
[root@master share]# yum install https://mirror.webtatic.com/yum/el7/epel-release.rpm
如果5.1 安装yum源不成功,可以手写yum源
[root@master ~]# vim /etc/yum.repos.d/remi.repo [remi-php54] name=remi-php54 baseurl=http://rpms.remirepo.net/enterprise/7/php54/x86_64/ enabled=1 gpgcheck=1 gpgkey=http://rpms.remirepo.net/RPM-GPG-KEY-remi [remi-php55] name=remi-php55 baseurl=http://rpms.remirepo.net/enterprise/7/php55/x86_64/ enabled=1 gpgcheck=1 gpgkey=http://rpms.remirepo.net/RPM-GPG-KEY-remi [remi-php56] name=remi-php56 baseurl=http://rpms.remirepo.net/enterprise/7/php56/x86_64/ enabled=1 gpgcheck=1 gpgkey=http://rpms.remirepo.net/RPM-GPG-KEY-remi [remi-php70] name=remi-php70 baseurl=http://rpms.remirepo.net/enterprise/7/php70/x86_64/ enabled=1 gpgcheck=1 gpgkey=http://rpms.remirepo.net/RPM-GPG-KEY-remi [remi-php71] name=remi-php71 baseurl=http://rpms.remirepo.net/enterprise/7/php71/x86_64/ enabled=1 gpgcheck=1 gpgkey=http://rpms.remirepo.net/RPM-GPG-KEY-remi [remi-php72] name=remi-php72 baseurl=http://rpms.remirepo.net/enterprise/7/php72/x86_64/ enabled=1 gpgcheck=1 gpgkey=http://rpms.remirepo.net/RPM-GPG-KEY-remi [remi-php73] name=remi-php73 baseurl=http://rpms.remirepo.net/enterprise/7/php73/x86_64/ enabled=1 gpgcheck=1 gpgkey=http://rpms.remirepo.net/RPM-GPG-KEY-remi [remi-php74] name=remi-php72 baseurl=http://rpms.remirepo.net/enterprise/7/php74/x86_64/ enabled=1 gpgcheck=1 gpgkey=http://rpms.remirepo.net/RPM-GPG-KEY-remi
Notice:★★
php-fpm版本是7.4的,安装完毕,可以采用systemctrl直接启动
[root@master yum.repos.d]# yum info php-fpm Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Available Packages Name : php-fpm Arch : x86_64 Version : 7.4.3 Release : 1.el7.remi Size : 1.8 M Repo : remi-php74 Summary : PHP FastCGI Process Manager URL : http://www.php.net/ License : PHP and Zend and BSD and MIT and ASL 1.0 and NCSA Description : PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI : implementation with some additional features useful for sites of : any size, especially busier sites.
[root@master yum.repos.d]# yum search php74
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
========================================================= N/S matched: php74 ==========================================================
php74-runtime.x86_64 : Package that handles php74 Software Collection.
php74.x86_64 : Package that installs PHP 7.4
php74-php-cli.x86_64 : Command-line interface for PHP
php74-php-common.x86_64 : Common files for PHP
php74-php-json.x86_64 : JavaScript Object Notation extension for PHP
Notice:★★
yum安装受网络状态限制,不建议使用!
[root@master php-7.4.3]# pwd /blueicex/soft/php-7.4.3 [root@master php-7.4.3]# cp php.ini-production /share/php/php7.4.3/php.ini [root@master php7.4.3]# pwd /share/php/php7.4.3 [root@master php7.4.3]# mkdir /share/php/php7.4.3/extensions [root@master php7.4.3]# vim /share/php/php7.4.3/php.ini expose_php = Off short_open_tag = ON max_execution_time = 300 max_input_time = 300 memory_limit = 128M post_max_size = 32M date.timezone = Asia/Shanghai mbstring.func_overload=2 extension_dir = "/share/php/php7.4.3/extensions/no-debug-zts-20200227/"
[root@master etc]# pwd
/share/php/php7.4.3/etc
[root@master etc]# cp php-fpm.conf.default php-fpm.conf
[root@master php-fpm.d]# pwd
/share/php/php7.4.3/etc/php-fpm.d
[root@master php-fpm.d]# cp www.conf.default www.conf
[root@master sbin]# pwd
/share/php/php7.4.3/sbin
[root@master sbin]# ln -sf /share/php/php7.4.3 /share/lnhome/php
[root@master bin]# cd /share/lnhome/php/
[root@master php]# ls
bin etc extensions include lib php sbin var
[root@master php]# echo 'export PHP_HOME=/share/lnhome/php' >>/etc/profile
[root@master php]# echo 'export PATH=$PHP_HOME/sbin:$PATH' >> /etc/profile
[root@master php]# echo 'export PHP_HOME=/share/apache' >> ~/.bashrc
[root@master php]# echo 'export PATH=$PHP_HOME/sbin:$PATH' >> ~/.bashrc
[root@master php]# source /etc/profile ~/.bashrc
[root@master etc]# php-fpm --help Usage: php [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p <prefix>] [-g <pid>] [-c <file>] [-d foo[=bar]] [-y <file>] [-D] [-F [-O]] -c <path>|<file> Look for php.ini file in this directory -n No php.ini file will be used -d foo[=bar] Define INI entry foo with value 'bar' -e Generate extended information for debugger/profiler -h This help -i PHP information -m Show compiled in modules -v Version number -p, --prefix <dir> Specify alternative prefix path to FastCGI process manager (default: /share/php/php7.4.3). -g, --pid <file> Specify the PID file location. -y, --fpm-config <file> Specify alternative path to FastCGI process manager config file. -t, --test Test FPM configuration and exit -D, --daemonize force to run in background, and ignore daemonize option from config file -F, --nodaemonize force to stay in foreground, and ignore daemonize option from config file -O, --force-stderr force output to stderr in nodaemonize even if stderr is not a TTY -R, --allow-to-run-as-root Allow pool to run as root (disabled by default) # Notice:R, --allow-to-run-as-root [root@master php]# php74 -v PHP 7.4.3 (cli) (built: Feb 18 2020 11:53:05) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies [root@master php]# php-fpm -c /share/php/php7.4.3/php.ini -y /share/php/php7.4.3/etc/php-fpm.conf -R root@master etc]# ps aux | grep php root 115011 0.0 0.3 245364 7484 ? Ss 12:18 0:00 php-fpm: master process (/share/php/php7.4.3/etc/php-fpm.conf) root 115012 0.0 0.3 245364 6784 ? S 12:18 0:00 php-fpm: pool www root 115013 0.0 0.3 245364 6784 ? S 12:18 0:00 php-fpm: pool www
[root@master fpm]# vim /usr/lib/systemd/system/php-fpm.service
[Unit]
Description=The PHP FastCGI Process Manager
After=network.target
[Service]
Type=forking
ExecStart=/share/php/php7.4.3/sbin/php-fpm -R -D -O -c /share/php/php7.4.3/php.ini --fpm-config /share/php/php7.4.3/etc/php-fpm.conf --pid /share/php/php7.4.3/etc/php-fpm.pid
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[root@master fpm]# ps aux | grep php root 41374 0.0 1.1 610272 23248 ? Ss 05:15 0:00 php-fpm: master process (/etc/opt/rh/rh-php73/php-fpm.conf) apache 41375 0.0 0.5 610272 10452 ? S 05:15 0:00 php-fpm: pool www apache 41376 0.0 0.5 610272 10452 ? S 05:15 0:00 php-fpm: pool www apache 41377 0.0 0.5 610272 10452 ? S 05:15 0:00 php-fpm: pool www apache 41378 0.0 0.5 610272 10452 ? S 05:15 0:00 php-fpm: pool www apache 41379 0.0 0.5 610272 10452 ? S 05:15 0:00 php-fpm: pool www root 49588 0.0 0.0 112712 964 pts/2 R+ 07:38 0:00 grep --color=auto php [root@master fpm]# killall php-fpm [root@master fpm]# systemctl start php-fpm [root@master fpm]# systemctl status php-fpm ● php-fpm.service - LSB: starts php-fpm Loaded: loaded (/etc/rc.d/init.d/php-fpm; bad; vendor preset: disabled) Active: active (running) since Wed 2020-02-26 07:38:21 CST; 11s ago .................. [root@master fpm]# ps aux | grep php root 49613 0.0 0.3 245360 7492 ? Ss 07:38 0:00 php-fpm: master process (/share/php/php7.4.3/etc/php-fpm.conf) apache 49614 0.0 0.3 245360 7036 ? S 07:38 0:00 php-fpm: pool www apache 49615 0.0 0.3 245360 7036 ? S 07:38 0:00 php-fpm: pool www root 49730 0.0 0.0 112712 964 pts/2 R+ 07:40 0:00 grep --color=auto php
Notice:★★★★
编译安装和yum安装截然不同,要看清楚配置和文件架构
编译安装已经在httpd.conf装载了php7模块,为了便于管理,可以去除httpd.conf关于php模块的配置,重新新建模块装载文件
[root@master apache]# pwd /share/apache/ [root@master apache]# mkdir modules conf.modules.d conf.d [root@master apache]# cd conf.modules.d/ [root@master conf.modules.d]# vim 00-php.conf LoadModule php7_module libexec/libphp7.so [root@master conf.modules.d]# cd ../conf.d/ [root@master conf.d]# vim php.conf <IfModule mod_php7.c> AddType application/x-httpd-php .php </IfModule> <IfModule dir_module> DirectoryIndex index.html index.php </IfModule> [root@master conf.d]# cd ../conf [root@master conf]# cp httpd.conf httpd.conf.bak [root@master conf]# vim httpd.conf Include conf.modules.d/*.conf IncludeOptional conf.d/*.conf [root@master conf.d]# mkdir /share/data/apache/www/html/v1 -pv [root@master extra]# pwd /share/apache/conf/extra root@master extra]# cp httpd-vhosts.conf /share/apache/conf.d/v1.conf [root@master extra]# cd /share/apache/conf.d/ [root@master conf.d]# vim v1.conf Listen 88 <VirtualHost *:88> ServerAdmin blueice1980@126.com DocumentRoot "/share/data/apache/www/html/v1" ServerName master.blueicex.com ErrorLog "var/logs/v1_error_log" CustomLog "var/logs/v1_access_log" common DirectoryIndex index.php </VirtualHost> <Directory "/share/data/apache/www/html/v1"> AllowOverride None # Allow open access: Require all granted </Directory>
启动Apache
[root@master conf.d]# systemctl start httpd
[root@master conf]# echo '<?php phpinfo(); ?>' >> /share/data/apache/www/html/v1/index.php
[root@master conf]# curl master.blueicex.com:/index.php
[root@master conf]# vim /share/data/apache/www/html/v1/mysql.php
<?php
$link = mysqli_connect('localhost', 'root', ' ');
if (!$link) {
die('Could not connect: ' . mysqli_error());
}
echo 'Connected successfully';
mysqli_close($link);
?>
[root@master conf]# curl master.blueicex.com:/mysql.php
#清理环境 rm -rf /share/php/php7.4.3 cp -rpfn /etc/{profile.bak,profile} cp -rpfn ~/.bashrcbak ~/.bashrc #安装环境包(重点是这里) yum -y install wget vim pcre pcre-devel openssl openssl-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool libtool-devel libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel libcurl libcurl-devel libjpeg-turbo libjpeg-turbo-devel libpng freetype libpng-devel freetype-devel icu libicu libicu-devel openldap openldap-clients openldap-devel openldap-servers sqlite-devel oniguruma oniguruma-devel libticonv libticonv-devel wget psmisc cp -frpn /usr/lib64/libldap* /usr/lib/ #下载php安装包 cd /share/soft wget ftp://ftpuser/php-7.4.3.tar.gz #编译安装php tar xf php-7.4.3.tar.gz cd php-7.4.3 ./configure --prefix=/share/php/php7.4.3 --with-apxs2=/share/apache/bin/apxs --with-config-file-path=/share/php/php7.4.3/etc --enable-fpm --with-fpm-user=root --with-fpm-group=root --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --with-libmbfl --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-pear --enable-maintainer-zts --with-ldap=shared --without-gdbm --with-mysql-sock=/share/mariadb/mariadb10.5/etc/mysql.sock --enable-sockets make -j 6 make install echo $? #配置PHP cd /share/soft/php-7.4.3 cp -fprn php.ini-production /share/php/php7.4.3/php.ini mkdir /share/php/php7.4.3/extensions -pv cat << EOF >/share/php/php7.4.3/php.ini expose_php = Off short_open_tag = ON max_execution_time = 300 max_input_time = 300 memory_limit = 128M post_max_size = 32M date.timezone = Asia/Shanghai mbstring.func_overload=2 extension_dir = "/share/php/php7.4.3/extensions/no-debug-zts-20200227/" EOF cd /share/php/php7.4.3/etc cp -fprn php-fpm.conf.default php-fpm.conf cd /share/php/php7.4.3/etc/php-fpm.d cp -fprn www.conf.default www.conf #指定环境变量 mkdir -pv /share/lnhome/ ln -sf /share/php/php7.4.3 /share/lnhome/php #cp -rpfn /etc/{profile,profile.bak} #cp -rpfn ~/.bashrc ~/.bashrcbak echo 'export PHP_HOME=/share/lnhome/php' >>/etc/profile echo 'export PATH=$PHP_HOME/sbin:$PATH' >> /etc/profile echo 'export PHP_HOME=/share/apache' >> ~/.bashrc echo 'export PATH=$PHP_HOME/sbin:$PATH' >> ~/.bashrc source /etc/profile ~/.bashrc #验证php安装 php-fpm --help php74 -v #添加php-fpm服务 cat << EOF >/usr/lib/systemd/system/php-fpm.service [Unit] Description=The PHP FastCGI Process Manager After=network.target [Service] Type=forking ExecStart=/share/php/php7.4.3/sbin/php-fpm -R -D -O -c /share/php/php7.4.3/php.ini --fpm-config /share/php/php7.4.3/etc/php-fpm.conf --pid /share/php/php7.4.3/etc/php-fpm.pid ExecReload=/bin/kill -USR2 $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target EOF #验证php服务安装 systemctl stop php-fpm systemctl start php-fpm systemctl status php-fpm #http配置php功能 cd /share/apache/ mkdir modules conf.modules.d conf.d cd /share/apache/conf.modules.d/ echo 'LoadModule php7_module libexec/libphp7.so' >>00-php.conf cd /share/apache/conf.d/ cat << EOF > php.conf <IfModule mod_php7.c> AddType application/x-httpd-php .php </IfModule> <IfModule dir_module> DirectoryIndex index.html index.php </IfModule> EOF cd /share/apache/conf cp httpd.conf httpd.conf.bak echo 'Include conf.modules.d/*.conf'>>httpd.conf echo 'IncludeOptional conf.d/*.conf'>>httpd.conf #验证服务 mkdir /share/data/apache/www/html/v1 -pv cd /share/apache/conf/extra cp httpd-vhosts.conf /share/apache/conf.d/v1.conf cd /share/apache/conf.d/ >>v1.conf cat << EOF >/share/data/apache/www/html/v1 Listen 88 <VirtualHost *:88> ServerAdmin blueice1980@126.com DocumentRoot "/share/data/apache/www/html/v1" ServerName node2.blueicex.com ErrorLog "var/logs/v1_error_log" CustomLog "var/logs/v1_access_log" common DirectoryIndex index.php </VirtualHost> <Directory "/share/data/apache/www/html/v1"> AllowOverride None # Allow open access: Require all granted </Directory> EOF systemctl restart httpd echo '<?php phpinfo(); ?>' > /share/data/apache/www/html/v1/index.php curl node2.blueicex.com:/index.php cat <<EOF>/share/data/apache/www/html/v1/mysql.php <?php $link = mysqli_connect('localhost', 'root', 'blueice1980'); if (!$link) { die('Could not connect: ' . mysqli_error()); } echo 'Connected successfully'; mysqli_close($link); ?> EOF curl master.blueicex.com:/mysql.php
############系统 #默认禁用短形式的开始标签 <? --disable-short-tags --enable-inline-optimization --enable-sysvsem --enable-sysvshm --enable-sigchild #支持zend的多字节 --enable-zend-multibyte #php.ini位置,默认为 PREFIX/lib。 --with-config-file-path=/usr/local/php/etc #整合apache,apxs功能 --with-apxs2=/usr/local/apache/bin/apxs #安装 PEAR 扩展。pear命令的支持,PHP扩展用的 --with-pear #进程控制 --enable-pcntl #魔术引用的支持 --enable-magic-quotes #魔术头文件位置 --with-mime-magic=/usr/share/file/magic.mime #日历扩展功能 --enable-calendar #关闭额外的运行库文件 --disable-rpath #关闭调试 --disable-debug #打开安全模式 --enable-safe-mode #开启wddx函数库 --enable-wddx #允许PHP读取、写入、创建和删除Unix共享内存段的函数集 --enable-shmop ############CGI #FPM 支持 --enable-fpm 支持fastcgi方式启动PHP --enable-fastCGI --enable-force-CGI-redirect ############压缩 --with-bz2 --with-zlib --enable-zip #zip 支持,[DIR]是 ZZIPlib 库安装路径 --with-zip[=DIR] ############网络 #FTP扩展 --enable-ftp #支持curl --with-curl #运用curl工具打开url流 --with-curlwrappers #支持 SOAP –enable-soap ############xml及扩展 #打开XSLT 文件支持,扩展了libXML2库 ,需要libxslt软件 --with-xsl #libxml2库的支持 --with-libXML-dir #xml-rpc的c语言 --with-XMLrpc ############字体 #打开gnu 的gettext 支持,编码库用到 --with-gettext #打开freetype1.*的支持,可以不加了 --with-ttf #freetype字体库的支持 --with-freetype-dir #关闭iconv函数,种字符集间的转换 --without-iconv #mbstring 多字节扩展 --enable-mbstring ############图片 #jpeg图片的支持 --with-jpeg-dir #png图片的支持 --with-png-dir #激活 GD 支持,可以指定扩展位置。编译 GD 库需要libpng 和 libjpeg。建议通过 sudo apt-get install php7.2-gd 或 yum install php72w-gt 安装。 --with-gd[=DIR] #打开图片大小调整,用到zabbix监控的时候用到了这个模块 --enable-bcmath #图片的元数据支持 --enable-exif #支持ncurses 屏幕绘制以及基于文本终端的图形互动功能的动态库 --with-ncurses ############加密 --with-mcrypt --with-mhash #openssl --with-openssl[=DIR] #支持perl的正则库 --with-pcre #perl的正则库案安装位置 --with-pcre-dir=/usr/local/bin/pcre-config --enable-mbregex ############数据库 #mariadb sock文件位置 --with-mysql-sock[=SOCKPATH] --enable-sockets #mariadb 安装目录 --with-mysqli=mysqlnd #mariadb mysql_config 文件位置,包括文件名 --with-mysqli=mysqlnd --enable-pdo --with-pdo-mysql=mysqlnd #freeTDS需要用到的,可能是链接mssql 才用到 --enable-pcntl --enable-dbase --disable-dmalloc #dba的gdbm支持 --with-gdbm
[root@master temp]# cat php.txt --prefix=/share/php/php7.4.3 --with-apxs2=/share/apache/bin/apxs --with-config-file-path=/share/php/php7.4.3/etc --enable-fpm --with-fpm-user=root --with-fpm-group=root --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --with-libmbfl --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-pear --enable-maintainer-zts --with-ldap=shared --without-gdbm [root@master temp]# ls 1.txt dmt.sh gege.service gege.service.bak groupauth init.sh php.txt port80 port81 qichong quchong sslweb temp userauth [root@master temp]# for i in `cat php.txt`; do echo -e -n "$i "; done; --prefix=/share/php/php7.4.3 --with-apxs2=/share/apache/bin/apxs --with-config-file-path=/share/php/php7.4.3/etc --enable-fpm --with-fpm-user=root --with-fpm-group=root --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --with-libmbfl --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-pear --enable-maintainer-zts --with-ldap=shared --without-gdbm
error: the HTTP XSLT module requires the libxml2/libxslt yum -y install libxml2 libxml2-dev yum -y install libxslt-devel error: the HTTP image filter module requires the GD library. yum -y install gd-devel error: the GeoIP module requires the GeoIP library. yum -y install GeoIP GeoIP-devel GeoIP-data error: the Google perftools module requires the Google perftools yum -y install gperftools error: libatomic_ops library was not found. yum -y install libuuid-devel libblkid-devel libudev-devel fuse-devel libedit-devel libatomic_ops-devel error trying to exec 'cc1plus': execvp: No such file or directory yum -y install gcc-c++ error: [pool www] cannot get uid for user 'www-data' groupadd www-data useradd -g www-data www-data configure: error: mbed TLS libraries not found. 。 需要安装mbedtls,教程:https://www.24kplus.com/linux/281.html error: Cannot find OpenSSL's <evp.h> yum install openssl openssl-devel ln -s /usr/lib64/libssl.so /usr/lib/ error: Libtool library used but 'LIBTOOL' is undefined yum install libtool exec: g++: not found yum -y update gcc yum -y install gcc+ gcc-c++ configure: error: tss lib not found: libtspi.so yum install trousers-devel Can't exec "autopoint": No such file or directory yum install gettext gettext-devel gettext-common-devel configure: error: libcrypto not found. yum remove openssl-devel yum -y install openssl-devel configure: error: Package requirements (libffi >= 3.0.0) were not met: No package 'libffi' found yum install libffi-devel fatal error: uuid.h: No such file or directory yum install e2fsprogs-devel uuid-devel libuuid-devel configure: error: openssl lib not found: libcrypto.so yum install openssl-devel tar (child): lbzip2: Cannot exec: No such file or directory yum -y install bzip2 configure: error: C++ preprocessor "/lib/cpp" fails sanity check yum install gcc-c++ configure: error: Please reinstall the BZip2 distribution yum install bzip2 bzip2-devel configure: error: cURL version 7.15.5 or later is required to compile php with cURL support yum install curl-devel configure: error: not found. Please provide a path to MagickWand-config or Wand-config program yum install ImageMagick-devel configure: error: no acceptable C compiler found in $PATH yum install gcc configure: error: Package requirements (icu-uc >= 50.1 icu-io icu-i18n) were not met: yum install libicu-devel configure: error: Package requirements (sqlite3 > 3.7.4) were not met: No package 'sqlite3' found yum install sqlite-devel configure: error: Package requirements (oniguruma) were not met: No package 'oniguruma' found yum install oniguruma oniguruma-devel
————Blueicex 2020/2/26 07:45 blueice1980@126.com
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。