Configuring an Apache method instance that supports PHP (Win7)

Source: Internet
Author: User

This article is mainly to share with you configuration support PHP (WIN7) of the Apache Method example, Wamp and lamp is the PHP engineers often use the environment, we today to configure Apache, so that it can work with PHP.

1. Go to Apache's conf directory and open Apache configuration file httpd.conf. (It is recommended to back up first before modifying)
Modify the directory where the Apache software resides:

    ServerRoot "D:/wamp/apache24"

To modify the host name and port number:

    ServerName localhost:80

Modify the WWW directory (which is the directory where the project resides, which the browser can access):

    DocumentRoot "d:/wamp/www"    <directory "D:/wamp/www" >

Modify the default index to support PHP:

<ifmodule dir_module>    directoryindex index.php index.html index.htm </IfModule>

To turn on the rewrite function:

    LoadModule Rewrite_module modules/mod_rewrite.so

Custom 404 page (optional):

    ErrorDocument 404/missing.html

Load the PHP module and note the absolute path:

php5.6

    LoadModule php5_module d:/wamp/php/php-5.6.22-win32-vc11-x86/php5apache2_4.dll     <ifmodule php5_module>         phpinidir "d:/wamp/php/php-5.6.22-win32-vc11-x86/"         AddType application/x-httpd-php. php        addtype application/x-httpd-php-source. Phps    </IfModule>

If it is PHP7, change it accordingly:

Php7

LoadModule php7_module d:/wamp/php/php-7.0.13-win32-vc14-x64/php7apache2_4.dll<ifmodule php7_module>     Phpinidir "d:/wamp/php/php-7.0.13-win32-vc14-x64/"     addtype application/x-httpd-php. php    AddType Application/x-httpd-php-source .phps</ifmodule>

Note: If the PHP5.4 version, PHP directory only php5apache2_2.dll, need and Apache2.2 collocation.
So, install php5.6 Be sure to verify that there are php5apache2_4.dll files in the PHP installation package.

You can turn on the virtual host configuration file:

    #Virtual hosts    Include conf/extra/httpd-vhosts.conf

The default httpd-vhosts.conf file is written for reference, but if you enable the file, configure it correctly, or the Apache service cannot be enabled.

Virtual Host Example:

<virtualhost *:80>    documentroot "d:/www/app/laravel-5-blog/public/"    ServerName laravel-5-blog.fhy.com    directoryindex index.php    <directory "d:/www/app/laravel-5-blog/" >        allowoverride all    </directory >    errorlog "logs/laravel-5-blog.fhy.com-error.log"    customlog "logs /laravel-5-blog.fhy.com-access.log "common</virtualhost>

where DocumentRoot set the path of the project, ServerName set the host name, DirectoryIndex set the portal file, directory allowoverride settings open. htaccess function.

You can turn on the host alias configuration file:

Include conf/extra/httpd-alias.conf

If you install the PHP x64 bit version, Apache also needs to be x64 bit version. Then, the PHP directory, and the libeay32.dll ssleay32.dll libssh2.dll four files under the Ext directory php_curl.dll are copied and placed in the System32 directory. Otherwise, the curl extension cannot be used.

After successfully starting Apache, write phpinfo.php in www directory:

<?php    Echo phpinfo ();? >

The browser address bar input localhost/phpinfo.php, display PHP related information to indicate success.

Wamp and lamp are often used by PHP engineers, and today we configure Apache so that it works with PHP.

1. Go to Apache's conf directory and open Apache configuration file httpd.conf. (It is recommended to back up first before modifying)
Modify the directory where the Apache software resides:

    ServerRoot "D:/wamp/apache24"

To modify the host name and port number:

    ServerName localhost:80

Modify the WWW directory (which is the directory where the project resides, which the browser can access):

    DocumentRoot "d:/wamp/www"    <directory "D:/wamp/www" >

Modify the default index to support PHP:

<ifmodule dir_module>    directoryindex index.php index.html index.htm </IfModule>

To turn on the rewrite function:

    LoadModule Rewrite_module modules/mod_rewrite.so

Custom 404 page (optional):

    ErrorDocument 404/missing.html

Load the PHP module and note the absolute path:

php5.6

    LoadModule php5_module d:/wamp/php/php-5.6.22-win32-vc11-x86/php5apache2_4.dll     <ifmodule php5_module>         phpinidir "d:/wamp/php/php-5.6.22-win32-vc11-x86/"         AddType application/x-httpd-php. php        addtype application/x-httpd-php-source. Phps    </IfModule>

If it is PHP7, change it accordingly:

Php7

LoadModule php7_module d:/wamp/php/php-7.0.13-win32-vc14-x64/php7apache2_4.dll<ifmodule php7_module>     Phpinidir "d:/wamp/php/php-7.0.13-win32-vc14-x64/"     addtype application/x-httpd-php. php    AddType Application/x-httpd-php-source .phps</ifmodule>

Note: If the PHP5.4 version, PHP directory only php5apache2_2.dll, need and Apache2.2 collocation.
So, install php5.6 Be sure to verify that there are php5apache2_4.dll files in the PHP installation package.

You can turn on the virtual host configuration file:

    #Virtual hosts    Include conf/extra/httpd-vhosts.conf

The default httpd-vhosts.conf file is written for reference, but if you enable the file, configure it correctly, or the Apache service cannot be enabled.

Virtual Host Example:

<virtualhost *:80>    documentroot "d:/www/app/laravel-5-blog/public/"    ServerName laravel-5-blog.fhy.com    directoryindex index.php    <directory "d:/www/app/laravel-5-blog/" >        allowoverride all    </directory >    errorlog "logs/laravel-5-blog.fhy.com-error.log"    customlog "logs /laravel-5-blog.fhy.com-access.log "common</virtualhost>

where DocumentRoot set the path of the project, ServerName set the host name, DirectoryIndex set the portal file, directory allowoverride settings open. htaccess function.

You can turn on the host alias configuration file:

Include conf/extra/httpd-alias.conf

If you install the PHP x64 bit version, Apache also needs to be x64 bit version. Then, the PHP directory, and the libeay32.dll ssleay32.dll libssh2.dll four files under the Ext directory php_curl.dll are copied and placed in the System32 directory. Otherwise, the curl extension cannot be used.

After successfully starting Apache, write phpinfo.php in www directory:

<?php    Echo phpinfo ();? >

The browser address bar input localhost/phpinfo.php, display PHP related information to indicate success.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.