Keywordsrun php on apache how to run php on apache how to run php on windows
There are two ways to use php on the apache
server: run PHP in CGI mode or Apache module mode. These two methods are obtained based on different configuration schemes for Apache.
Configuring the Apache
server is mainly done by modifying its configuration file httpd.conf. This file is generally located in the conf folder of the Apache directory.
The Apache configuration file used in this article is D:/usr/local/apache2/conf/httpd.conf. The following description refers to the modification of this document. The PHP version mentioned in this article is PHP5.
1. Run PHP in CGI mode For PHP5, you need to add the following code to the httpd.conf file (# is the comment mark of httpd.conf):
code show as below:
# Set the alias of the PHP directory
ScriptAlias /php/ "D:/usr/local/php"
# Associate specific extensions to parse PHP files
AddType application/x-httpd-php .php
# Set up a program that uses PHP5 to execute CGI scripts
Action application/x-httpd-php "/php/php-cgi.exe"
2. Run PHP in Apache mode For PHP5, you need to configure the following:
code show as below:
# Load PHP5 module
LoadModule php5_module "D:/usr/local/php/php5apache2.dll"
AddType application/x-httpd-php .php
# Configure the path of the php.ini file
PHPIniDir "D:/usr/loca/php"
After setting up, you need to start the Apache
server, and then perform a test to verify whether PHP can work properly. For this, a new test program "phpinfo.php" needs to be created in the Web virtual directory. By default, the virtual directory is located in the htdocs folder under the Apache directory, such as "D:/usr/local/apache2/htdocs".
Here is the content of the phpinfo.php file:
The code is as follows: <?php
phpinfo();
?>
Enter in the browser: http://localhost/phpinfo.php, if you can see the interface of php version 5, the installation is successful.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.