EverKB

Knowledge Base Ever

Sett sammen og installer Apache 2.4 på CentOS7

2019-11-15 12:18:53

tag: CentOS, Apache, CentOS7, Apache2.4, Compiling Apache, Sett sammen Apache httpd2.4

CentOS7 kommer med en Apache httpd (heretter kalt httpd) -tjeneste. Hvis du ikke inkluderer denne tjenesten på maskinen din, kan du bruke yum til å installere den.

Hvis du trenger å installere en ny versjon av httpd, for eksempel httpd2.4, må du kompilere den selv. Samlingsprosessen er ikke komplisert, bare de avhengige pakkene trenger å bli samlet og installert, noe som gjør hele prosessen noe komplisert.

Avinstaller den gamle versjonen, installer byggeverktøyet og avinstaller den gamle versjonen av installasjonspakken

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

Sett sammen 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 konfigurasjonsfil, konfigurer systemctl til å 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

Angi kjørbare tillatelser, start tjenesten og sett til å starte opp ved oppstart

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

tag

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