|
|
|
|
|
|
| |
Well, PHP 4.0.0 is available, so it's time to run through the amazingly simple method of installing Apache and PHP4 on your Windows machine. Let me just answer the inevitable question now, and get it out of the way: you say "Where are your instructions on PHP4 + IIS?" and I say "The installation instructions for PHP4 as an ISAPI filter for IIS are in the README.txt file, in the PHP 4.0.0 distribution." I can't write a tutorial about it, because IIS will never touch any of my machines. Sorry. There's a mailing list for PHP + Windows users, so if the installation instructions in the README.txt have you befuddled, send a message to: php-windows@lists.php.net. |
|
Ok, so that's out of the way.... |
|
If you have a working version of Apache on your Windows machine, you can skip this section. Otherwise, time to get yourself a Web server: |
|
- Go to http://www.apache.org/dist/binaries/win32/ and
download the latest version of the Windows binary file (with the *.exe extension). Currently, it's version 1.3.12. This file is pre-compiled and ready to install.
- Once you have the file on your hard drive, run the executable file by double-clicking it or typing its location in the Run dialog box under the Start menu.
- The installation wizard will start. Read and accept all the licencing stuff.
- The installation wizard will ask for:
- The Apache installation directory. Default is "C:\Program Files\Apache Group\Apache" but you can change this to "C:\Apache\" or anything else you wish.
- The name that will appear in the Start menu; default is "Apache Web Server".
- The installation type: typical, minimum or custom. I usually pick "typical".
- Sit back and watch the pretty colors as the installation sequence runs through its paces. The wizard will tell you when it's finished, and ask if you want to read the README. If you want to, do so. If not, just Finish the install.
|
|
During the installation process, a default set of configuration files will be placed in the "conf" directory, under the installation directory (i.e. "C:\Program Files\Apache Group\Apache\conf\"). You'll be making some modifications here in a little but, but now take a moment to try to run Apache. |
|
If you're on Windows NT and you want to run Apache as a service: |
|
- Select "Install Apache as Service (NT only)" from your Start menu.
- Start the service named "Apache" by opening the Services window in the Control Panel, selecting "Apache" and clicking the "Start" button.
- Apache will now continue to run in the background, and will automatically start whenever your machine starts.
|
If you're not on NT and need to start Apache on your own: |
|
- Select "Start Apache" or "Start Apache as a Console App" from the Apache folder in the Start menu. A console window will open and Apache will run. Keep this window open!
- Yes, that's really it.
|
Now let's get PHP4 hooked in there... |
|
- Go to http://www.php.net/, go to the "Downloads" area, and select the link for the Windows binaries. This is a zip file, containing pre-compiled binaries, ready to install. If you want to build from source, then you don't need me or this tutorial to tell you what to do.
- Once you have the file on your hard drive, use your favorite un-zipping tool to extract the contents to say, C:\php4\ (If you put the files in some other directory, substitute that directory where appropriate, later in this process.).
- Take the file called "php.ini-dist", rename it to "php.ini" and move it to C:\WINDOWS\ or wherever you usually put your *.ini files.
- Forget about that file for a moment.
- Take the two files "Msvcrt.dll" and "php4ts.dll", and put them in C:\WINDOWS\SYSTEM\ or wherever you usually put your *.dll files. If your system tells you that you already have "Msvcrt.dll" or it's currently in use, that's fine. As long as you have it.
- Forget about the other *.dll files for now.
|
Let's go make a few modifications to the Apache configuration files, and run a vanilla version of Apache + PHP4. Then we'll go back and tweak on PHP a little bit. |
|
Using a text editor, open the httpd.conf file, located in your Apache configuration (conf) directory. The goal of the configuration is to tell Apache what to do with files ending with .phtml, .php or anything else you use to indicate a PHP file. Basically, you'll be telling Apache to execute an application in order to do something with those files; in this case, run the php.exe program to parse the PHP code. |
|
In httpd.conf, find this line:
ServerAdmin you@your.address
Change it to real values, such as:
ServerAdmin joe@schmo.com
Find this line:
#ServerName new.host.name
Change it to something like:
ServerName localhost
For now, at least. If you have a real machine name, like gambit.yourdomain.com, go ahead and use it.
Confession time; those two changes have nothing to do with PHP, but it's good housekeeping.
Now find a section that looks like this: |
|
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "C:/Apache/cgi-bin/"
|
|
|
You need to add another ScriptAlias line:
ScriptAlias /php4/ "C:/php4/"
Now find a section that looks like this: |
|
#
# AddType allows you to tweak mime.types without actually editing it, or to
# make certain files to be certain types.
#
# For example, the PHP3 module (not part of the Apache distribution)
# will typically use:
#
#AddType application/x-httpd-php3 .phtml
#AddType application/x-httpd-php3-source .phps
|
|
|
Although the example is now out-of-date, since you'll be using PHP4, you get the idea. This is the area where you say "for all files ending with [whatever], consider them to be of [whatever] type." Add these lines: |
|
AddType application/x-httpd-php .phtml .php
AddType application/x-httpd-php-source .phps
|
|
|
|
If you want to create your own file extension for PHP files, like .joe (really, you can...), add .joe after the .phtml and .php in the first AddType line. |
|
One more modification...find a section like this: |
|
#
# Action lets you define media types that will execute a script whenever
# a matching file is called. This eliminates the need for repeated URL
# pathnames for oft-used CGI file processors.
# Format: Action media/type /cgi-script/location
# Format: Action handler-name /cgi-script/location
#
|
|
|
You need to add an Action line for your new file types, so that they get sent through the PHP parser. Add this: |
|
Action application/x-httpd-php /php4/php.exe
|
|
|
I know it looks weird, without the drive letter, the slashes are backwards, there aren't any quotation marks, but this is how you do it. That /php4/ comes from the ScriptAlias line at the beginning of the file, so Apache knows that /php4/ really equals C:\php4\ ("C:/php4/" == "C:\php4\" in Apache world). |
|
Alrighty then, let's try to start Apache again (shut down and restart Apache if it's still running). Provided there are no issues on startup, open a text editor and type this: |
| |
|
Save this file as phpinfo.php, and put it in the document root of Apache (in the htdocs directory within your installation directory.). |
|
Fire up your Web browser and go to http://localhost/phpinfo.php -- you should see a page that starts out like this: |
|
 |
If you don't, then something has gone awry, and let me know. |
|
So what is all this stuff? It's "info"...and a ton of it! The phpinfo() function produces this page that shows you what sorts of things are installed, your environment, your settings, and so on. The following list shows you the basic, compiled-in stuff: |
|
- Regular Expressions
- Dynamic Library Support
- Internal Sendmail Support
- PCRE Support
- ODBC Support
- Session Support
- XML Support
- MySQL Support
- BCMath
- WDDX
|
This means that for the elements in the list above, you do not need to go out and find additional *.dll files. However, if you need Image Creation functions, Crypt functions, other database connectivity support functions, you need to go off and find the *.dlls for those things. A quick search of the mailing list archives should prove useful...what you'll probably find is a link to http://download.swwwing.com/php4/modules/, where a very nice PHP developer has donated his time and energy to maintaining up-to-date compilations of *.dlls for you to use. If you have any problems with the *.dll files you get from that site, remember to take that up with them, not me.... |
|
Alright, time to go back and tweak on the php.ini file. Use a text editor to open the php.ini file in C:\WINDOWS\ or wherever you placed it. The following changes are optional or just FYI. |
|
For sending mail, find these two lines: |
|
SMTP = localhost ;for win32 only
sendmail_from = me@localhost.com ;for win32 only
|
|
|
Change these to something useful, like: |
|
SMTP = mail.yourdomain.com
sendmail_from = you@yourdomain.com
|
|
|
If your outgoing mail server is mail.yourdomain.com and your e-mail address is you@yourdomain.com, that is. |
|
To use additional *.dlls, put them in C:\php4\ and uncomment their entry in this block: |
|
;Windows Extensions
;extension=php_mysql.dll
;extension=php_nsmail.dll
;extension=php_calendar.dll
;extension=php_dbase.dll
;extension=php_filepro.dll
;extension=php_gd.dll
...
|
|
|
"Uncomment" means to take away that ";" at the beginning of the line. Notice that there's a line for the php_mysql.dll file, but remember, that's already compiled in for you. Don't think you need another one, because you don't. |
|
That's really all there is to it; if anything blows up in your face or doesn't match what I've said, just let me know -- this has all worked for me about a zillion times now, but everybody's machine is different. Don't forget about the php-windows mailing list - it's a good place to ask questions. |
|
| |
| Setup and Install Apache with PHP4 as a Dynamic Module (DSO) Categories : PHP, PHP Configuration, Apache | | | Custom Error Messages When Using $PHP_SELF as Form Action Categories : PHP, PHP Configuration | | | Apache, PHP, and PostgreSQL on RedHat Linux Categories : Apache, PHP, Databases, PostgreSQL, Linux | | | Installing Apache Web Server and PHP 4 on Linux Categories : PHP, Web Browsers, Apache, Linux | | | User Authentication With Apache and PHP Categories : PHP, Web Servers, Apache, Authentication | | | How TO Install PHP, Apache and MySQL on Linux or Unix Categories : PHP, MySQL, Apache, Installation, Beginner Guides | | | Generating One-Time URLs with PHP Categories : PHP, URLs | | | Creating Auto-incrementing ID Fields with PHP and Oracle Categories : PHP, PHP options/info, Databases, Oracle | | | Data, its presentation and user interface forms Categories : PHP, XML, User Interface | | | PHP CLI and Cron Categories : PHP, CLI, Cron | | | Honey, I Shrunk My Website Categories : PHP, PHP options/info, Site Planning, Other | | | PHP 101 Part 8 of 15 : Databases and Other Animals Categories : PHP, Beginner Guides, Databases | | | Saving Images in MySQL Categories : MySQL, PHP, Graphics, Databases | | | Introduction to WAP using WML, ASP and PHP Categories : PHP, WAP, WML | | | Web Development With PHP FastTemplate Categories : PHP, Templates, FDF | |
| | | Anonymous wrote : 48 Neat installation manual. Though I just installed
everything the day before I found this `howto`
I am having trouble with adding the php_crypt.dll and
getting it to work. Any help would be usefull.
thanx | | | Glenn Gogs wrote : 125 Good Manual to guide you. I have successfully installed
Apache&Php on my Win98, but only in the older version
(4.0.2). I still have problems using the latest version of
PHP(4.0.3). | | | Anonymous wrote : 163 I have tried all what u said in this very good and simple
manual for PHP4 with Apache on WINDOWS OS. It wont
work. I have placed all the necessary .dlls and followed
the readme.txt carefully. Failed me.
I wonder, what else can I do? | | | Anonymous wrote : 164 Hi,
I finally managed to run PHP4.0.4pl1 service with
APACHE 1.3.17 on Windows 98 after facing problems. By
following the ReadMe, it wont work. By following just
Julie`s guide, it wont work. Finally it worked after I used
both.
Heres what I added to the "httpd.conf" with some guide
from Julie`s tutorial:
.....start...........
AddType application/x-httpd-php4 .phtml .php
AddType application/x-httpd-php .php4 .php
AddType application/x-httpd-php-source .phps
.........And...........
Action application/x-httpd-php4 "/php4/php.exe"
Action application/x-httpd-php "/php4/php.exe"
.........And............
ScriptAlias /php4/ "C:/php/"
..........And.............
LoadModule php4_module c:/php/sapi/php4apache.dll
.......END..............
Thanks for the guide. It has opened up a new world for
me at the age of 40.
My very best wishes.
| | | Anonymous wrote : 177 I get this message when using Include()
>Warning: Failed opening `links.x` for inclusion
(include_path=``) in c:\programmer\apache
group\apache\htdocs\search\search.php on line 13<
I have checked the php.ini at "include_path=``" and tried
using On, Yes, /., \. as well as `path1/path2` (I`m on
Win98). Nothing seems to help ... can anyone? Thanks,
John
| | | Anonymous wrote : 211 Very nice and helpfull information. Problem: Link
does not work:
http://download.swwwing.com/php4/modules/ | | | Anonymous wrote : 221 simple and easy-followed php installation guide!!!
really a good guide for php beginners!!
i am sure u can install php with the aid of this guide,
even u are a novice like me!!!
thx!! | | | Anonymous wrote : 235 Tengo instlado PHP4 en WNT4 con IIS 4 y quiero
conectarme a un MS SQL SERVER 7.0 que esta en otra
maquina bajo WNT4, hago lo que dice la configuracion
pero no logro conectarme con el SQL SERVER el
mssql_conect() no funciona, es me dice que no puede
cargar la extension=php_mssql70.dll el php.ini
Si hay alguien que me puede ayudar? | | | aschenbach fritz wrote : 343 hello,
i am currently running php v4.2.3, mysql v3.23.53, and
apache 1.3.20.
i am having troubules in the php.ini file, its giving me
heartburns, i have this error statement after running
phpinfo() within a php file the error at the bottom Said:
Warning: Failed opening `1` for inclusion
(include_path=`.;c:\php4\pear`) in Unknown on line 0
even if i changed this to include_path
= "C:\my.dir\my.dir.with.two.folders\php.files"
the same errors came up, what is this warning mean?
i am running apache and php like a glove in module state,
its just the config directives in php = include_path which
giving me heartburns.
please write to me.
Sincerely,
Asch | | | jeremy watts wrote : 377 Hello,
I am running Windows XP and have followed the Apache/PHP4
installation procedure to the letter, but get nothing but a 404
error when i point my browser at http://localhost/phpinfo.php
I`m really running out of ideas on how to solve this. I`ve been
trying for 5 days now to get this installed , using all sorts of
tutorials and advice, re-installing apache and php....
someone please save me from clinical insanity...
jeremy | |
|
|
|