19.07.2023

Installing Apache php on windows 7. Installing Apache, PHP, MySQL and phpMyAdmin on Windows XP. Downloading PHP for Windows


Apache for Windows XP

Currently, all current versions of Apache run on Windows 7 SP1, Vista SP2, 8 / 8.1, 10, Server 2008 SP2 / R2 SP1, Server 2012 / R2, Server 2016.

Thus, it is currently not possible to run modern versions of Apache on Windows XP. Also Apache will not work on Windows Server 2003.

On Windows XP, you can only run Apache 2.2. Moreover, your Windows XP system must have Service Pack 3.

Before continuing, I recommend that you upgrade to a newer version of Windows - starting with the seven, you can install any modern version of Apache and PHP. Old versions of Apache and PHP may contain bugs. If you plan to use a local web server to learn web application administration and PHP programming, then Windows XP is not the best platform - here you will be dealing with long outdated software.

If I haven't convinced you, then follow this step-by-step guide to run Apache on Windows XP.

Creating the web server structure

Let's create the directory structure of our server. The main idea is to separate executable files and site files from databases. This is convenient for server maintenance, including backup.

At the root of the disk C:\ create a directory server. In this directory, create 2 subdirectories: bin(for executable files) and data.

Go to directory data and create subfolders there D.B.(for databases) and htdocs(for websites).

How to Install Apache on Windows XP

Select Custom installation:

Change the installation folder to C:\Server\bin\Apache2.2\:

Once the installation is complete, open http://localhost/ :

Go to directory C:\Server\bin\Apache2.2\conf\ and open the file httpd.conf any text editor.

In it, we need to replace a number of lines.

#ServerName localhost:80

ServerName localhost:80

DocumentRoot "C:/Server/bin/Apache2.2/htdocs"

DocumentRoot "C:/Server/data/htdocs/"

DirectoryIndex index.html

DirectoryIndex index.php index.html index.htm

# AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None

# AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # AllowOverride FileInfo AuthConfig Limit # AllowOverride All

#LoadModule rewrite_module modules/mod_rewrite.so

LoadModule rewrite_module modules/mod_rewrite.so

We save and close the file. That's it, Apache setup is complete! Restart the web server or restart your computer for the changes to take effect.

Place your sites in a folder C:\Server\data\htdocs\.

How to Install PHP on Windows XP

On Windows XP, with this version of Apache, only PHP 5.4 will work, the latest version is PHP 5.4.9, this is the file that we download from the archive.

Download and install the "Microsoft Visual C++ 2008 Redistributable Package (x86)" file for this version of PHP.

In folder C:\Server\bin\ create another folder named PHP, unpack the contents of the downloaded file into it php-5.4.9-Win32-VC9-x86.zip.

In file C:\Server\bin\Apache2.2\conf\httpd.conf add lines at the very end

PHPIniDir "C:/Server/bin/PHP" AddHandler application/x-httpd-php .php LoadModule php5_module "C:/Server/bin/PHP/php5apache2_2.dll"

Now in a folder C:\Server\bin\PHP\ find the file php.ini development and rename it to php.ini.

Open this file php.ini in any text editor, look for the line

; extension_dir = "ext"

and replace it with

Extension_dir = "C:\Server\bin\PHP\ext\"

Now find the group of lines:

;extension=php_bz2.dll ;extension=php_curl.dll ;extension=php_fileinfo.dll ;extension=php_gd2.dll ;extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_intl.dll ;extension=php_imap.dll ;extension =php_interbase.dll ;extension=php_ldap.dll ;extension=php_mbstring.dll ;extension=php_exif.dll ; Must be after mbstring as it depends on it ;extension=php_mysql.dll ;extension=php_mysqli.dll ;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client ;extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client =php_pgsql.dll ;extension=php_pspell.dll ;extension=php_shmop.dll

and replace it with:

Extension=php_bz2.dll extension=php_curl.dll extension=php_fileinfo.dll extension=php_gd2.dll extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_intl.dll ;extension=php_imap.dll ;extension=php_interbase.dll ; extension=php_ldap.dll extension=php_mbstring.dll extension=php_exif.dll ; Must be after mbstring as it depends on it extension=php_mysql.dll extension=php_mysqli.dll ;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client ;extension=php_oci8_11g.dll ; Use with Oracle 11gR2 Instant Client extension=php_openssl.dll ;extension=php_pdo_firebird.dll extension=php_pdo_mysql.dll ;extension=php_pdo_oci.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

now uncomment the lines from this group:

;extension=php_soap.dll ;extension=php_sockets.dll ;extension=php_sqlite3.dll ;extension=php_sybase_ct.dll ;extension=php_tidy.dll ;extension=php_xmlrpc.dll ;extension=php_xsl.dll ;extension=php_zip.dll

should get:

extension=php_soap.dll extension=php_sockets.dll extension=php_sqlite3.dll ;extension=php_sybase_ct.dll ;extension=php_tidy.dll extension=php_xmlrpc.dll extension=php_xsl.dll ;extension=php_zip.dll

Restart the web server:

In catalog C:\Server\data\htdocs\ create a file with the name i.php

Copy to this file:

Unzip the downloaded file to C:\Server\data\htdocs\. Rename this folder (phpMyAdmin-3.5.8.2-all-languages) to phpmyadmin.

In catalog c:\Server\data\htdocs\phpmyadmin\ create a file config.inc.php and copy it there:

Now in a web browser open http://localhost/phpmyadmin/ :

For Username, enter root and leave the password blank.

Conclusion

As you can see, although we have selected suitable versions, it is possible to run a full-fledged web server on Windows XP, even if not with the latest software components.

By the way, you can download the finished assembly created according to this instruction. You will find her.

Many good applications are written in PHP. Not even
a lot and some of them are very good, so why not use these
applications on Windows? Especially if the internal portal is running on Windows, and
on a Unix machine, the external site of the company is spinning - then
can save on infrastructure and host on Windows
server also an external site. Or if you want to standardize
infrastructure and host sites on Windows
platform, since developers and users work on
Windows platform.
On www.iis.net
can be found
list
popular PHP applications
with instructions for installing on IIS. To run them
no change required on IIS
php code.

Installing and configuring PHP for use with the FastCGI module.

To get started, to successfully use PHP on
Windows, PHP would be nice
install.
Step 1Download PHP
On the site PHP.net you need to download
the latest version of PHP for Windows. Recommended for use with FastCGI
set PHP version without thread safety control, since the module itself
FastCGI ensures that execution occurs on a single thread and support
thread safety control in PHP itself introduces unnecessary checks and
blocking, leading to a significant drop in performance. That's why
select Non-thread-safe Win32 binaries (version 5.2.6 is current at the time of writing
this message) .
It is worth noting that we believe Non-thread-safe was designed specifically for
work with FastCGI on IIS (the first release was in version 5.2.1) and use it in
other environments is not recommended. By the way, since version 5.2.2 Zend seriously
working on PHP performance optimization under Windows, which can't help but
please. If we compare versions 5.2.1 and 5.2.2, then the difference in processing speed
requests can be easily seen with a simple load test.
Step 2Installing PHP
Installation is quite simple: since we downloaded the archive from
executable files, it is enough to expand this archive, for example, in
directory C:\Web\PHP.
As a basic configuration, we will use the recommended settings:
make a copy of the php.ini-recommended file in php.ini in the same directory and open
it for editing, after which we will go through the file from above, uncommenting the following
strings to ensure security and compatibility with most PHP
applications:
  • open_basedir = directory where PHP applications are located.
    Specifying a directory will restrict the file permissions of PHP applications to only
    this directory. It is convenient to override this setting in configuration files
    directly for each application, but it does not hurt to install this
    configuration and specify the root directory of all PHP applications. For example, C:\inetpub\PhpSites.
  • cgi.force_redirect = 0
    The default is 1 but needs to be set to 0 because IIS
    controls PHP execution security and there is no
    need. Moreover, inclusion can lead to unexpected
    results. When used with other web servers on Windows, this
    setting must be enabled.
  • cgi.fix_pathinfo=1
    PHP will set the filename in the SCRIPT_FILENAME variable if
    set to 0, then the filename will be in the PATH_TRANSLATED variable, which
    may break compatibility with most applications.
  • fastcgi.impersonate = 1;
    FastCGI allows a process to impersonate using a client context,
    the calling process. This mechanism only works under FastCGI/IIS, for example
    this will not work on Apache on Windows.
  • short_open_tag = On
    Most applications use short tags, so it will not
    it is superfluous to include their support.
  • display_errors = On
    When checking and debugging PHP applications on FastCGI, you should enable output
    error messages.
Step 3Check if PHP is working
While we have not configured IIS, check the health of the interpreter
you can simply, for example, by running the command c:\web\php\php.exe -info > c:\test.txt

Installing and configuring the FastCGI module on IIS7.

If you have IIS7, then something tells me about the name of your operating room
systems - Windows Vista? Didn't guess, then Windows Server 2008! Either you are a hacker and
put IIS7 somewhere else, but this is a non-standard solution and we do not
support ;).
Step 1Install FastCGI
I want to please right away - in IIS7, which comes with Windows Server 2008 and Windows Vista
Service Pack 1 FastCGI module is already included. It only needs to be connected to
settings. To do this, on Vista you need to open Control Panel -> Programs and select
"Turn Windows Features On or Off":

After that, you need to install the feature in IIS: Internet Information Services
-> World Wide Web Services -> Application Development Features -> CGI. Wherein
support for both CGI and FastCGI will be installed.

On Windows Server 2008 the process is similar: Server Manager -> Roles -> Add
Role Services -> Web Server -> Application Development -> CGI.
Actually everything that is required to enable the FastCGI module.
Step 2Configuring IIS7
1. Open IIS Manager, select the node (server) for which you want to configure
PHP support. And then select Handler Mappings.

2. Select the Add Module Mapping link on the Handler Mappings page and
fill the window with the following values:
Request path: *.php (processing all files with .php extension)
Module: FastCgiModule (FastCGI module)
Executable: C:\Web\PHP\php-cgi.exe (path to PHP)
Name: PHP (name for convenience)

After adding this setting, a window with a question about registration will appear.
FastCGI application for this handler. We confirm.
The actions described above led to the creation in the PhpSites directory of the following
web.config file:


< configuration >
< system.webServer >
< handlers >
< add name =«PHP» path ="*.php" verb ="*"
modules="FastCgiModule" scriptProcessor ="C:\Web\PHP\php-cgi.exe "
resourceType ="Unspecified" />



Now we can move on to PHP health check.
Step 3. Checking the correctness of the settings
In the directory of the node for which we configured PHP, we create a file
index.php:
phpinfo();
?>
And we access this file via an HTTP request. As a result, if all is well and
our karma is not corrupted, the request will be processed correctly:

Of course, when using PHP on
IIS7 may have pitfalls that you need to
fight to achieve the expected result (great work
PHP applications on Windows).
Hammers for breaking common stones are shown below.

PHP process restart frequency

Because when using PHP on
IIS7 using FastCGI
module, the FastCGI module itself takes care of
process and resource management, you need to make sure that the restart mechanism
processes (recycling) in PHP
won't interfere with FastCGI. This is easy to do if
configure FastCGI to always restart
processes before PHP does.
There is a setting in FastCGI settings
instanceMaxRequests, which determines after processing how many requests,
the process will be restarted. In PHP, a similar setting
set by the value of the PHP_FCGI_MAX_REQUESTS variable. Obviously to give
the ability of FastCGI to steer the process is enough
set instanceMaxRequests<= PHP_FCGI_MAX_REQUEST.
It is convenient to do this by editing the file
applicationHost.config (hidden in the C:\windows\system32\inetsrv\config\ directory).
The configuration should contain the following information:

< fastCgi >
< application fullPath ="C:\inetpub\php\php-cgi.exe "
maxInstances="4" instanceMaxRequests="10000" >
< environmentVariables >
< environmentVariable name =«PHP_FCGI_MAX_REQUESTS» value =«10000» >


Using Multiple Versions of PHP

Because different versions of PHP can be used in
applications that are hosted on the server, it would be nice to be able to
use different versions for different sites.
In the configuration file applicationHost.config
it is enough to define sections for different versions of PHP:
< fastCgi >
< application fullPath ="C:\inetpub\php\php-cgi.exe">
...

< application fullPath =«C:\inetpub\php4\php4.exe» >
...

< application fullPath ="C:\inetpub\php41\php41.exe">
...


* This source code was highlighted with .
And for each of the sites, a module is configured that uses one or another
version (you can use the interface described above, or you can
edit the configuration in the text):
< handlers >
< add name =«PHP4» path ="*.php" verb ="*" modules =«FastCgiModule»
scriptProcessor ="C:\inetpub\php\php41.exe"
resourceType ="Unspecified" />

* This source code was highlighted with .

Using Different PHP Presets

If you want to configure PHP differently for
different sites, then again, all this can be described through the configuration settings in
applicationHost.config.
< fastCgi >

< application fullPath ="C:\inetpub\php\php-cgi.exe "

arguments ="-d my.website=wordpress" >

< environmentVariables >

< environmentVariable name =«PHPRC» value =«C:\inetpub\wordpress» />





< application fullPath ="C:\inetpub\php\php-cgi.exe "

arguments ="-d my.website=phpsite" >

< environmentVariables >

< environmentVariable name =«PHPRC» value =«C:\inetpub\phpsite» />






* This source code was highlighted with .

After that, the settings are linked to the corresponding sites in
web.config:
< system.webServer >

< handlers accessPolicy =«Read, Script» >
< add name =«PHP» path ="*.php" verb ="*" modules =«FastCgiModule»
scriptProcessor ="C:\inetpub\php\php-cgi.exe|-d my.website=wordpress"

resourceType ="Unspecified" requireAccess ="Script" />




* This source code was highlighted with .

According to the given configuration, php.ini
must be placed in the directory of each of the sites.
When editing settings, you should strictly observe the coincidence of paths to
corresponding PHP version and with
applicationHost.config and in web.config to
avoid unexpected results if the paths are reversed.
At first glance, editing the configuration may seem complicated and
awkward process, but once you get used to the configuration in
XML and settings distribution method
Ctrl+C, Ctrl+V, you'll be surprised at the presence of others
config ways :)

PHP security settings

There are many different settings in php.ini, many of which
affect the security of using PHP. Tune
all in a fitting way, a worthy cause.
Set allow_url_fopen=Off
; using URL for file operations
Set allow_url_include=Off
register_globals=Off
; unregister global variables
open_basedir="c:\inetpub\" ;
limit on the directory in which PHP is running

Max_execution_time=30 ; limitation
script execution time
max_input_time=60
memory_limit=16M ;
memory limit
upload_max_filesize=2M
post_max_size=8M
max_input_nesting_levels=64
display_errors=Off
; disable error messages
log_errors=On
error_log="C:\error.log"
expose_php=Off
; hide PHP presence

Conclusion

PHP on Windows is not
just interesting and convenient, the main thing is that it works. A team
IIS is working on PHP
worked on Windows as well as on
Unix/Linux (of course, they try to do better).
Since this is a new theme for Microsoft, we can
make some mistakes, we may not notice or understand something, so we
it is very important to receive comments from you - developers and administrators.
Write in the comments your wishes and problems that you see now in
PHP on Windows, and we will
try to solve problems, and implement wishes.

Tags: Add tags

If you are a Linux user, then refer to the article "".

PHP 7 release

PHP 7.0.0 Alpha release 2 is currently available. The first beta will appear in the coming days. Neither alpha nor beta are recommended for real work. But you can already try them on the test server.

Especially since PHP7 changes are very significant:

  • Up to 2x the performance of PHP 7 compared to PHP 5.6 (wow!)
  • Expected 64-bit support
  • Many fatal errors are now Exceptions
  • Remove old and unsupported SAPIs (Server Application Programming Interfaces) and extensions
  • NULL operator coalescing (??)
  • Combined comparison operator (<=>)
  • return type declaration
  • Scalar type declaration
  • Anonymous classes
How to Install PHP 7 on Windows

PHP of any version is almost always paired with a server and a database management system. If you do not have a server at all, then refer to the article "". When you get to installing PHP in that article, come back here.

If you already have a server, then you can find general upgrade questions in the article "".

Features of installing PHP 7 on Windows

I installed on Apache 2.4 VC14. If you haven't upgraded the server yet, then do so. Links and details on this manual.

To download PHP 7.0 go to

Hidden from guests

Always download all programs only from official sites!

Select version Thread Safe(64-bit or 32-bit as your Apache server).

Definitely needed Visual C++ Redistributable for Visual Studio 2015! If you have already upgraded the Apache server, then that server also needs this package. Those. you should have installed it already. If this is not the case, then go to

Hidden from guests

And download the appropriate bitness package.

After downloading, install it.

If you use when installing the server, then unpack the contents of the downloaded archive from PHP into the directory C:ServerbinPHP.

Go to this directory, find the file php.ini development and rename it to php.ini.

Open this file with any text editor, find the line there

; extension_dir = "ext"

And replace it with

Extension_dir = "ext"

Now we need to enable PHP extensions, because most sites and scripts won't work without them. Attention: at the moment with some extensions it is not possible to start the server, so take a close look below. Find a group of lines:

;extension=php_bz2.dll ;extension=php_curl.dll ;extension=php_fileinfo.dll ;extension=php_gd2.dll ;extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_intl.dll ;extension=php_imap.dll ;extension =php_interbase.dll ;extension=php_ldap.dll ;extension=php_mbstring.dll ;extension=php_exif.dll ; Must be after mbstring as it depends on it ;extension=php_mysqli.dll ;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client ;extension=php_openssl.dll ;extension=php_pdo_firebird.dll ;extension=php_pdo_mysql.dll ;extension=php_pdo_oci.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

And replace them with the following lines. Please note that some extensions are left disabled, because when they are enabled, Apache does not start!

extension=php_bz2.dll extension=php_curl.dll extension=php_fileinfo.dll extension=php_gd2.dll extension=php_gettext.dll extension=php_gmp.dll extension=php_intl.dll extension=php_imap.dll ;extension=php_interbase.dll extension=php_ldap. dll extension=php_mbstring.dll extension=php_exif.dll ; Must be after mbstring as it depends on it extension=php_mysqli.dll ;extension=php_oci8_12c.dll ; Use with Oracle Database 12c Instant Client extension=php_openssl.dll ;extension=php_pdo_firebird.dll extension=php_pdo_mysql.dll ;extension=php_pdo_oci.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

Now we find the following group of lines:

;extension=php_soap.dll ;extension=php_sockets.dll ;extension=php_sqlite3.dll ;extension=php_tidy.dll ;extension=php_xmlrpc.dll ;extension=php_xsl.dll

These extensions can include all:

extension=php_soap.dll extension=php_sockets.dll extension=php_sqlite3.dll extension=php_tidy.dll extension=php_xmlrpc.dll extension=php_xsl.dll

We save and close the file.

Now let's move on to the Apache configuration file. For those who installed according to my instructions, this file is here C:ServerbinApache24confhttpd.conf

Open it with any text editor. We find the lines with which we connected PHP 5 and delete them.
instructions so that you can quickly and easily install everything.

Installing a web server on Linux:

  • If you have Ubuntu, then the article "How to install Apache web server with PHP 7, MariaDB/MySQL and phpMyAdmin (LAMP) on Ubuntu 16.10" will suit you.
  • If you have Arch Linux, then the article "Installing LAMP (Linux, Apache, MySQL/MariaDB, PHP7 and phpMyAdmin) on Arch Linux / BlackArch" will suit you.

The local server is a very useful tool. It will definitely come in handy for webmasters, PHP programmers, penetration testers. All of the programs included in a typical web server installation are free, and all are open source. A local web server consumes a minimum of resources and, in fact, it is not difficult to install and configure it at all.

This guide will tell you how to install a local web server without using ready-made builds. This method has its advantages. The most important of these are: full control over what you install; the ability to use the latest software versions.

If you follow the instructions exactly, then everything will work for you! Except for those who have Windows XP - if you have this operating system, then a special instruction has been made for you.

I will show an example of installation on Windows 10, but if you have a different version of Windows, then do not be embarrassed - the procedure is identical everywhere. I will download the latest (most recent) at the time of writing the versions of the programs. If there are new versions coming out by the time you're reading, then download those.

Installation steps:

You may also find it useful:

1. Preparation (downloading the programs included in the server, creating the server structure)

We need:

  • Apache(directly web server)
  • PHP- environment for running PHP programs (required by almost all websites)
  • MySQL- database management system (required by most websites)
  • phpMyAdmin- very handy database management tool

The official website of the Apache developers is httpd.apache.org . You can download Apache from this site. But the official version is built using the old compiler, for this reason it does not work with new versions of PHP. The PHP authors recommend Apache from apachelounge.com/download. Therefore, for this instruction, we download Apache from the site apachelounge.com/download.

If you have a 64-bit version of Windows, then you can choose both 64-bit and 32-bit versions of the components. The main rule is that all components must be of the same bit depth. If you have a 32-bit version of Windows, then all components must be 32-bit. This does not apply to phpMyAdmin, which is written in PHP. For PHP programs, the concept of bitness is not applicable.

The free version of MySQL is called MySQL Community Server. It can be downloaded from the page. The same page has an executable installer, but I recommend downloading the ZIP file. On the download page, we are prompted to register or log into an existing account - but this is not necessary. Just click on the link " No thanks, just start my download". Pay attention to bitness.

We also need a C++ Redistributable Visual Studio 2017 file, i.e. The Visual C++ Redistributable for Visual Studio 2017 (or any other later one), you can download it on the official Microsoft website at the link (direct download link for the 64-bit version; direct download link for the 32-bit version). This file is needed for the web server. And MySQL requires the Visual C++ Redistributable Packages for Visual Studio 2015. You can download it from .

So, I have downloaded the following files:

  • httpd-2.4.29-Win64-VC15.zip
  • php-7.2.0-Win32-VC15-x64.zip
  • mysql-8.0.11-winx64.zip
  • phpMyAdmin-4.7.6-all-languages.zip
  • vc_redist.x64.exe
  • vcredist_x64.exe

Install files vc_redist.x64.exe And vcredist_x64.exe.

2. Create the structure of the web server

Let's create the directory structure of our server. The main idea is to separate executable files and site files from databases. This is convenient for server maintenance, including backup.

At the root of the disk C:\ create a directory server. In this directory, create 2 subdirectories: bin(for executable files) and data.

Go to directory data and create subfolders there D.B.(for databases) and htdocs(for websites).

Go to directory C:\Server\data\DB\ and create an empty folder there data.

3. Installing Apache 2.4

The contents of the downloaded archive (more precisely, only the directory Apache24), unzip to C:\Server\bin\.

Go to directory c:\Server\bin\Apache24\conf\ and open the file httpd.conf any text editor.

In it, we need to replace a number of lines.

Define SRVROOT "c:/Apache24"

Define SRVROOT "c:/Server/bin/Apache24"

#ServerName www.example.com:80

servername localhost

DocumentRoot "$(SRVROOT)/htdocs"

DocumentRoot "c:/Server/data/htdocs/"

DirectoryIndex index.html

DirectoryIndex index.php index.html index.htm

# AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # AllowOverride FileInfo AuthConfig Limit # AllowOverride None

# AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # AllowOverride FileInfo AuthConfig Limit # AllowOverride All

#LoadModule rewrite_module modules/mod_rewrite.so

LoadModule rewrite_module modules/mod_rewrite.so

We save and close the file. That's it, Apache setup is complete! A description of each modified directive can be found on this page.

Open a command prompt (this can be done by pressing the Win + X keys at the same time). Select Windows PowerShell (Administrator) there and copy there:

C:\Server\bin\Apache24\bin\httpd.exe -k install

If there is a request from the firewall against Apache, then click Allow.

Now enter on the command line:

C:\Server\bin\Apache24\bin\httpd.exe -k start

And press Enter.

Enter root as the username. Leave the password field blank. If everything is done correctly, then everything should look like this:

7. Server usage and data backup

In catalog c:\Server\data\htdocs\ create folders and files, for example:

c:\Server\data\htdocs\test\ajax.php - this file, respectively, will be available at http://localhost/test/ajax.php, etc.

To create a full backup of all sites and databases, just copy the directory C:\Server\data\.

Before updating modules, make a backup of the folder bin- in case of problems, it will be easy to roll back to previous versions.

When you reinstall the server or upgrade it, you must reconfigure the configuration files. If you have copies of these files, then the process can be greatly accelerated. It is recommended to back up the following files:

  • c:\Server\bin\Apache24\conf\httpd.conf
  • c:\Server\bin\mysql-8.0\my.ini
  • c:\Server\bin\PHP\php.ini
  • c:\Server\data\htdocs\phpMyAdmin\config.inc.php

All settings are stored in them.

8. Additional PHP setup

PHP is currently a very powerful, flexible, user-friendly tool. On a local computer, it can be used to perform a variety of tasks that are not necessarily related to the generation of Web pages. When solving extraordinary tasks, you can run into the restrictions set in the settings. These settings are contained in the php.ini file (c:\Server\bin\PHP\php.ini) Let's look at some of them:

memory_limit = 128M

sets the maximum amount of memory the script can use

Post_max_size = 8M

sets the maximum amount of data that will be accepted when sending using the POST method

;default_charset = "UTF-8"

sets the encoding (by default, the line is commented out)

Upload_max_filesize = 2M

the maximum size of the file uploaded to the server. Initially set to a very small size - only two megabytes. For example, when loading a database in phpMyAdmin, it will not be possible to load a file larger than 2 megabytes until this setting item is changed.

Max_file_uploads = 20

maximum number of files to upload at one time

Max_execution_time = 30

maximum execution time for one script

It is not necessary to change these settings, but it is useful to know about them.

9. Additional configuration of phpMyAdmin

We have already configured phpMyAdmin and most of the basic functionality is enough. However, on the phpMyAdmin start page, there is an inscription: "Additional features of phpMyAdmin are not fully configured, some features have been disabled."

New features are:

  • showing relationships between (related) tables;
  • adding information about tables (since version 2.3.0 you can describe in a special table 'table_info' which column will be shown in the tooltip when moving the cursor over the associated key);
  • creation of a PDF schema (starting from version 2.3.0 you can create PDF pages in phpMyAdmin showing relationships between your tables);
  • display column comments (since version 2.3.0 you can make a comment describing each column for each table. And they will be visible in the "print preview". Since version 2.5.0, comments are used on native table pages and in view, showing as tooltips above columns (property tables) or embedded in the table header in view mode (they can also be shown in a table dump);
  • create bookmarks (since version 2.2.0, phpMyAdmin allows users to bookmark queries. This can be useful for frequently used queries);
  • history of SQL queries (starting from version 2.5.0 you can save your history of all SQL queries that were made through the phpMyAdmin interface);
  • designer (starting from version 2.10.0, the Designer tool is available; it allows you to visually manage the relationships between tables);
  • information about recently used tables;
  • customizing the interface of frequently used tables;
  • tracking (starting from version 3.3.x, a tracking mechanism is available. It helps you trace every SQL command that was executed by phpMyAdmin. Recording work with data and recording commands is supported. Once enabled, you can make versions of tables);
  • user settings (since version 3.4.x, phpMyAdmin allows users to set most of the settings and save them in the database);
  • custom menus (starting from version 4.1.0 you can create user groups that will only have access to assigned menu items. A user can be assigned to a group and will see only menu items available to his group);
  • hide/show navigation items (since version 4.1.0 you can hide/show items in the navigation tree).
  • and others

Now we will configure these additional features in full. Go to http://localhost/phpmyadmin/chk_rel.php and click "Create Database". After that, all new features will be activated.

Some screenshots of new features:

1) Designer

2) Tracking

10. Installing a mail stub

In the C:\Server\bin\ directory, create a new directory called Sendmail. Now in this directory create a sendmail.php file with the following content:

#!/usr/bin/env php

Open the PHP configuration file, it is located here C:\Server\bin\PHP\php.ini. And add one line there:

Sendmail_path = "C:\Server\bin\PHP\php.exe C:\Server\bin\Sendmail\sendmail.php --dir C:\Server\bin\Sendmail\emails"

Save the file and restart the server. Great, now all sent emails will be stored in the directory C:\Server\bin\Sendmail\emails\

Letters will have the extension .eml and they can be opened, for example, by the program Thunderbird. Or a regular text editor.

11. Adding PHP Directory to PATH on Windows

If this is not done, then there may be problems with some PHP modules, including php_curl.dll, php_intl.dll, php_ldap.dll, php_pdo_pgsql.dll and php_pgsql.dll. At least when the server is started, the following appears in the logs every time:

PHP Warning: PHP Startup: Unable to load dynamic library "C:\\Server\\bin\\PHP\\ext\\php_curl.dll" - \xef\xbf\xbd\xef\xbf\xbd \xef\xbf\ xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\ xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\ xbf\xbd\xef\xbf\xbd.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library "C:\\Server\\bin\\PHP\\ext\\php_intl.dll " - \xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd \xef \xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library " C:\\Server\\bin\\PHP\\ext\\php_ldap.dll" - \xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\ xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\ xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd.\r \n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library "C:\\Server\\bin\\PHP\\ext\\php_pdo_pgsql.dll" - \xef\xbf\xbd\xef\xbf \xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef \xbf\xbd\xef\xbf\xbd\xef\xbf\xbd.\r\n in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library "C:\\Server\\bin\\PHP\ \ext\\php_pgsql.dll" - \xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\ xbd\xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\ xef\xbf\xbd \xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd.\r\n in Unknown on line 0

To avoid these warnings, you need to add the path to PHP to the system environment variables.

Click the Start button (or whatever it's called on Windows 10?), start typing " Changing System Environment Variables” and open the corresponding settings window.

There click " Environment Variables»:

In the window " System variables» find and click on Path, then press " Change»:

Move the entry to the very top:

Close all windows and save your changes.

Restart the server.

12. Hang, traffic slowdown and/or server error Asynchronous AcceptEx failed

If your server “freezes” even without load - it does not show web pages until it is restarted, and in the server logs there are errors Asynchronous AcceptEx failed:

AH00455: Apache/2.4.9 (Win64) PHP/5.5.13 configured -- resuming normal operations AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:42:59 AH00094: Command line: "c:\\Server\\ bin\\Apache24\\bin\\httpd.exe -d C:/Server/bin/Apache24" AH00418: Parent: Created child process 4952 AH00354: Child: Starting 64 worker threads. (OS 64) The specified network name is no longer available. : AH00341: winnt_accept: Asynchronous AcceptEx failed. (OS 64) The specified network name is no longer available. : AH00341: winnt_accept: Asynchronous AcceptEx failed. (OS 64) The specified network name is no longer available. : AH00341: winnt_accept: Asynchronous AcceptEx failed. (OS 64) The specified network name is no longer available. : AH00341: winnt_accept: Asynchronous AcceptEx failed. (OS 64) The specified network name is no longer available. : AH00341: winnt_accept: Asynchronous AcceptEx failed. (OS 64) The specified network name is no longer available. : AH00341: winnt_accept: Asynchronous AcceptEx failed.

Then in the Apache configuration file add:

AcceptFilter http none AcceptFilter https none EnableSendfile off EnableMMAP off

13. Setting up cURL in Apache Web Server on Windows

If you don't know what cURL is, then you don't need it. Those. Feel free to skip this step.

cURL is a console utility that allows you to communicate with remote servers using a very large number of protocols. cURL can use cookies and supports authentication. If the web application requires cURL, then it must be specified in the dependencies. Many popular applications do not require cURL, for example, phpMyAdmin and WordPress do not need to set up cURL.

If cURL is configured incorrectly, then you will get errors:

Fatal error: Call to undefined function curl_multi_init() in ...

curl error: SSL certificate problem: unable to get local issuer certificate

For cURL to work in Apache on Windows you need:

1) Be sure to add PHP directory to PATH (system environment variables). How to do this is described just above:

2) In file C:\Server\bin\PHP\php.ini the line should be uncommented extension=curl

This is not normally required, but you can backup the server's binary (executable) files if you wish. All these files are in the folder C:\Server\bin\. These are Apache, MySQL and PHP - i.e. programs that are responsible for the operation of the server, but which we can download at any time from official sites and reconfigure.

If you want to make a backup copy of them (for example, before updating the server), then stop the services:

C:\Server\bin\Apache24\bin\httpd.exe -k stop net stop mysql

And copy the folder to a safe place C:\Server\bin\.

By the way, you can copy the entire server, ie. folder C:\Server\- in this case, you will simultaneously get a backup copy of both executable files and data (databases, sites).

When the copy is complete, restart the services:

C:\Server\bin\Apache24\bin\httpd.exe -k start net start mysql

15. Server update

All components that make up the web server are actively developed and new versions are released regularly. When a new version is released, you can update one component (for example, PHP), or several at once.

17. Nothing works for me

This manual is regularly reviewed and tested with the latest components. Since the instruction is voluminous, the occurrence of errors may be due to the fact that you missed something or did something wrong. First, try deleting everything and doing it all over again.

Over the years of the existence of this manual, many typical errors that occur in the web server have been collected, all of them, along with the solution to problems, are described on a separate page " Errors when configuring and installing Apache, PHP, MySQL/MariaDB, phpMyAdmin". It also says how to correctly describe your problem so that you can be helped to deal with it.

If something does not work for you, then please, before asking a question in the comments, search this error page. To do this, you can use Ctrl+F in your browser and search for part of the error line.

There is a rare error associated with the fact that some other program is already listening on port 80. To determine if port 80 is already in use, do this:

1) press the key combination WIN + x

2) from the list that opens, select "Windows PowerShell (administrator)"

3) execute there:

Cmd for /f "tokens=1,2,3,4,5*" %i in ("netstat -aon ^| findstr ":80" ^| findstr /i listening") do echo %j %l & @tasklist | findstr %m

If some program is already hanging on port 80, then you will see it.

Removing a server

If you no longer need the server, or you want to install it again, stop the services and remove them from autostart by executing in the command line:

C:\Server\bin\Apache24\bin\httpd.exe -k stop c:\Server\bin\Apache24\bin\httpd.exe -k uninstall net stop mysql c:\Server\bin\mysql-8.0\bin\ mysqld --remove

Delete the server files, to do this, delete the folder C:\Server\. Attention, this will remove all databases and your sites.

How to protect the Apache web server from being hacked on Windows

With PHP (with a choice of versions), with MySQL and phpMyAdmin. This site is hosted on it: responsive and qualified technical support, installation of WordPress and other web applications in one click,

This section of the manual applies to Windows 98/Me and Windows NT/2000/XP/2003. PHP will not run on 16 bit platforms such as Windows 3.1 and sometimes we refer to Windows supported platforms as Win32.

Comment:

Windows XP/2003 are no longer supported for PHP 5.5.0.

Comment:

Windows 98/Me/NT4/2000 are no longer supported for PHP 5.3.0.

Comment:

Windows 95 is no longer supported for PHP 4.3.0.

If you have a development environment such as Microsoft Visual Studio, you can also build PHP from source.

Once PHP is installed on Windows, you may also want to download various extensions to provide additional functionality.

Manual Installation Guide

This section contains instructions for manually installing and configuring PHP on Microsoft Windows.

Selecting and downloading a PHP distribution package

Download the PHP distribution as a zip file from . There are several different versions of zip packages - choose the version that suits your web server:

Structure and content of the PHP package

Extract the contents of the zip archive to a directory of your choice, for example C:\PHP\. The structure of folders and files extracted from the archive will look like this:

Example #1 PHP 5 package structure

c:\php | +--dev | | | |-php5ts.lib -- non-threaded version of php5.lib | +--ext -- DLL extensions for PHP | | | |-php_bz2.dll | | | |-php_cpdf.dll | | | |-... | +--extras -- empty | +--pear -- initial copy of PEAR | | |-go-pear.bat -- PEAR installation script | |-... | |-php-cgi.exe -- CGI executable | |-php-win.exe -- executes scripts without open console | |-php.exe -- PHP Command Line (CLI) Executable | |-... | |-php.ini-development -- default php.ini settings | |-php.ini-production -- recommended php.ini settings | |-php5apache2_2.dll -- available in multi-threaded version only | |-php5apache2_2_filter.dll -- only available in multi-threaded version | |-... | |-php5ts.dll -- core PHP DLL (php5.dll in non-threaded version) | |-...

Below is a list of modules and executables included in the PHP zip distribution:

    php-cgi.exe is a CGI executable that can be used while running PHP on IIS via CGI or FastCGI.

    php-win.exe - PHP executable for executing PHP scripts without using the console (for example, PHP applications using Windows GUI).

    php.exe - PHP executable file for executing PHP scripts in the console (CLI).

    php5apache2_2.dll - Apache 2.2.X module.

    php5apache2_2_filter.dll - Apache 2.2.X filter.

Changing the php.ini file

Once the contents of the php package are extracted, make a copy of php.ini-production named php.ini in the same folder. If needed, it is also possible to place the php.ini in any other location of your choice, but this requires additional configuration, which is listed in the PHP Configuration section.

The php.ini file contains PHP execution rules and instructions for working with the environment in which it runs. The following are some of the php.ini settings that can improve how PHP works on Windows. Some of them are optional. There are many other directives that may be useful in your environment - see the list of php.ini directives for more details.

Mandatory directives:

    extension_dir = <путь к директории расширений> - extension_dir specifies the directory where PHP extensions are located. The path can be absolute (eg "C:\PHP\ext") or relative (eg ".\ext"). Extensions used in php.ini must be located in extension_dir .

    extension= xxxxx.dll- For each pluggable extension, you must specify the "extension=" directive. Extensions from extension_dir marked with this directive are loaded when PHP starts.

    log_errors = On- PHP has an error logging mechanism that can be used to store errors in a file or send them to a service (eg syslog). The mechanism also uses the value of the error_log directive. When PHP is executed by IIS, log_errors must be enabled with the correct error_log .

    error_log = <пусть к файлу лога ошибок> - error_log is needed to indicate the absolute or relative path to the file where PHP errors are logged. This file must be writable by the web server. The most common locations for this file are various temporary TEMP directories, such as "C:\inetpub\temp\php-errors.log".

    cgi.force_redirect = 0 - This directive is required for execution under IIS. This is a directory protection mechanism required by many other web servers. However, enabling it under IIS will cause PHP kernel errors on Windows.

    cgi.fix_pathinfo = 1 - Provides support for PATH_INFO according to the CGI specification. IIS FastCGI uses this setting.

    fastcgi.impersonate = 1 - FastCGI under IIS supports the ability to identify the calling client's security tokens. This allows IIS to determine the security context under which the request is being made.

    fastcgi.logging= 0 - FastCGI logging should be disabled in IIS. If the entry is enabled, then all messages of any class will be recognized as errors by FastCGI, which will cause IIS to throw an HTTP 500 exception.

Optional directives

    max_execution_time = ## - This directive specifies the maximum execution time for any PHP script. The default is 30 seconds. You should increase this value if your PHP application needs to run longer.

    memory_limit = ###M- The amount of memory available to the PHP process, in MB. The default is 128, which is sufficient for most PHP applications. Some complex applications may require more memory.

    display_errors = Off- The directive defines which errors should be returned to the web server for further logging. When set to "On", PHP reports all kinds of errors that are listed in the error_reporting directive. For security reasons, it is recommended to set it to "Off" on production servers to prevent error output from being passed to the end user, as they may contain information that threatens the security of the application.

    open_basedir = <пути к директориям, разделенные точкой с запятой> , for example openbasedir="C:\inetpub\wwwroot;C:\inetpub\temp". This directive specifies the paths to directories where PHP is allowed to operate on the file system. Any operation on files and directories outside the specified paths will result in an error. This directive is especially useful for preventing access to the installed PHP in shared hosting environments to prevent PHP scripts from accessing any files outside the web site's root directory.

    upload_max_filesize = ###M and post_max_size = ###M- The maximum allowed size of the uploaded file and sent data, respectively. The values ​​of these directives should be increased if PHP applications need to process large uploads, such as images or videos.

Once PHP is installed on your system, the next step is to select a web server and configure it further to work with PHP. Select a specific web server in the table of contents for this material.

Microsoft IIS 5.1 and IIS 6.0

This section contains instructions for manually setting up Internet Information Services (IIS) 5.1 and IIS 6.0 to work with PHP on Microsoft Windows XP and Windows Server 2003. For instructions on setting up IIS 7.0 and later versions on Windows Vista, Windows Server 2008, Windows 7 and Windows Server 2008 R2 refer to Microsoft IIS 7.0 and later .

Configuring IIS to process PHP requests

Download and install PHP in accordance with the instructions described in manual installation steps

Comment:

Non-thread-safe build of PHP is recommended when using IIS. The non-thread-safe builds are available at

Configure the CGI- and FastCGI-specific settings in php.ini file as shown below:

Example #2 CGI and FastCGI settings in php.ini

Enabling FastCGI Support in IIS

The FastCGI module is disabled by default when installing IIS. The methods for enabling it vary depending on the version of Windows you are using.

To enable FastCGI support on Windows Vista SP1 and Windows 7:

    In the "Start" menu, select "Run", in the window that appears, type "optionalfeatures.exe" from the keyboard and click "Ok";

    In the "Windows Components" window that opens, expand the folder "IIS", "Internet Services", "Application Development Components" and check the box next to "CGI";

    Click OK and wait for the installation process to complete.


To enable FastCGI support on Windows Server 2008 and Windows Server 2008 R2:

    In Windows, open the Start menu, select "Run:", type "CompMgmtLauncher" from the keyboard and click "Ok";

    If the "Web Server (IIS)" role is not listed in the "Roles" tab, add it by selecting "Add Roles";

    If the "Web Server (IIS)" role is present, select "Role Service Selection" and check the box next to "CGI" in the "Application Development Components" group;


Configuring IIS to Handle PHP Requests

Download and install PHP according to the instructions given in the installation description

Comment:

Change the CGI and FastCGI settings in the php.ini file as shown below:

Example #8 CGI and FastCGI settings in php.ini

fastcgi.impersonate = 1 fastcgi.logging = 0 cgi.fix_pathinfo=1 cgi.force_redirect = 0

Set up an IIS handler for PHP using the IIS Management Interface or via the command line.

Using the IIS Management Interface to Create a PHP Handler

The following steps will allow you to create an IIS handler for PHP in the IIS Management Interface:



Using the command line to create a PHP handler mapping

Use the commands below to create an IIS FastCGI process pool that will use the php-cgi.exe executable for PHP requests. Replace the value of the fullPath parameter with the absolute path to the php-cgi.exe file.

Beispiel #9 Creating an IIS FastCGI process pool

%windir%\system32\inetsrv\appcmd set config /section:system.webServer/fastCGI ^ /+

Configuring IIS to handle specific PHP requests from the command line is shown below. Replace the value of the scriptProcessor parameter with the absolute path to the php-cgi.exe file.

Example #10 Creating a PHP request handler mapping

%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers ^ /+

This command creates a handler mapping for IIS for *.php files, which is the result and processed by the FastCGI module.

Comment:

This step completes the installation and configuration. The following instructions are optional but highly recommended for optimal PHP functionality and performance on IIS.

Presentation and access to the file system

When using IIS, it is recommended to enable the FastCGI view in PHP. This is controlled by the fastcgi.impersonate directive in the php.ini file. When impersonation is enabled, PHP will perform all operations on the file system under the account that was specified during IIS authentication. This ensures that, given a common PHP process for all IIS sites, the sites' PHP scripts will not have access to each other's files as long as IIS uses different accounts for each site.

For example, in the default settings of IIS 7, anonymous authentication is enabled under the standard user IUSR. This means that while giving IIS permission to execute a PHP script, it is also necessary to give the IUSR account permission to read this script. If the PHP application needs to write to some files or folders, then the IUSR account should be given write access to them.

To decide which user is used for authentication in IIS 7, you can use the following commands. Replace "Default Web Site" with the name of the IIS site you are working with. In the output, in the configuration XML, see the userName attribute.

Example #11 Determining the account used by IIS for anonymous authentication

%windir%\system32\inetsrv\appcmd.exe list config "Default Web Site" ^ /section:anonymousAuthentication

Comment:

If the userName attribute is not present on the anonymousAuthentication element, or is set to the empty string, then the application pool identity is used as anonymous for this website.

To change access settings for files or folders, use the user interface in Windows Explorer or the icacls command.

Example #12 Setting file permissions

icacls C:\inetpub\wwwroot\upload /grant IUSR:(OI)(CI)(M)

Setting index.php as default document in IIS

By default, IIS does not have a document name set to handle HTTP requests by default. In PHP applications, the default document is index.php . To add index.php to the default IIS document sheet, use the following command:

Beispiel #13 Setting index.php as the default document in IIS

%windir%\system32\inetsrv\appcmd.exe set config ^ -section:system.webServer/defaultDocument /+"files." ^ /commit:apphost

FastCGI and PHP configuration with process re-creation

Configuring IIS FastCGI settings for recycling PHP processes using the commands is given below. The FastCGI instanceMaxRequests option sets the maximum number of requests that can be processed by one php-cgi.exe process until IIS starts to disable them. The PHP environment variable PHP_FCGI_MAX_REQUESTS sets how many requests a single php-cgi.exe process will handle before it starts deleting them. Of course, the value set for FastCGI InstanceMaxRequests is less than or equal to PHP_FCGI_MAX_REQUESTS .

Beispiel #14 Setting up FastCGI and rebuilding PHP

%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^ /.instanceMaxRequests:10000 %windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^ / +".environmentVariables.^"

Setting the FastCGI Timeout

Increasing the timeout parameter for FastCGI is done if there is a long-running PHP script. Two parameters control the timeout, they are: activityTimeout and requestTimeout . Use the commands below to change the timeout settings. Of course, you need to replace the value of the fullPath parameter with the full path to the php-cgi.exe file.

Example #15 Configuring FastCGI timeout settings

%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi ^ /.activityTimeout:"90" /commit:apphost %windir%\system32\inetsrv\appcmd.exe set config -section:system .webServer/fastCgi ^ /.requestTimeout:"90" /commit:apphost

Changing the position of the php.ini file

There are two ways to configure PHP to work with Apache 1.3.x on Windows. The first is to use the CGI binary (php.exe for PHP 4 and php-cgi.exe for PHP 5), the second is to use the Apache Module DLL. In both cases, you need to edit httpd.conf to configure Apache to work with PHP and restart the server.

Currently the SAPI module is more stable under Windows, so we recommend using it instead of CGI as it is more transparent and secure.

Although there are several options for configuring PHP under Apache, they are quite simple for a beginner. Please refer to the Apache documentation for further configuration instructions.

Don't forget to restart the server after changing the configuration file. For example, commands NET STOP APACHE And NET START APACHE, if Apache is running as a Windows service, or using regular shortcuts.

Comment:

Installing PHP as an Apache module

You need to add the following lines to the Apache httpd.conf file:

Example #17 PHP as an Apache 1.3.x module

This assumes PHP is installed in c:\php . Change the path if it's not.

# Add to the end of the LoadModule section # Don"t forget to copy this file from the sapi directory! LoadModule php4_module "C:/php/php4apache.dll" # Add to the end of the AddModule section AddModule mod_php4.c

# Add to the end of the LoadModule section LoadModule php5_module "C:/php/php5apache.dll" # Add to the end of the AddModule section AddModule mod_php5.c

For both versions:

# Add this line inside the conditional brace AddType application/x-httpd-php .php # For syntax highlighted .phps files, also add AddType application/x-httpd-php-source .phps

Installation as binary CGI file

If PHP is unpacked to C:\php\ as described in the Manual Installation Steps section, the following lines must be added to the Apache configuration file:

Example #18 PHP and Apache 1.3.x as CGI

Note that the second line in the list above is already in httpd.conf , but it's commented out. Also, don't forget to replace c:/php/ with your actual PHP path.

Attention

"CGI Security"

When installing PHP as a CGI, there is no such convenient option for syntax highlighting of PHP sources as when installing as a module. If you want to use it, you must use the function highlight_file(). To do this, simply create a PHP script with the following code: .

Apache 2.x on Microsoft Windows

This section contains instructions for installing PHP for Apache 2.x on Microsoft Windows systems.

Comment: Apache 2.2 support

Apache 2.2 users should note that the DLL file for Apache 2.2 is called php5apache2_2.dll , not php5apache2.dll , and is only available for PHP 5.2.0 and later.

You are strongly encouraged to read the » Apache Documentation to get a basic understanding of Apache 2.x Server. Also, before reading this help, take a look at the » Apache 2.x Windows Guidelines.

Apache 2.x is designed to run on server versions of Windows such as Windows NT 4.0, Windows 2000, Windows XP, or Windows 7. Although Apache 2.x can be used on Windows 9x, these platforms are not fully supported and some features will not work. Right. Correction of this situation is not planned.

Download the latest version of » Apache 2.x and the appropriate PHP version. Follow the Step by Step Installation Guide and come back to continue integrating PHP and Apache.

There are three ways to install PHP for Apache on Windows. You can run PHP as a handler, as CGI, or under FastCGI.

Comment: Remember that when specifying paths in the Apache configuration files under Windows, all backslashes, such as c:\directory\file.ext , must be changed to forward slashes: c:/directory/file.ext . Directory paths may also require a trailing slash.

Installing PHP as a handler under Apache

You need to add the following lines to your Apache httpd.conf configuration file to load the PHP module for Apache 2.x:

Example #19 PHP as an Apache 2.x handler

# LoadModule php5_module "c:/php/php5apache2.dll" AddHandler application/x-httpd-php .php # configure path to php.ini PHPIniDir "C:/php"

Comment: Don't forget to use the actual PHP directory path instead of C:/php/ in the example above. Take care to use either php5apache2.dll or php5apache2_2.dll in the LoadModule directive and make sure that the specified file is actually in the path you specified in the directive.

The above configuration will allow PHP to process any file that has a .php extension, even if there are other extensions. For example, a file named example.php.txt will be run by the PHP engine. To ensure that only files that are have the extension.php will be run, use the following configuration:

SetHandler application/x-httpd-php

Running PHP as CGI

You should refer to the » Apache CGI documentation for a more complete understanding of running CGI under Apache.

To run PHP as CGI, you need to place your php-cgi files in a directory designated as the CGI directory using the ScriptAlilas directive.

After that, you need to add the line #! in PHP files, pointing to the location of the PHP executable.

Example #20 PHP as CGI under Apache 2.x

#!C:/php/php.exe

Attention

By using a CGI installation, your server is exposed to several possible vulnerabilities. Please see the CGI Security section for information on how you can protect yourself from such attacks.

Running PHP under FastCGI

Running PHP under FastCGI has a number of advantages over running it as CGI. The installation is pretty simple:

NSAPI setup on Sun, iPlanet and Netscape servers

To install PHP with NSAPI, do the following:

  • Copy php4ts.dll to your systemroot (the directory where you installed Windows)
  • Make a file association from the command line. Type the following two lines:

    assoc .php=PHPScript ftype PHPScript=c:\php\php.exe %1 %*

  • In the Netscape Enterprise Administration Server create a new mime type (Category: type, Content-Type: magnus-internal/x-httpd-php, File Suffix: php).
  • Edit magnus.conf (for servers >= 6) or obj.conf (for servers< 6) and add the following: You should place the lines after mime types init.

    Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="c:/php/sapi/php4nsapi.dll" Init fn="php4_init" LateInit="yes" errorString="Failed to initialise PHP! "

    (PHP >= 4.3.3) php_ini parameter is optional but with it you can place your php.ini in your web server configuration directory.

    Configure the default object in obj.conf (for virtual server classes in their vserver.obj.conf): In the section, place this line necessarily after all "ObjectType" and before all "AddLog" lines:

    Service fn="php4_execute" type="magnus-internal/x-httpd-php"

    (PHP >= 4.3.3) As additional parameters you can add some special php.ini -values, for example you can set a docroot="/path/to/docroot" specific to the context php4_execute is called. For boolean ini-keys please use 0/1 as value, not "On","Off",... (this will not work correctly), e.g. zlib.output_compression=1 instead of zlib.output_compression="On"

    This is only needed if you want to configure a directory that only consists of PHP scripts (same like a cgi-bin directory):

    ObjectType fn="force-type" type="magnus-internal/x-httpd-php" Service fn=php4_execute

    After that you can configure a directory in the Administration server and assign it the style x-httpd-php. All files in it will get executed as PHP. This is nice to hide PHP usage by renaming files to .html .

  • Restart your web service and apply changes
  • Do it for each web server instance you want PHP to run
  • Comment:

    The stacksize that PHP uses depends on the configuration of the web server. If you get crashes with very large PHP scripts, it is recommended to raise it with the Admin Server (in the section "MAGNUS EDITOR").

    CGI environment and recommended modifications in php.ini

    Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE WS/iPlanet/Netscape is a multithreaded web server. Because of that all requests are running in the same process space (the space of the web server itself) and this space has only one environment. If you want to get CGI variables like PATH_INFO, HTTP_HOST etc. it is not the correct way to try this in the old PHP way with getenv() or a similar way (register globals to environment, $_ENV). You would only get the environment of the running web server without any valid CGI variables!

    Comment:

    Why are there (invalid) CGI variables in the environment?

    Answer: This is because you started the web server process from the admin server which runs the startup script of the web server, you wanted to start, as a CGI script (a CGI script inside of the admin server!). This is why the environment of the started web server has some CGI environment variables in it. You can test this by starting the web server not from the administration server. Use the command line as root user and start it manually - you will see there are no CGI-like environment variables.

    Simply change your scripts to get CGI variables in the correct way for PHP 4.x by using the superglobal $_SERVER . If you have older scripts which use $HTTP_HOST , etc., you should turn on register_globals in php.ini and change the variable order too (important: remove "E" from it, because you do not need the environment here):

    variables_order = "GPCS" register_globals = On

    Special use for error pages or self-made directory listings (PHP >= 4.3.3)

    You can use PHP to generate the error pages for "404 Not Found" or similar. Add the following line to the object in obj.conf for every error page you want to overwrite:

    Error fn="php4_execute" code=XXX script="/path/to/script.php"

    Where XXX is the HTTP error code. Please delete any other error directives which could interfere with yours. If you want to place a page for all errors that could exist, leave the code parameter out. Your script can get the HTTP status code with $_SERVER["ERROR_TYPE"] .

    Another possibility is to generate self-made directory listings. Just create a PHP script which displays a directory listing and replace the corresponding default Service line for type="magnus-internal/directory" in obj.conf with the following:

    Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/script.php"

    For both error and directory listing pages the original URI and translated URI are in the variables $_SERVER["PATH_INFO"] and $_SERVER["PATH_TRANSLATED"] .

    This list describes how to install the ISAPI module to work with the Sambar server on Windows.

      Find a file called mappings.ini (in the config folder) in the Sambar installation directory.

      Open mappings.ini and add the following line under :

      Example #22 ISAPI configuration for Sambar

      #for PHP 4 *.php = c:\php\php4isapi.dll #for PHP 5 *.php = c:\php\php5isapi.dll

      (If PHP is installed in c:\php .)

      Restart Sambar for the changes to take effect.

    Comment:

    If you want to use PHP to communicate with resources on other computers on your network, you need to change the account that is used by the Sambar server service. By default, this is LocalSystem and remote resources will not be available. The account can be edited using the "Services" option of the administrative utility from the Windows Control Panel.

    Xitami on Microsoft Windows

    This section contains notes and tricks specific to » Xitami on the Windows platform.

    This checklist describes how to install the PHP CGI library so that it works with Xitami on Windows.

    Comment: Important for CGI users

    Installing PHP extensions on Windows OS

    After installing PHP and a web server on Windows OS, you may need to install some extensions to add functionality. You can choose which extensions will be loaded when PHP starts up by modifying your php.ini file. You can also load extensions dynamically in your scripts using the function


    2023
    maccase.ru - Android. Brands. Iron. News