Forked from algotrader-dotcom/Compile apache 2.4 + php from source
Last active
November 3, 2021 14:58
-
-
Save z2z/3bf4c60b7f0c0171d410d54bad088e6e to your computer and use it in GitHub Desktop.
Compile apache 2.4 + php from source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Requirements | |
yum install pcre* | |
yum install libxml* | |
yum install gdbm-devel | |
2. Download packages | |
# http://mirrors.wuchna.com/apachemirror//apr/apr-1.6.5.tar.bz2 | |
# http://mirrors.wuchna.com/apachemirror//apr/apr-util-1.6.1.tar.bz2 | |
# http://php.net/get/php-5.6.38.tar.bz2/from/a/mirror | |
# https://www-eu.apache.org/dist//httpd/httpd-2.4.37.tar.bz2 | |
# tar xvzf file.tar.gz- to uncompress a gzip tar file (.tgz or .tar.gz) | |
# tar xvjf file.tar.bz2 - to uncompress a bzip2 tar file (.tbz or .tar.bz2) to extract the contents. | |
3. Install Apache | |
mv apr-1.5.2 /usr/src/httpd-2.4.16/srclib/apr | |
mv apr-util-1.5.2 /usr/src/httpd-2.4.16/srclib/apr-util | |
./configure --prefix=/opt/apache24 \ | |
--enable-so \ | |
--enable-cgi \ | |
--enable-info \ | |
--enable-rewrite \ | |
--enable-speling \ | |
--enable-usertrack \ | |
--enable-deflate \ | |
--enable-ssl \ | |
--enable-mime-magic \ | |
--with-included-apr | |
make && make install | |
4. Install PHP | |
./configure --with-apxs2=/opt/apache24/bin/apxs --with-mysql --prefix=/opt/apache24/php --with-config-file-path=/opt/apache24/php --enable-force-cgi-redirect --disable-cgi --with-zlib --with-gettext --with-gdbm --enable-pdo=shared --with-pdo-mysql=shared --without-pdo-sqlite | |
make && make install | |
cp php.ini-production /opt/apache24/php/php.ini | |
Update php.ini | |
include_path = "/opt/apache24/php/lib/php" | |
extension = mysql.so | |
extension = mysql_pdo.so | |
5. Re check | |
/opt/apache24/bin/httpd -M | |
/opt/apache24/bin/httpd -t | |
Update httpd.conf: | |
LoadModule php5_module modules/libphp5.so | |
AddHandler php5-script .php | |
DirectoryIndex index.html index.php | |
AddType text/html .php | |
LoadModule vhost_alias_module modules/mod_vhost_alias.so | |
Include conf/extra/httpd-vhosts.conf | |
6. Start service | |
/opt/apache24/bin/apachectl start | |
7. Troubleshooting | |
# Apache2: AH01630: client denied by server configuration | |
<VirtualHost *:80> | |
... | |
<Directory "/var/www/html/example.com/public"> | |
Options MultiViews FollowSymLinks | |
AllowOverride all | |
Order allow,deny | |
Allow from all | |
</Directory> | |
... | |
</VirtualHost> | |
# .. | |
8. Install php modules | |
# memcache | |
wget http://pecl.php.net/get/memcache-2.2.4.tgz | |
tar -zxvf memcached-2.2.4.tgz | |
cd memcached-2.2.4 | |
/opt/apache24/php/bin/phpize | |
./configure --enable-memcache --with-php-config=/opt/apache24/php/bin/php-config | |
make && make install | |
Update php.ini with extension = memcache.so | |
9. References | |
http://dan.drydog.com/apache2php.html | |
http://moiseevigor.github.io/software/2015/05/18/apache2-ah01630-client-denied-by-server-configuration/ | |
https://blogs.oracle.com/opal/the-php-quotconfigure-with-oci8quot-option-in-detail |
It doesn't go through the PHP stuff, but these instructions actually work on CentOS 7: https://www.linuxhelp.com/how-to-install-apache-from-source-code-on-centos-7
The instructions are for an older version of Apache 2.4. Idk if they work for newer versions.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In step 3, it's unclear in what directory the ./configure needs to be run.