Installation Of Apache For PHP


In this article, you will learn about the installation of Apache for PHP. 
It is used to maintain an open-source HTTP server for Unix and Windows. In Unix, it is easy to find the RPM for Apache and PHP, but this installation may not include every PHP feature. PHP compiles on most versions of UNIX-like operating systems, including Solaris and Linux. It will need root privileges to completely install PHP.
The first step is to download the required files and unpack them. 
Download the newest version from the PHP site <> and the Apache site <>. After unpacking the tar tile, the first step is to configure Apache. This is done by running the configure script inside the directory.
Configure Apache
./configure \
--server-uid = nobody \
--enable-module = so
This script will examine the system and prepare a make file for Apache. This builds Apache for using shared libraries, one of which will be PHP. To test Apache by starting it with the /usr/local/apache/bin/apachectl script.The information is received by running ./configure --help. Running make will create the PHP library and make install places the PHP module in the Apache directory of modules.
Configuring PHP
./configure \ 
--with-apxs = /usr/local/apache/bin/apxs \ 
--with-zlib \
--with-bz2 \
--with-openssl \ 
--with-gd \
--enable-exif \
--with-jpeg-dir = /usr \
--with-freetype-dir \ 
--with-tllib \
--enable-gd-native-ttf \
--with-mysql = \usr
To supply additional configuration options, PHP uses a file called php.ini. This file should reside in /usr/local/lib, so copy it from the PHP source directory. 
Copying php.ini
cp php.ini-dist /usr/local/lib/php.ini
It controls the aspects of PHP. The last step is to make sure Apache recognizes PHP scripts. 

Activating PHP for Apache

LoadModule php5_module libexec/
AddType application/x-httpd-php .php 
AddModule mod_php5.c
This script will cause all files with the extension .php to executed as PHP scripts. It is able to insert index.php as a default document. When the Apache server is started, it will process the PHP scripts. The documentation of Apache has hints for starting the Apache automatically.

Installation of Apache for Windows

Compiling PHP for windows is not an ordinary process. Windows users typically use binaries available on the PHP web site. Both packages include automated installers, which makes installation easy. It allows for better flexibility by installing the PHP manually using the archive.
Unzip the PHP archive into a directory. Copy the file php.ini-dist into your system root directory. Rename it php.ini.
When PHP is invoked, it looks first for php.ini in this directory. It is able to edit to change configuration parameters, including automatically loading extensions. Make sure the required Dll files are in your path. One way is to copy the required files to your system directory. The webserver must be able to find the php4ts.dll, which is in the root of the PHP installation directory.
The next step is to configure Apache to load the PHP module. 
Activating PHP for Apache on windows
LoadModule php5_module c:/php/sapi/php5apache.dll
AddType application/x-httpd-php .php
AddModule mod_php5. c 
These lines load the module and associate the .php extension with the PHP script. Then after completing all the processes, the final step is to restart the Apache.

Editing scripts

PHP scripts are just text files, and can be edit and created just like HTML files. Telnet into your web server and start creating files with vi, or create files with notepad and use FTP to upload them one by one.

PHP script

PHP exists as a tag inside as an HTML file. To accommodate XML and some picky editors such as Microsoft front page, PHP offers three other ways to mark code. Putting PHP after the opening question mark makes PHP code to XML parsers. The below code displays the date in the console. 
Printing date
  1. <html>  
  2.     <head>  
  3.         <title>Listing 1-6</title>  
  4.     </head>  
  5.     <body>  
  6.                        Date:  
  7.         <?php print(Date("l F d, Y")):?>  
  8.     </body>  
  9. </htlm>  
Date: Monday, May 1, 2020