EverKB

Knowledge Base Ever

Kompiler og installer Apache 2.4 på CentOS7

2019-11-15 12:18:53

tag: CentOS, Apache, CentOS7, Apache2.4, Compiling Apache, Kompilér Apache httpd2.4

CentOS7 leveres med en Apache httpd (i det følgende benævnt httpd) -tjeneste. Hvis du ikke inkluderer denne service på din maskine, kan du bruge yum til at installere den.

Hvis du har brug for at installere en ny version af httpd, f.eks. Httpd2.4, skal du samle den selv. Kompilationsprocessen er ikke kompliceret, kun de afhængige pakker skal kompileres og installeres, hvilket gør hele processen noget kompliceret.

Afinstaller den gamle version, installer build-værktøjet, og afinstaller den gamle version af installationspakken

yum -y remove httpd

yum -y install gcc gcc-c++
yum -y group install "Development Tools"

yum -y remove apr apr-devel apr-util apr-util-devel

Installer apr

cd /usr/local/src/
yum -y install wget
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz
tar xf apr-1.7.0.tar.gz
cd apr-1.7.0
./configure --prefix=/usr/local/apr
make && make install

Installer apr-util

yum -y install expat-devel

cd /usr/local/src/
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
tar xf apr-util-1.6.1.tar.gz 
cd apr-util-1.6.1
./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config 
make && make install

Installer pcre

cd /usr/local/src/
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.43.tar.gz
tar xf pcre-8.43.tar.gz 
cd pcre-8.43
./configure --prefix=/usr/local/pcre  
make && make install

Kompilér httpd

cd /usr/local/src/
wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.39.tar.gz
tar xf httpd-2.4.39.tar.gz
cd httpd-2.4.39
./configure --prefix=/usr/local/apache --enable-rewrite --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
make && make install

Rediger /etc/init.d/httpd konfigurationsfil, konfigurer systemctl til at starte

#!/bin/bash
# chkconfig: 12345 80 90
function start_http()
{
    /usr/local/apache/bin/apachectl start
}
function stop_http()
{
    /usr/local/apache/bin/apachectl stop
}
case "$1" in
start)
    start_http
;;
stop)
    stop_http
;;
restart)
    stop_http
    start_http
;;
*)
    echo "Usage : start | stop | restart"
;;
esac

Indstil eksekverbare tilladelser, start tjenesten, og indstil til at starte, når du starter

chmod a+x /etc/init.d/httpd
systemctl daemon-reload
systemctl start httpd
chkconfig --add httpd

tag

CentOS7 CentOS PHP Linux Python3 Python MySQL MariaDB YUM JavaScript CSS Redis MySQL8 caching_sha2_password HTML mysql_native_password PHP7 MariaDB10.4 PostgreSQL sub folder availability eth0 Install MongoDB pdo_sqlsrv SOCKS5 Web Server date mssql-tools register_shutdown_function Symfony File Upload JetBrain php-fpm sqlsrv Zend Framework ADDDATE DevExpress height network interface Shadowsocks-Libev unixODBC-devel Port 80 string Aura error_get_last INDENTIFIED BY password policy requirements SOCKS Web Development data msodbcsql Redis5 SVN Fedora Media Writer jemalloc SQLAlchemy absolute Deepin FuelPHP mysqlclient Shadowsocks toggle convert margin PHPUnit Framework ss5.passwd at-symbol Error Control Operator IIS password SOCKET vps daemon process MongoDB4 sudoers center Fatal Errors Phalcon SQL Server 2017 WiFi .htaccess DATE_SUB set_error_handler TestCase Compiling PHP frequency conflict PHPUnit ss5.conf apr Elasticsearch7.3 HTTP particles.js Slim Vincent Garreau daemon MongoDB Sudo Failed to build these modules: _uuid ip command pg_bha.conf SQL Server width DATE_ADD MySQL-python scrollbar Tcp BBR Compiling Apache Frameworks libpython3.7m.so.1.0 PHPStorm ss5-3.8.9 Apache2.4 Elasticsearch NodeJs show VIM CURLOPT_POSTFIELDS Minimal ISO substr Bluetooth Failed to build these modules: _ctypes INTERVAL PECL SQL Date Funcitons Wi-Fi date sub root Tag Cloud CodeIgniter font-size Laravel ss5 apache httpd dual network interfaces horiz-align node.js ShadowsocksR vertical-align CURLFille mb_substr PyCharm SUBDATE BarManager exec IntelliJIDEA PEAR SOCKS5 Proxy Server WebStorm date add remi Tag Chrome find jQuery PHP5.5 src Apache du hide nginx Shadowsocks-Python V2Ray cURL