您的位置:首页 > 运维架构 > Apache

Install Apache and PHP

2008-11-11 21:00 302 查看
Setup the Apache and Php environment again:
1.Install the Apache webserver.
2. Get the current version of PHP 5 from http://www.php.net/downloads.php#v5. (It’s 5.2.3 at this time). Get both the zip file and the PECL zip file (which includes extensions).
3. Uninstall any previous installations of PHP 5 (Start > Control Panel > Programs and Features). You may have to reboot your machine.
4. Disconnect from the Internet. Turn off your firewall. Turn off your virus checker.
5. Turn off User Account Control (UAC).
6. Get an administrator prompt by going to All Programs > Accessories. Right-Click “Command Prompt” and choose “Run as Administrator”
7. Use the command prompt to manually remove directories containing previous PHP installations (like C:/Program Files/PHP…)
8. Go to the directory where you’ve downloaded the PHP5 and PECL zipfiles. Extract the PHP zipfile. Rename the extracted php directory (which has a name something like php-5.2.3-Win32) to c:/php. Extract the PECL zipfile into c:/php/ext.
9. In the command prompt, type:
cd c:/php
mkdir upload
mkdir session
copy php.ini-recommended php.ini


10. Open php.ini in Notepad:

There are many variables… the following are important. Notice that starting a line with a semicolon in the ini file comments it out.

upload_tmp_dir="C:/php/upload"
session.save_path="C:/php/session"
cgi.force_redirect=0
extension_dir ="C:/php/ext"
display_errors = Off
log_errors = On
error_log = "C:/php/error_log"


11. You might want to look at upload_max_filesize. I’ve set mine to 16M. I also set post_max_size = 16M.

12. Enable the extensions you need by deleting the semicolon at the beginning of the line. These will depend on your application… I’m going to be using MySQL (which I’ve already installed) and Moodle (which I’ll install later). My list looks like the following:

extension=php_bz2.dll
extension=php_curl.dll
extension=php_dba.dll
extension=php_dbase.dll
;extension=php_exif.dll
extension=php_fdf.dll
extension=php_gd2.dll
extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_ifx.dll
;extension=php_imap.dll
;extension=php_interbase.dll
extension=php_ldap.dll
extension=php_mbstring.dll
extension=php_mcrypt.dll
extension=php_mhash.dll
extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_msql.dll
;extension=php_mssql.dll
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8.dll
extension=php_openssl.dll
;extension=php_pdo.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mssql.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_oci8.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_pspell.dll
extension=php_shmop.dll
;extension=php_snmp.dll
extension=php_soap.dll
extension=php_sockets.dll
;extension=php_sqlite.dll
;extension=php_sybase_ct.dll
extension=php_tidy.dll
extension=php_xmlrpc.dll
extension=php_xsl.dll
extension=php_zip.dll


13. Right-Click on Start > Computer. Choose “Properties”, then “Advanced”. Click on “Environment Variables”. Click on PATH, then Edit… and add “;C:/php;c:/php/ext” (without quotes) to the end of the variable.

14. Open your Apache configuration file (All Programs > Apache HTTP Server 2.2.x > Configure Apache Server > Edit the Apache httpd.conf Configuration File). Add the following lines:

LoadModule php5_module "C:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
AcceptPathInfo on
PHPIniDir "C:/php"


15. Look for the DirectoryIndex line. Add ” index.php” (no quotes) to the end of that line.

16. Save the file.

17. Create a file named test.php in your Apache htdocs directory, containing this text:

18. Reboot your machine.

19. Browse to http://localhost/test.php. You should see tabulated information about your working PHP installation.

Cite from: http://senese.wordpress.com/2007/06/06/install-php-5-under-apache-22-and-windows-vista/

 

Problems:

After I installed the apache server, it showed that there is no services! Add when I type in http://localhost:8080/ nothing except blank page showed. Why? I remembered last time, I also encountered this kind of problem. However, I forgot how I tackled it! Ash!

Search on line, and I found the real answer:

Apache can be run as a service on Windows NT. There is some highly experimental support for similar behavior on Windows 9x.

You can install Apache as a service automatically during the installation. If you chose to install for all users, the installation will create an Apache service for you. If you specify to install for yourself only, you can manually register Apache as a service after the installation. You have to be a member of the Administrators group for the service installation to succeed.

Apache comes with a utility called the Apache Service Monitor. With it you can see and manage the state of all installed Apache services on any machine on your network. To be able to manage an Apache service with the monitor, you have to first install the service (either automatically via the installation or manually).

You can install Apache as a Windows NT service as follows from the command prompt at the Apache
bin
subdirectory:

httpd -k install


If you need to specify the name of the service you want to install, use the following command. You have to do this if you have several different service installations of Apache on your computer.

httpd -k install-n "MyServiceName" 


If you need to have specifically named configuration files for different services, you must use this:

httpd -k install-n "MyServiceName" -f "c:/files/my.conf"


http://httpd.apache.org/docs/2.0/platform/windows.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: