学习目标:
centos7安装apache2.4.53+php8.1.3
学习内容
1.安装apache
1.安装必要依赖
yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel
yum install libxml2-devel -y
yum install openssl openssl-devel
yum install bzip2 bzip2-devel -y yum install curl-devel -y
yum install libjpeg-devel -y
yum install libpng libpng-devel -y
yum install freetype-devel -y yum install libxslt-devel -y
yum install libzip-devel -y
yum install libxml2-devel
yum -y install autoconf automake libtool
yum install sqlite-devel
yum install expat-devel -y
git clone https://github.com/kkos/oniguruma
cd oniguruma
./autogen.sh
./configure --prefix=/usr --libdir=/lib64
make && make install
2.下载apr-1.7.0
cd /opt
wgethttps://dlcdn.apache.org//apr/apr-1.7.0.tar.gz
tar -zxvf /opt/apr-1.7.0.tar.gz
make -p /usr/local/apr
cd /opt/apr-1.7.0
./configure --prefix=/usr/local/apr
make && make install
编译时报错
rm: cannot remove ‘libtoolT’: No such file or directory
参考
https://blog.csdn.net/weixin_44656934/article/details/90075806
3.下载apr-util-1.6.1
wget https://dlcdn.apache.org//apr/apr-util-1.6.1.tar.gz
tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
4.下载pcre
wget https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.39/pcre2-10.39.tar.gz
cd pcre2-10.39
make -p /usr/local/pcre
./configure --prefix=/usr/local/pcre
make && make install
5.下载apache包
wget https://dlcdn.apache.org/httpd/httpd-2.4.53.tar.gz
cd httpd-2.4.46
mkdir -p /usr/local/httpd
./configure --prefix=/usr/local/httpd/ --enable-shared=max--enable-module=rewirte --enable-module=so --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
make && make install
执行make命令报错
libtool: error: cannot find the library ‘/usr/local/apr-util//lib/libapr-1.la’ or unhandled argument ‘/usr/local/apr-util//lib/libapr-1.la’
修复方案参考如下:
https://blog.netimed.cn/archives/Linux/20200212/207.html
2.安装php8.1.4
1.下载php8.1.4
wget https://www.php.net/distributions/php-8.1.4.tar.gz
2.编译php8.1.4
cd /opt/
tar -zxvf php-8.1.4.tar.gz
cd /opt/php8.1.4/php-8.1.4
3.编译前检查
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --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 --with-config-file-path=/etc
编译安装
make && make install
centos7开放80端口
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT