How to install PHP5.6 when using apache2.4.28 complile from source on Ubuntu 16.04?
I believe you have done several things wrong. First this line:
./configure --prefix=/etc/apache2 --enable-mods-shared="reallyall" --enable-mpms-shared="all"
should have been:
./configure --prefix=/usr/local/apache2" --enable-mods-shared="reallyall" --enable-mpms-shared="all"
Your --prefix
option during compile is wrong. I advice you remove it and fix that --prefix
option
How to compile:
Download the source file for the version you want
-
Install build requirements:
sudo apt-get install build-essential
-
Install
Zlib
for compresssion with these steps:cd /usr/local/src wget http://www.zlib.net/zlib-1.2.8.tar.gz tar xvfz zlib-1.2.8.tar.gz cd zlib-1.2.8/ ./configure --prefix=/usr/local make
-
Compile apache with these steps:
-
Move the downloaded
apache
source file into/usr/local/src
, thencd /usr/local/src tar xvfz httpd-2.4.10.tar.gz cd httpd-2.4.10/ sudo ./configure
-
If you get
APR
error run :sudo apt install libapr1-dev libaprutil1-dev
-
-
If successful run:
sudo make sudo make install
-
-
Check to see if it's working:
sudo /usr/local/apache2/bin/apachectl start
- put
http://localhost
or your machine ip address and you should see a message saying "It works!"
- put
-
Enable
boot startup
:sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/apache2 sudo chmod +x /etc/init.d/apache2
-
Add to default
runlevels
:sudo /usr/sbin/update-rc.d -f apache2 defaults
Source:
http://www.linuxpathfinder.com/install-apache-from-source-on-ubuntu
Ouch... Building Apache + PHP can be done + the build process can be painfully long + error prone.
Here's how I use the latest stable PPAs for installing latest Apache + also PHP which can be easily switched between 5.6 or 7.0 or 7.1 + soon 7.2, when it goes stable.
I do this in LXD containers, so machine (host level) contains only default code + LXD + no LAMP stack code.
Here's how I'd install latest stable LXD + Apache + MariaDB + PHP (5.6) + OpenSSL + HTTP2 + FPM (which is now required for running HTTP2) + Dovecot.
Steps I use to setup client hosting LXD container LAMP Stacks...
# Setup repositories, some of which require a bit of trickery
add-apt-repository ppa:ubuntu-lxc/lxd-stable < /dev/null
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php </dev/null
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/apache2 </dev/null
add-apt-repository ppa:pdoes/dovecot </dev/null
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
echo "deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.2/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/mariadb-$(lsb_release -sc).list
apt-get update
# Install PHP-5.6 based LAMP
apt-get install mariadb-server mariadb-client libmysqlclient-dev
apt-get install php5.6-fpm php5.6-cli php5.6-mbstring php5.6-zip \
php5.6-mysql php5.6-curl php5.6-xml php5.6-xmlrpc \
php5.6-gd php5.6-soap php5.6-gmp php5.6-pspell \
php5.6-sqlite3 php5.6-tidy php5.6-xsl php5.6-bz2 \
php5.6-tidy php5.6-bcmath php5.6-bz2 php5.6-dba
a2enmod mpm_event proxy_fcgi setenvif alias cgid ssl http2 \
expires headers include rewrite
a2enconf php5.6-fpm
# update PHP CLI, when multiple versions installed
update-alternatives --set php /usr/bin/php5.6
# tune FPM pool + php.ini + opcache.ini + xdebug.ini + cold restart FPM
service service php5.6-fpm
Taking this approach will give you latest stable Apache + PHP + OpenSSL + as packaged code (no hand rolled builds).
You'll also get upstream bug fixes, as bugs are discovered.
If you hand roll your own, you'll have to constantly check many diff mailing lists to know when to rebuild + how to apply patches... which is another massively time consuming endeavor.
BTW, Apache-2.4.28 just released last week, so this Apache version will appear in the ondrej PPA as soon as it's packaged + code tested.
Likely sometime this week or next, so you'll end up with Apache-2.4.27 installed today.