0

I try to compile Apache 2.4.28 from source, I can't use command

apt-get install apache2

Because this command install Apache 2.4.18 only.

Here is my install step:

  • Install dependency

    apt-get install build-essential 
    apt-get install libexpat1-dev
    apt-get install libpcre3-dev libssl-dev 
    
  • Download apache2.4.28

    cd /usr/local/src    
    wget http://mirrors.viethosting.com/apache//apr/apr-1.6.2.tar.gz 
    wget http://mirrors.viethosting.com/apache//apr/apr-util-1.6.0.tar.gz
    wget http://archive.apache.org/dist/httpd/httpd-2.4.28.tar.gz
    
  • Compile apache 2.4.28

    tar xzvf apr-1.6.2.tar.gz
    tar xzvf apr-util-1.6.0.tar.gz
    tar xzvf httpd-2.4.28.tar.gz
    mv apr-1.6.2/ httpd-2.4.28/srclib/apr
    mv apr-util-1.6.0/ httpd-2.4.28/srclib/apr-util
    ./configure --prefix=/etc/apache2 --enable-mods-shared="reallyall" --enable-mpms-shared="all"
    

    Configure result

    make && make install
    

    enter image description here

    ln -s /etc/apache2/bin/apachectl /etc/init.d/apache
    update-rc.d apache defaults----> It has this warning "insserv: warning: script 'apache' missing LSB tags and overrides"
    
    service apache start
    

After performing the above steps, Apache 2.4.28 has been run. But I when I use

apache2 -v ----> it's not show the version of apache2

enter image description here

Then I install PHP5.6 like this:

apt-get install software-properties-common
add-apt-repository ppa:ondrej/php
apt-get update
apt-get install php5.6

When I use this command it not only install php5.6 but also install apache2.4.18 and when I test PHP by:

echo "hello world"; ----> it not show any thing.

And

root@ubuntu:~# ps -aux | grep httpd
root        991  0.0  0.1  75268  3848 ?        Ss   02:47   0:00 /usr/local/apache2/bin/httpd -k start

@Edit: as the comment I change:

./configure --prefix=/etc/apache2 --enable-mods-shared="reallyall" --enable-mpms-shared="all"

to

./configure --prefix=/usr/local/apache2 --enable-mods-shared="reallyall" --enable-mpms-shared="all"

Please help me, thank in advance.

  • Is apache on your path, run which apache2 and lets see what you get! – George Udosen Oct 12 '17 at 7:49
  • It not return any things :( – nistelrooy41001662 Oct 12 '17 at 8:00
  • @George: I add some info to make my question clearly. – nistelrooy41001662 Oct 12 '17 at 8:03
  • You installed it in /etc/ and I don't think that the right place for a binary at least on Ubuntu! – George Udosen Oct 12 '17 at 8:10
1

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.

  • You're welcome! BTW, Apache-2.4.29 has also released. When you're building from source, I suggest you setup Google Alerts to track all packages which change in your specific runtime stack. Then you'll know when you have to rebuild all your code. – David Favor Nov 1 '17 at 13:09
0

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:

  1. Download the source file for the version you want

  2. Install build requirements:

    sudo apt-get install build-essential
    
  3. 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
    
  4. Compile apache with these steps:

    • Move the downloaded apache source file into /usr/local/src, then

      cd /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
      
  5. 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!"
  6. Enable boot startup:

    sudo cp /usr/local/apache2/bin/apachectl /etc/init.d/apache2
    sudo chmod +x /etc/init.d/apache2
    
  7. Add to default runlevels:

    sudo /usr/sbin/update-rc.d -f apache2 defaults
    

Source:

http://www.linuxpathfinder.com/install-apache-from-source-on-ubuntu

  • let me try again – nistelrooy41001662 Oct 12 '17 at 8:13
  • I am install ubuntu 16.04 again in vmware, i am waiting it done, ah, Have you tried to install PHP in your way? – nistelrooy41001662 Oct 12 '17 at 8:28
  • I cant' do this command sudo make install in step 4 – nistelrooy41001662 Oct 12 '17 at 8:57
  • Ok one moment let me correct that, see update! – George Udosen Oct 12 '17 at 9:00
  • Ok do sudo ./configure – George Udosen Oct 12 '17 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.