pavement

Apache, Installing with PHP

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
(Final Notes)
m (Reverted edits by 173.165.130.129 (talk) to last revision by DavidYoung)
 
(10 intermediate revisions by 5 users not shown)
Line 6: Line 6:
  
 
==Installing from packages==
 
==Installing from packages==
Packages are fast and easy, but do not allow you a great deal of customization.
+
Packages are fast and easy, but do not allow you a great deal of customization.  Also, it is very easy to wind up with inconsistencies between the system that a precompiled binary expects and the actual condition of your system: for example, a minor difference in the version of a particular dependency library installed may break a package, where the same difference would be handled in stride if you were compiling from source.
  
First, update your ports tree and either install the packages as root, if you're in a hurry:
+
If you're in a hurry and have a clean system though, packages are by far the fastest way to go.  First, update your ports tree and then install the packages as root:
 
  # pkg_add -r apache13
 
  # pkg_add -r apache13
 
  # pkg_add -r php4
 
  # pkg_add -r php4
==Installing from ports==
+
 
Installing from ports will allow you to customize the build and will install from source; assuming that you've [[cvsup]]'ed recently, you'll also be using the most current version of the software. This is the recommended way to install software for most FreeBSD servers. It will also register the install with the ports db and will allow you to remove the software (via make deinstall) or upgrade (see [[portupgrade]]).
+
==Installing from source via ports==
 +
Installing from ports will allow you to customize the build and will install from source; assuming that you've [[Ports Tree, Updating|updated your ports tree]] recently, you'll also be using the most current version of the software. This is the recommended way to install software for most FreeBSD servers. It will also register the install with the ports db and will allow you to remove the software (via make deinstall) or upgrade (see [[portupgrade]]).
  
 
  # cd /usr/ports/www/apache13 && make install clean
 
  # cd /usr/ports/www/apache13 && make install clean
Line 26: Line 27:
 
  cd /root/installs/
 
  cd /root/installs/
  
Next, we best go get the sources:
+
Next, go get the sources:
  
 
(As of writing this guide, the current versions are: Apache/1.3.34 and PHP/4.4.2. You might have to amend the following arguments inorder to download the current version or to find a server nearer to you.)
 
(As of writing this guide, the current versions are: Apache/1.3.34 and PHP/4.4.2. You might have to amend the following arguments inorder to download the current version or to find a server nearer to you.)
Line 33: Line 34:
 
  fetch <nowiki>http://uk.php.net/get/php-4.4.2.tar.gz/from/uk.php.net/mirror</nowiki>
 
  fetch <nowiki>http://uk.php.net/get/php-4.4.2.tar.gz/from/uk.php.net/mirror</nowiki>
  
''Compiling and Installing Apache''
 
 
Uncompress and untar the file and [[cd]] into the directory:
 
Uncompress and untar the file and [[cd]] into the directory:
 
  tar zxvf apache_1.3.34.tar.gz
 
  tar zxvf apache_1.3.34.tar.gz
Line 43: Line 43:
 
  make install
 
  make install
  
''Compiling and Installing PHP''
+
Next, do the same for PHP. Uncompress and untar the file and [[cd]] into the directory:
Uncompress and untar the file and [[cd]] into the directory:
+
 
  tar zxvf php-4.4.2.tar.gz
 
  tar zxvf php-4.4.2.tar.gz
 
  cd php-4.4.2/
 
  cd php-4.4.2/
Line 123: Line 122:
 
[[Category:FreeBSD for Servers]]
 
[[Category:FreeBSD for Servers]]
 
[[Category:Ports and Packages]]
 
[[Category:Ports and Packages]]
 +
 +
== Change Your Life Through the Art of Self Mastery ==
 +
 +
There is only one corner of the universe you can be certain of improving, and thats your own SELF. ~ Aldous HuxleyI will share with you today some of the things I shared recently with an audience of close to 100 people, a topic that is very dear to my heart the Art of SELF Mastery, what really means to be true to your SELF, and the inner peace, harmony, love and the inner power that comes from being your true SELF.
 +
 +
[[http://goodvillenews.com/Change-Your-Life-Through-the-Art-of-Self-Mastery-tEkVh3.html Change Your Life Through the Art of Self Mastery]]
 +
 +
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
 +
 +
== The Story of Change ==
 +
 +
"Ive come to see that we have two parts to ourselves; its almost like two muscles -- a consumer muscle and a citizen muscle. Our consumer muscle, which is fed and exercised constantly, has grown strong: So strong that "consumer" has become our primary identity, our reason for being. Were told so often that were a nation of consumers that we dont blink when the media use "consumer" and "person" interchangeably."
 +
 +
[[http://goodvillenews.com/The-Story-of-Change-hgReTV.html The Story of Change]]
 +
 +
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
 +
 +
== The Power of You! Living Life Without Limits ==
 +
 +
To every person there comes in their lifetime that special moment when you are figuratively tapped on the shoulder and offered the chance to do a very special thing, unique to you and your talents. What a tragedy if that moment finds you unprepared or unqualified for work which could have been your finest hour. Winston Churchill
 +
 +
[[http://goodvillenews.com/The-Power-of-You-Living-Life-Without-Limits-TtvgM5.html The Power of You! Living Life Without Limits]]
 +
 +
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
 +
 +
== 10 Tips Designed to Keep You on Your Toes ==
 +
 +
Life is best enjoyed when time periods are evenly divided between labor, sleep, and recreationall people should spend one-third of their time in recreation which is rebuilding, voluntary activity, never idleness. ~ Brigham Young
 +
 +
[[http://goodvillenews.com/10-Tips-Designed-to-Keep-You-on-Your-Toes-tWWIOy.html 10 Tips Designed to Keep You on Your Toes]]
 +
 +
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
 +
 +
== Rats Walking Again After Spinal Cord Injury ==
 +
 +
Scientists in Switzerland have restored full movement to rats paralyzed by spinal cord injuries in a study that spurs hope that the techniques may hold promise for someday treating people with similar injuries.
 +
 +
[[http://goodvillenews.com/Rats-Walking-Again-After-Spinal-Cord-Injury-nBLFSB.html Rats Walking Again After Spinal Cord Injury]]
 +
 +
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]

Latest revision as of 16:27, 25 August 2012

Apachefeather.jpg Php.jpg

Contents

[edit] Getting Started

I have decided to use Apache/1.x with PHP/4.x. I belive this is the better combination, as time tells, they are the most popular and better stability. Anyhow, this is my opinion, so this guide will use those two versions. There are a variety of ways to install, with distinct advantages and disadvantages:

[edit] Installing from packages

Packages are fast and easy, but do not allow you a great deal of customization. Also, it is very easy to wind up with inconsistencies between the system that a precompiled binary expects and the actual condition of your system: for example, a minor difference in the version of a particular dependency library installed may break a package, where the same difference would be handled in stride if you were compiling from source.

If you're in a hurry and have a clean system though, packages are by far the fastest way to go. First, update your ports tree and then install the packages as root:

# pkg_add -r apache13
# pkg_add -r php4

[edit] Installing from source via ports

Installing from ports will allow you to customize the build and will install from source; assuming that you've updated your ports tree recently, you'll also be using the most current version of the software. This is the recommended way to install software for most FreeBSD servers. It will also register the install with the ports db and will allow you to remove the software (via make deinstall) or upgrade (see portupgrade).

# cd /usr/ports/www/apache13 && make install clean
# cd /usr/ports/lang/php4 && make install clean

In either case, they'll be installed in /usr/local by default.

[edit] Installing from source without ports

Alternately, you can install from source without using ports, although this is not the suggested way to do it -- your install won't be registered in the ports pkg database and uninstalling or upgrading will be made somewhat more difficult.

First, create and cd into a good location for sources, ie: /root/installs/

mkdir /root/installs/
cd /root/installs/

Next, go get the sources:

(As of writing this guide, the current versions are: Apache/1.3.34 and PHP/4.4.2. You might have to amend the following arguments inorder to download the current version or to find a server nearer to you.)

fetch http://www.mirror.ac.uk/mirror/ftp.apache.org/httpd/apache_1.3.34.tar.gz
fetch http://uk.php.net/get/php-4.4.2.tar.gz/from/uk.php.net/mirror

Uncompress and untar the file and cd into the directory:

tar zxvf apache_1.3.34.tar.gz
cd apache_1.3.34/

Configure the install:

./configure --prefix=/usr/local/apache --enable-module=so

and make it:

make
make install

Next, do the same for PHP. Uncompress and untar the file and cd into the directory:

tar zxvf php-4.4.2.tar.gz
cd php-4.4.2/

Configure the install:

./configure --with-apxs=/usr/local/apache/bin/apxs

and make it:

make
make install

[edit] Setting up php.ini

cp php.ini-dist /usr/local/lib/php.ini

Note:

You may wish to edit the above file to set PHP options. If you'd rather use php.ini-recommended, make sure to read the list of changes, and how they affect the behaviour of PHP.

[edit] httpd.conf

Now, you will have to edit the httpd.conf file to load the PHP module:

pico /usr/local/apache/conf/httpd.conf

1) Add the following line to the above file:

LoadModule php4_module libexec/libphp4.so

- Or if you are lazy and can't be bothered to check httpd.conf:

echo "LoadModule php4_module libexec/libphp4.so" >> /usr/local/apache/conf/httpd.conf

Note:

Running "make install" might have added the line for you, best be on the safe side and check!


2) In the AddModule section of httpd.conf, add the following line to the bottom of the section:

AddModule mod_php4.c


3) Apache will need to be told on what to class as a PHP document. Add this line to the httpd.conf file in the AddType section:

AddType application/x-httpd-php .php

...You might consider using the following line to show highlighted PHP source, it can be achieved by adding the line also to the AddModule section under the line you have just added:

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

[edit] Starting Apache

Use the following command to start Apache:

/usr/local/apache/bin/apachectl start

[edit] All works?

To test everything went according to plan, we will now make a PHP file:

echo "<? phpinfo(); ?>" >> /usr/local/apache/htdocs/php-test.php

Run your favourite browser, such as Firefox and point it to http://localhost/php-test.php. You will now see lots of compilation and configuration options for PHP.


You're Done!

[edit] Final Notes

You should now have a working version of Apache with PHP. The next and only thing I will suggest is to auto-start apache via an rc.d script (installing from ports will suggest how to do this) or via a crontab to start Apache at boot:

crontab -e

and add to the bottom:

@reboot /usr/local/apache/bin/apachectl start

[edit] Change Your Life Through the Art of Self Mastery

There is only one corner of the universe you can be certain of improving, and thats your own SELF. ~ Aldous HuxleyI will share with you today some of the things I shared recently with an audience of close to 100 people, a topic that is very dear to my heart the Art of SELF Mastery, what really means to be true to your SELF, and the inner peace, harmony, love and the inner power that comes from being your true SELF.

[Change Your Life Through the Art of Self Mastery]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]

[edit] The Story of Change

"Ive come to see that we have two parts to ourselves; its almost like two muscles -- a consumer muscle and a citizen muscle. Our consumer muscle, which is fed and exercised constantly, has grown strong: So strong that "consumer" has become our primary identity, our reason for being. Were told so often that were a nation of consumers that we dont blink when the media use "consumer" and "person" interchangeably."

[The Story of Change]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]

[edit] The Power of You! Living Life Without Limits

To every person there comes in their lifetime that special moment when you are figuratively tapped on the shoulder and offered the chance to do a very special thing, unique to you and your talents. What a tragedy if that moment finds you unprepared or unqualified for work which could have been your finest hour. Winston Churchill

[The Power of You! Living Life Without Limits]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]

[edit] 10 Tips Designed to Keep You on Your Toes

Life is best enjoyed when time periods are evenly divided between labor, sleep, and recreationall people should spend one-third of their time in recreation which is rebuilding, voluntary activity, never idleness. ~ Brigham Young

[10 Tips Designed to Keep You on Your Toes]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]

[edit] Rats Walking Again After Spinal Cord Injury

Scientists in Switzerland have restored full movement to rats paralyzed by spinal cord injuries in a study that spurs hope that the techniques may hold promise for someday treating people with similar injuries.

[Rats Walking Again After Spinal Cord Injury]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]

Personal tools