APACHE

 

INSTALLATION OF APACHE WITH PHP SERVER.

Do not take this intallation documentation as a literal bible of how to install Apache with php. Systems will vary and needs will vary and I can almost guarantee that you will have to make some tweaks, changes and adjustments relative to your system and your particular needs in order to get a working Apache installation that makes you happy. I cannot guarantee that you will not completely crash your system while trying to install Apache (though you’d have to try pretty darn hard). I have said it on other parts of this site and I will say it now: USE A TESTING SERVER THE FIRST TIME YOU INSTALL APACHE!! ALWAYS DO A TEST INSTALL FIRST! You should never install Apache, or any other program for that matter, on a live production server until you have tested it thoroughly and you are confident in your ability to handle the install and any problems that may arise as a result of the install.

Before You Start! – When installing apache, I would STRONGLY reccomend that you first conduct a test installation on a test server if you have one available. I would recommend you to install Ubuntu 12.04 full installation for installation of a Apache server so that all the packages needed will be installed. If you’re new to Apache, chances are you will probably screw the install up the first time through. Do a favor to first install on a test server that has no importance to you, so that in case you come across any issues it can be resolved.

Understanding what you are about to do

Though I really hope you know this by now, you are about to install a complete Apache server solution on whatever server you have chosen. You will be replacing whatever apache server software is currently on your server with php and a lot of extra software to enhance apache functionality.

What you need to know before beginning the installation

The installation and setup of a php based apache server, whether through this site or any other site, is not easy. I would not recommend this installation to anyone who is a newcomer to the Linux/Unix world. If you are such a person, I would STRONLY recommend that you take step back and familiarize yourself with general Linux/UInix knowledge before diving into this installation. In other words, if you are a newbie you WILL have a hard time with this installation. That’s a fact.

What to expect from this installation guide

First and foremost, know this: The Source installation of Apache DOES WORK. It’s been tested time and time again. But don’t get me wrong, the guide is not a work of perfection. I’m sure there are a few minor mistakes or typos here and there, but the install does work as a whole and any MAJOR problems you encounter are typically going to be due to something you’ve done wrong or something you’re system isn’t doing right. It is completely normal for most everyone to experience some problems during the install. That’s life. Get used to it. While I make all efforts to make this guide easy and error free, the ease of the installation process really depends on the skill of the individual person attempting the install. As I said, most everyone experiences a problem or 2 along the way. If you are a newbie, these problems can be very difficult to overcome without help. If you are a seasoned sysadmin, you should be able to use common sense to fix most problems as they come up. It is for this reason that experienced Linux/Unix people find this guide to be excellent while newbies have a more hit or miss experience. Some love it, some get frustrated. So goes the life of the newbie. But the frustration that newbies feel at time arises out of that person’s own inabilities and NOT out of some huge flaw in the guide. I’ve used this installtion guide myself countless times verbatim, and it DOES work. To ensure a positive experience, make sure your system is properly prepared and make sure you have the appropriate skill set.

What NOT to expect from this installation guide

While the Apache guide does work, you SHOULD NOT expect it to be a seamless and flawless experience. System environments and server setups vary, so portions of the installation guide may be more difficult for some users.

This guide is also NOT absolutely perfect. As I said, it DOES work for most people, but I am always finding areas for improvement, clarification and correction. If you ever find an area of the install process that you feel needs improvement, clarification or correction, by all means let me know.

And now, the most important piece of advice before you begin the installation:

READ EVERY WORD ON EVERY STEP OF THE INSTALL! READ, READ, READ, READ!

httpd.apache.org Pre-Installation Checklist

A successful Apache installation requires certain packages be installed and certain configurations be present on your server. I’ve put together this page to provide a general checklist for visitors to use before they begin the installation. Keep in mind that, since setups will vary from server to server, you may find some requirements that are not listed here.

How much disk space should I have available on my server?

The following is the partition schema maintained by us for the server.

/ partition: about 20GB.

/home partition: About 150GB

Download the Software

The first thing you’ll need to do to get started with installation of dependencies needed by the apache.

So let’s start the installation by getting the needed software. You will notice that below I create a new directory called /download and I place the all tarball in that directory before unpacking it. I would strongly recommend you do this as the rest of the instructions on this site are geared toward this source directory structure. Anyway, lets get down to business.

An introduction to the Apache /Apache installation / Setting your expectations

Often referred to as simply Apache, a public-domain open sourceWeb server developed by a loosely-knit group of programmers. The first version of Apache, based on the NCSA httpd Web server, was developed in 1995.
Core development of the Apache Web server is performed by a group of about 20 volunteer programmers, called the Apache Group.However, because the source code is freely available, anyone can adapt the server for specific needs, and there is a large public libraryof Apache add-ons. In many respects, development of Apache is similar to development of the Linuxoperating system.
The original version of Apache was written for UNIX, but there are now versions that run under OS/2, Windows and other platforms.

Installation steps

Installation of Apache2 from source on ubuntu with php.
Install all dependencies needed by the apache

web01@hari:~$ sudo apt-get install build-essential
web01@hari:~$ sudo apt-get build-dep apache2
web01@hari:~$ apt-get install openssl libssl-dev

Download the latest Apache
We can download the latest apache form the link http://httpd.apache.org/ . Lets download
the apache source file and install.

 web01@hari:~$ wget http://www.apache.org/dist/httpd/httpd-2.2.27.tar.bz2
web01@hari:~/download$ tar -jxvf httpd-2.2.27.tar.bz2
web01@hari:~/download$ cd httpd-2.2.27
web01@hari:~/download/httpd-2.2.27$ vi ins
"./configure" \
"--prefix=/home/web01/apache" \
"--enable-so" \
"--enable-cgi" \
"--enable-info" \
"--enable-rewrite" \
"--enable-speling" \
"--enable-usertrack" \
"--enable-deflate" \
"--enable-ssl" \
"--enable-mime-magic" \
"$@"
web01@hari:~/download/httpd-2.2.27$ chmod +x ins
web01@hari:~/download/httpd-2.2.27$ sh ins
web01@hari:~/download/httpd-2.2.27$ make
web01@hari:~/download/httpd-2.2.27$ make install  

You only need the enable-so line above. For information on other options, type ./configure –help and see “Compiling and Installing” in the Apache 2 Documentation, http://httpd.apache.org/

PHP INSTALLATION

Download/unpack PHP source from the PHP website, http://www.php.net/ pick the latest from the 4.x series or 5.x series.

web01@hari:~/download$wget http://in1.php.net/get/php-5.6.0.tar.bz2/from/this/mirror
web01@hari:~/download$ tar -jxvf php-5.6.0.tar.bz2
web01@hari:~/download$ cd php-5.6.0
web01@hari:~/download/php-5.6.0$ ./configure --with-apxs2=/home/web01/apache/bin/apxs --prefix=/home/web01/apache/php --with-config-file-path=/home/web01/apache/php --enable-force-cgi-redirect --disable-cgi --with-zlib --with-gettext --with-gdbm --with-mysqli --with-mysql
web01@hari:~/download/php-5.6.0$ make
web01@hari:~/download/php-5.6.0$ make install
web01@hari:~/download/php-5.6.0$cp -p .libs/libphp5.so /home/web01/apache/modules
web01@hari:~/download/php-5.6.0$cp -p php.ini-production /home/web01/apache/php/php.ini

You only need the –with-apxs2, and prefix lines. –with-mysql adds MySql (you need to specify the directory if it’s in a unusual location (e.g., –with-mysql=/usr/local ), –with-config-file moves the php.ini file location, disable-cgi disables the CGI version, which is not needed if you use Apache modules. It also enables and installs the command line interface (CLI) version. –with-zlib allows use of gzip-type compression, –with-gettext is for internationalization, and –with-gdbm allows access to GDBM databases. For more information, type ./configure –help and see the “Installation” chapter in the PHP Manual, http://ww.php.net/docs.php

For any php related error please check the below link.

http://www.robo47.net/text/6-PHP-Configure-und-Compile-Fehler

Check the below directives are in httpd.conf

# Make sure there’s only **1** line for each of these 2 directives:
# Use for PHP 4.x:
#LoadModule php4_module modules/libphp4.so
#AddHandler php-script .php
# Use for PHP 5.x:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script .php
# Add index.php to your DirectoryIndex line:
DirectoryIndex index.html index.php
AddType text/html .php
# PHP Syntax Coloring
# (optional but useful for reading PHP source for debugging):
AddType application/x-httpd-php-source phps

Lets start now apache

web01@hari:~$ cd apache
web01@hari:~/apache$/home/web01/apache/bin/apachectl start
web01@hari:~/apache/bin$ ./httpd -t
Syntax OK

Access your webserver with your favorite browser. The following is a good test page to use for PHP. You only need the one line in bold is needed to display PHP configuration information. Name the file anything you want, but it must end with .php, such as phpinfo.php, and move the file to your web server content directory (for me /home/web01/apache/htdocs), with read permission set: ex-

#vi /home/web01/apache/htdocs/phpinfo.php
<html>
<head>
	<title>PHP Test</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<h1>PHP Test</h1>
<b>An Example of PHP in Action</b>

		<?php echo "The Current Date and Time is: 
";
			echo date("g:i A l, F j Y.");?>
<h2>PHP Information</h2>
<?php phpinfo(); ?>

</body>
</html> 



Now access php page by http://yourmachineip:port/phpinfo.php

APR LINK FOR APACHE

Below is the apr sources files link with installation which is needed before compilation

wget http://apache.mesi.com.ar/apr/apr-1.4.6.tar.gz
wget http://apache.mesi.com.ar/apr/apr-util-1.4.1.tar.gz
wget http://mirrors.linsrv.net/apache//httpd/httpd-2.4.3.tar.gz
gzip -d apr-1.4.6.tar.gz; tar xvf apr-1.4.6.tar
gzip -d apr-util-1.4.1.tar.gz; tar xvf apr-util-1.4.1.tar
gzip -d httpd-2.4.3.tar.gz; tar xvf httpd-2.4.3.tar
mv apr-1.4.6 httpd-2.4.3/srclib/apr
mv apr-util-1.4.1 httpd-2.4.3/srclib/apr-util cd httpd-2.4.3
./configure --with-included-apr --with-pcre
make; make install

References.

http://php.net/manual/en/install.unix.apache2.php
http://dan.drydog.com/apache2php.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s