Installing Apache HTTP is always fun. A few days back, I was installing Apache 2.4 on CentOS VM and encountered multiple errors.
I thought it would be helpful to put together for a reference.
APR not found
[root@chandan httpd-2.4.25]# ./configure --enable-ssl checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu configure: configure: Configuring Apache Portable Runtime library... configure: checking for APR... no configure: error: APR not found. Please read the documentation. [root@chandan httpd-2.4.25]#
APR stands for “Apache Portable Runtime” and needed to compile from the source. If you are in the same situation as me then following will rescue you.
First, you need to install APR.
- Download the latest version of APR using wget
wget https://www-eu.apache.org/dist/apr/apr-1.6.3.tar.gz .
- Extract the downloaded file
gunzip -c apr-1.6.3.tar.gz | tar xvf -
- it will create a new folder “apr-1.6.3”
- Go inside and compile with configure command
./configure
It will take a few seconds and once done you will get a prompt back (ensure no error).
- The last step would be to install using make command
make make install
Once done, I tried installing Apache and got another error.
APR-util not found
[root@chandan httpd-2.4.25]# ./configure --enable-ssl --enable-so checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu configure: configure: Configuring Apache Portable Runtime library... configure: checking for APR... yes setting CC to "gcc" setting CPP to "gcc -E" setting CFLAGS to " -g -O2 -pthread" setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE" setting LDFLAGS to " " configure: configure: Configuring Apache Portable Runtime Utility library... configure: checking for APR-util... no configure: error: APR-util not found. Please read the documentation. [root@chandan httpd-2.4.25]#
In case you have “APR-util not found” error as well then you got to install the following.
- Download the latest APR-util source
wget https://www-eu.apache.org/dist/apr/apr-util-1.6.1.tar.gz .
- Extract the downloaded gz file
gunzip -c apr-util-1.6.1.tar.gz | tar xvf -
- Go inside the newly created folder “apr-util-1.6.1” and install using the following commands
./configure --with-apr=/usr/local/apr/bin/apr-1-config make make install
Tried installing Apache again and got another error.
pcre-config for libpcre not found
This is what I got.
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for gcc option to accept ISO C99... -std=gnu99
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
PCRE stands for Perl Compatible Regular Expressions, and this error got an easy solution. You just to install pcre-devel package.
yum install pcre-devel
Not over yet, got another in next attempt related to OpenSSL.
OpenSSL version is too old
checking whether to enable mod_slotmem_plain... no checking whether to enable mod_ssl... checking dependencies checking for OpenSSL... checking for user-provided OpenSSL base directory... ./configure: line 25426: cd: /usr/bin/openssl: Not a directory /root/httpd-2.4.25 adding "-I/root/httpd-2.4.25/include" to CPPFLAGS setting MOD_CFLAGS to "-I/root/httpd-2.4.25/include" setting ab_CFLAGS to "-I/root/httpd-2.4.25/include" adding "-L/root/httpd-2.4.25/lib" to LDFLAGS setting MOD_LDFLAGS to "-L/root/httpd-2.4.25/lib" checking for OpenSSL version >= 0.9.8a... FAILED configure: WARNING: OpenSSL version is too old no checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures [root@chandan httpd-2.4.25]#
The first thing you have to ensure you have the latest version of OpenSSL which was in my case, so I needed to install the devel package, and it was all right.
yum install openssl-devel
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
While compiling APR, I got this error.
[root@instance-1 apr-util-1.6.1]# make make[1]: Entering directory `/opt/temp/apr-util-1.6.1' /bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/opt/temp/apr-util-1.6.1/include -I/opt/temp/apr-util-1.6.1/include/private -I/usr/local/apr/include/apr-1 -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory #include <expat.h> ^ compilation terminated. make[1]: *** [xml/apr_xml.lo] Error 1
If you are getting this error, then this can be resolved by installing expat-devel
package.
yum install expat-devel
configure: error: no acceptable C compiler found in $PATH
C compiler not found is typical for any software build, and you can fix this by installing the compiler.
yum install gcc
nghttp2 version is too old
This is specific to when you try to install Apache with HTTP/2. You will get the following error.
checking whether to enable mod_http2... checking dependencies
checking for OpenSSL... (cached) yes
setting MOD_LDFLAGS to " -lssl -lcrypto -lrt -lcrypt -lpthread"
setting MOD_CFLAGS to " "
setting MOD_CPPFLAGS to "-DH2_OPENSSL"
checking for nghttp2... checking for user-provided nghttp2 base directory... none
checking for pkg-config along ... checking for nghttp2 version >= 1.2.1... FAILED
configure: WARNING: nghttp2 version is too old
no
checking whether to enable mod_http2... configure: error: mod_http2 has been requested but can not be built due to prerequisite failures
And, if so, you can fix by installing nghttp2 as below.
- Download the latest version of nghttp2 from here
wget https://github.com/nghttp2/nghttp2/releases/download/v1.37.0/nghttp2-1.37.0.tar.gz
- Extract the downloaded file
tar -xvf nghttp2-1.37.0.tar.gz
- It will create a new folder, go inside that and run the following
./configure
make
make install
Once done without error, run the Apache source build with HTTP2 again. It should be alright.
Finally, I was able to install Apache successfully. If you are interested in learning about Apache HTTP Server Administration, then check out this online course.
During Apache httpd installation if you get below error, that means Apache Portable Run-time environment was not found or not installed.
checking for APR... no configure: error: APR not found. Please read the documentation.
and/or
checking for APR-util... no configure: error: APR-util not found. Please read the documentation.
So install APR and APR-util and give httpd those paths. Httpd will be happy to run for you after that… 🙂
Go further if you want to know how to install APR.
You can download APR and APR-util from here.
Then extract those to separate folders.
First change to the extract APR directory and install it. (Tip: cd command to change directory)
sudo ./configure --prefix=<apr-path> sudo make sudo make install
So you have a working APR. Next is APR-util.
Change to the extract APR-Util directory and install it. (Tip: cd command to change directory)
sudo ./configure --prefix=<apr-util-path> --with-prefix=<apr-path> sudo make sudo make instal
Install zlib packages with the command (optional; you can turn this off at your will):
yum install zlib zlib-devel
Apart from APR and APR-Util, you may need to install pcre too. So download it from here first.
Change to the directory and use the below commands to install.
sudo ./configure --prefix=<pcre-path> sudo make sudo make install
Now lets make httpd understand that we have a working pcre, APR and APR-util.
./configure --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache --enable-deflate --enable-expires --enable-headers --enable-usertrack --enable-cgi --enable-vhost-alias --enable-rewrite --enable-so --prefix=<httpd-path> --with-apr=<apr-path> --with-apr-util=<apr-util-path> --with-pcre=<pcre-path>
# Rest is history make make install
Sreejith
A strong believer of:
1. Knowledge is power
2. Progress comes from proper application of knowledge
3. Reverent attains wisdom
4. For one’s own salvation, and for the welfare of the world
View all posts by Sreejith
Apache httpd source installation prompt APR error
1. Download HTTPD source package
https://www.apache.org/
Choose the site of Chinese domain name cn:
Find httpd:
2. Back in Linux CentOS, download the httpd compressed package using the wget name:
[root@magedu ~]# wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.38.tar.gz --2019-07-21 13:16:50-- https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.38.tar.gz Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1 Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 9187294 (8.8M) [application/x-gzip]
3. Unzip and download files;
[root@magedu ~]# tar zxvf httpd-2.4.38.tar.gz httpd-2.4.38/ httpd-2.4.38/config.layout httpd-2.4.38/configure.in httpd-2.4.38/Makefile.win httpd-2.4.38/configure httpd-2.4.38/test/ httpd-2.4.38/test/test_parser.c httpd-2.4.38/test/check_chunked httpd-2.4.38/test/make_sni.sh httpd-2.4.38/test/README httpd-2.4.38/test/test-writev.c httpd-2.4.38/test/test_limits.c httpd-2.4.38/test/tcpdumpscii.txt
4. Install the compiler and development kit before decompressing.
` [root@magedu ~]# yum install gcc "Developent Tools"`
5. Enter the decompressed httpd directory to see the help information of configure
[root@magedu ~]# cd httpd-2.4.38/ [root@magedu httpd-2.4.38]# ./configure --help
6. Installation using configuration files
[root@magedu httpd-2.4.38]# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu configure: configure: Configuring Apache Portable(Transplantation) Runtime library(Runtime libraries)... configure: checking for APR... no configure: error: APR not found. Please read the documentation.(Error: APR No, please read the document.
Tips for error reporting:
Congure: error: APR not found. Please read the documentation. (Error: APR not found, please read the document)
Tips do not find APR, use yum to install, but must pay attention to the installation, tips to install which software, usually add devel after the software, that is to say, to install the lack of software development tools, such as this tip apr, it is necessary to install apr-devel:
#yum install apr-devel
After the installation is completed, then. / configure;
In particular, during this period, you can not switch to other directories, the entire installation process must be in the root directory of the installation software;
[root@magedu httpd-2.4.38]# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd checking for APR-util... no configure: error: APR-util not found. Please read the documentation.
Hint for missing apr-util, then install the development version of apr-util, apr-util-devel
root@magedu httpd-2.4.39]# yum install apr-util-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check --> Processing Dependency: libdb-devel(x86-64) for package: apr-util-devel-1.5.2-6.el7.x86_64 --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: apr-util-devel-1.5.2-6.el7.x86_64 --> Running transaction check ...
After the installation is complete, then. / configure
[root@magedu httpd-2.4.38]# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd checking for pcre-config... false configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
Prompt PCRE to report an error and install pcre. This PCRE also has to install the development version, that is, install pcre-devel:
[root@magedu httpd-2.4.39]# yum install pcre-devel -y
After the installation is complete, then. / configure
# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd checking for chosen layout... Apache checking for working mkdir -p... yes checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu configure: ... config.status: creating include/ap_config_auto.h config.status: executing default commands configure: summary of build options: Server Version: 2.4.39 C compiler: gcc -std=gnu99 CFLAGS: -pthread CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE LDFLAGS: LIBS: C preprocessor: gcc -E
Eventually succeeded, using echo$? Check whether it succeeded:
[root@magedu httpd-2.4.39]# echo $? 0
Then use make
[root@magedu httpd-2.4.39]# make Making all in srclib make[1]: Entering directory `/soft/httpd-2.4.39/srclib' make[1]: Leaving directory `/soft/httpd-2.4.39/srclib' Making all in os
Finally: make install
[root@magedu httpd-2.4.39]#make install
7. After completion, configure PATH variable and man manual. After completion, start the service, login address and test page appear, which means the installation is successful.
Я думал, что установить apache под Linux будет несложно. Можно выполнить три команды: распаковка jxvf, выполнение компиляции, выполнение установки, установка в порядке. Неожиданно этот процесс оказался неудачным. Возможно, это как-то связано с окружающей средой. Позвольте мне сначала поговорить о моем окружении.
—————————
linux: cenos5.5 (при проверке 4.8 также возникнут следующие проблемы)
apache: httpd-2.4.1.tar.bz2
—————————
[[email protected] apache]# tar jxvf httpd-2.4.1.tar.bz2 //РазархивироватьapacheСжатый пакет
[[email protected] apache]# cd httpd-2.4.1 //Таргетингhttpd-2.4.1 В папке
[[email protected] httpd-2.4.1]# ls //Просмотр дисплеяhttpd-2.4.1 Содержимое в папке
[root @ localhost httpd-2.4.1] #. / configure — help | more // Просмотр параметров конфигурации apache
[root @ localhost httpd- 2.4.1] #. / configure — prefix = / usr / local / apache — enable-so / / Настроить путь к apache, за которым следует параметр —enable-so, чтобы позволить ядру apache загружать DSO
[root @ localhost httpd-2.4.1] #make // компилировать apache
ошибка! незамедлительный:
configure: error: APR not found. Please read the documentation
Вы можете скачать apr-1.4.6.tar.gz на официальном сайте apache
Решить проблему апр не найден >>>>
Скачать адрес APR и APR-UTIL:http://apr.apache.org/download.cgi
[[email protected] apache]# tar -zxf apr-1.4.6.tar.gz
[[email protected] apache]# cd apr-1.4.6
[[email protected] apr-1.4.6]# ./configure —prefix=/usr/local/apr
[[email protected] apr-1.4.6]# make
[[email protected] apr-1.4.6]# make install
После завершения установки снова скомпилируйте apache
[[email protected] httpd-2.4.1]# make
Что-то опять пошло не так! незамедлительный:
configure: error: APR-util not found. Please read the documentation
Хорошо! Или загрузите адрес официального сайта apache выше apr-util-1.4.1.tar.gz
Решить проблему APR-util не найден >>>>
[[email protected] apache]# tar -zxf apr-util-1.4.1.tar.gz
[[email protected] apache]# cd apr-util-1.4.1
[[email protected] apr-util-1.4.1]# ./configure —prefix=/usr/local/apr-util —with-apr=/usr/local/apr/bin/apr-1-config
[[email protected] apr-util-1.4.1]# make
[[email protected] apr-util-1.4.1]# make install
Давайте снова скомпилируем apache, и снова выйдет ошибка! незамедлительный:
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/ , I X! Взаимосвязь между установочным программным обеспечением Linux иногда может привести к сбою в работе.
../configure по-прежнему запрашивает APR-util not found, добавьте —with-apr = / usr / local / apr —with-apr-util = / usr / local / apr-util, а затем появится >>>>>>
[[email protected] apache]# ./configure –help | grep pcre
—with-pcre=PATH Use external PCRE library
ссылка для скачивания:http://ftp.exim.llorien.org/pcre/
Загрузите pcre-8.30.zip, есть много файлов списков, обычные браузеры будут иметь функцию поиска, вы можете искать и находить их с помощью ctrl + f и загружать.
[[email protected] apache]#unzip -o pcre-8.30.zip
[[email protected] apache]#cd pcre-8.30
[[email protected] pcre-8.30]#./configure —prefix=/usr/local/pcre
[[email protected] pcre-8.30]#make
[[email protected] pcre-8.30]#make install
Скомпилировать Apache
[[email protected] httpd-2.3.12-beta]# ./configure —prefix=/usr/local/apache2 —with-apr=/usr/local/apr —with-apr-util=/usr/local/apr-util/
Обратите внимание, что следующие здесь параметры должны соответствовать пути, по которому ранее были установлены apr и apr-util.
[[email protected] httpd-2.4.1]# make
[[email protected] httpd-2.4.1]# make install
На этот раз компиляция и установка больше не должны сообщать об ошибках. Ха-ха! !
Запустить apache
[[email protected] bin]# pwd
/usr/local/apache/bin
[root @ localhost bin] #apachectl stop stop
[root @ localhost bin] #apachectl start start
Проверить, занят ли порт 80
[[email protected] conf]#netstat -an | grep :80
Проверьте, запущена ли служба запуска Apache
[[email protected] bin]# ps -aux | grep httpd
Warning: bad syntax, perhaps a bogus ‘-‘? See /usr/share/doc/procps-3.2.7/FAQ
root 2866 0.0 1.2 25164 9556 ? Ss 22:45 0:00 /usr/sbin/httpd -k start
apache 2867 0.0 0.7 25300 5556 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2868 0.0 0.6 25300 5444 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2869 0.0 0.6 25300 5444 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2870 0.0 0.7 25300 5556 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2871 0.0 0.6 25164 4796 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2872 0.0 0.6 25164 4796 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2873 0.0 0.6 25164 4796 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2874 0.0 0.6 25164 4796 ? S 22:45 0:00 /usr/sbin/httpd -k start
root 3141 0.0 0.0 4244 676 pts/1 R+ 22:48 0:00 grep httpd
Затем проверьте, можно ли открыть страницу apache по умолчанию. http: // ip: 80 / index.html
Снова возникла ошибка:
Порт занят? Измените файл конфигурации apache
/usr/local/apache/conf/httpd.conf файл конфигурации
[[email protected] conf] vi httpd.conf
Найдите следующую строку:
Listen 80 Измените 80 на другие порты, такие как 8080 и 8800, пока они не заняты.
Найдите следующую строку:
ServerName www.example.com:80Измените локальный IP-адрес и номер порта, например: 192.168.0.105:80
Порт был изменен, и все время сообщалось об ошибке. Поскольку у меня не было предыдущего опыта установки apache под Linux, я хочу узнать, какая страница строки запускается по умолчанию. Итак, я нашел файл … / apache / htdocs / index.html (введенный в заблуждение котом)! На самом деле, в противном случае фактическим запущенным является файл в каталоге / var / www / html.
You don’t have permission to access /index.html on this server
Настоящая ошибка находится в этой подсказке. Потому что наших прав доступа к файлам недостаточно. Затем добавьте разрешения к файлу!
Создайте файл index.html в / var / www / html
[[email protected] html]# chmod 766 index.html
Хорошо! Заходим снова в apache, страница открывается нормально! Процесс очень запутанный, а концовка прекрасна!
————резюме—————
Устанавливаемые файлы:
apr-1.4.6
apr-util-1.4.1.tar.bz2
pcre-8.30.zip
/usr/local/apache apacheКаталог установки
/usr/local/apache/conf/httpd.conf Конфигурационный файл
/usr/local/apache/bin/ apachectl stop/start стоп/стартовая программа
/ var / www / html / Создавать доступные страницы в этой папке