Saturday, June 26, 2021

Install Apache 2.4 with PHP 8.0.7 on Linux

There are steps that involve 'wget' command. For the host server to speak to a target mirror (target server), one needs to verify the proxy settings of the host server.

Check if you are able to do a wget. If wget is not working:

  1. Download the files required to the local computer prior to start of this installation
  2. FTP the downloaded files to the required path (location)
  3. Proceed with other installation steps
Dependancies:
yum install expat-devel pcre-devel openssl-devel libxml2* curl-devel libicu* libpng* libldb-dev libldap2-dev ldap* openldap openldap-devel libtool*

Apache Download and Installation:

  1. Change Directory (cd command) to the desired path (location). Here location is /scratch/installation
  2. wget https://archive.apache.org/dist/httpd/httpd-2.4.39.tar.gz
  3. tar -xzvf httpd-2.4.39.tar.gz
  4. cd httpd-2.4.39/srclib/ (Observe the path before the next wget)
  5. wget http://mirrors.estointernet.in/apache/apr/apr-1.7.0.tar.gz
  6. tar -xzvf apr-1.7.0.tar.gz
  7. wget http://mirrors.estointernet.in/apache/apr/apr-util-1.6.1.tar.gz
  8. tar -xzvf apr-util-1.6.1.tar.gz
  9. cd apr-1.7.0
  10. ./configure && make && make install
  11.  cd ../apr-util-1.6.1/
  12.  ./configure --with-apr=/scratch/installation/httpd-2.4.39/srclib/apr-1.7.0 && make && make install
  13. cd ../../
  14. ./configure --prefix=/scratch/installation/apache2 --enable-module=so --enable-ssl
  15. make
  16. make install
~~~~~END OF INSTALLATION~~~~~

Start the server:

/scratch/installation/apache2/bin/apachectl -k start

Stop Server:

/scratch/installation/apache2/bin/apachectl -k stop

Restart the Apache

/scratch/installation/apache2/bin/apachectl -k restart

~~~~~END OF STARTING APACHE SERVER~~~~~

PHP Setup:

  1. cd /scratch/installation/
  2. wget https://www.php.net/distributions/php-8.0.7.tar.gz
  3. tar -xzvf php-8.0.7.tar.gz
  4. cd /scratch/installation/php-8.0.7
  5. yum install sqlite-devel
  6. yum install oniguruma-devel
  7. export ORACLE_HOME=/scratch/orcleapp/opt/oracle_db/product/19c_client {path the Oracle client}
  8. ./configure --prefix=/scratch/installation/php --with-oci8=/scratch/orcleapp/opt/oracle_db/product/19c_client --with-apxs2=/scratch/installation/apache2/bin/apxs --with-config-file-path=/scratch/installation/apache2/conf --enable-sigchild --with-curl --with-ldap --with-gd --enable-ftp --enable-sysvsem --enable-sysvshm --enable-bcmath --enable-calendar --enable-wddx --with-openssl --with-gettext --enable-sockets --enable-mbstring --enable-soap --enable-pcntl --with-mysqli=mysqlnd --with-iconv --with-pdo-mysql=mysqlnd --enable-fileinfo --enable-phar --enable-intl --with-pdo-oci
  9. make
  10. make install
  11. libtool --finish /scratch/installation/php-8.0.7/libs
  12. Add the below line in bash profile
  13. vi ~/.bash_profile
  14. Add below line before “export PATH”
  15. PATH=$PATH:/scratch/installation/php/bin
  16. Add below line after “export PATH”
  17. export ORACLE_HOME=/scratch/orcleapp/opt/oracle_db/product/19c_client
  18. Save the file
  19. source ~/.bash_profile
  20. cd /scratch/installation/php-8.0.7
  21. cp php.ini-development /scratch/installation/apache2/conf/php.ini
  22. Add the below code in apache configuration files
  23. vi /scratch/installation/apache2/conf/httpd.conf

    #
    # This next section will call PHP for .php, .phtml, and .phps files

    #

    AddType application/x-httpd-php .php

    AddType application/x-httpd-php .phtml

    AddType application/x-httpd-php-source .phps

    #

    # This is the directory containing php.ini

    #

    PHPIniDir "/scratch/installation/apache2/conf"

  24. Save the file using ESC, :wq and Enter keys
  25. Disable Directory listing
  26. Open the httpd.conf file and modify the line
  27. vi /scratch/installation/apache2/conf/httpd.conf

From

Options Indexes FollowSymLinks

To

Options FollowSymLinks

~~~~~END~~~~~

Restart the Apache

/scratch/installation/apache2/bin/apachectl -k restart

Testing

  • Create a test script file: vi /scratch/installation/apache2/htdocs/phpinfo.php

add the below content

<?php

phpinfo();

?>

  • Save and close the file when you are finished.
  • Test by opening the url in browser

http://<domain>/phpinfo.php