Home  >  Article  >  Backend Development  >  How to set up a php environment in win7 local server

How to set up a php environment in win7 local server

藏色散人
藏色散人Original
2021-07-05 10:07:441980browse

How to build a PHP environment on win7 local server: first install and configure Apache; then download PHP and configure php.ini; and finally restart the Apache server.

How to set up a php environment in win7 local server

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

Windows7 builds Apache local server PHP environment

Version

  • Apache 2.4.25 Win64
  • PHP 7.1.2
    Because Apache is in the win environment There is no release version provided below, only the source code. If you don’t want to compile it yourself, you can choose this version: https://www.apachelounge.com/download/

Install and configure Apache

1. Download and extract to the installation directory d:\Apache24

2. Modify the configuration file d:\Apache24\conf

 ServerRoot "d:\Apache24"
 DocumentRoot "d:\Apache24\htdocs"
 Directory "d:\Apache24\htdocs"
 ServerName localhost:80

Modify:

<Directory "d:/Apache24/htdocs">    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

4. Enter localhost in the browser and display "It works!", success

Installation and configuration PHP

1. Download and extract to the installation directory d:\php

2. Modify the Apache configuration file d:\Apache24\conf, Add the following code

# php7 supportLoadModule php7_module d:/php/php7apache2_4.dllAddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phpsPHPIniDir "D:/php/"

3. Modify

<IfModule dir_module>
    DirectoryIndex index.html index.php</IfModule>

4. Configure php.ini

  • Back up php.ini-production in the php installation directory and rename it For php.ini
  • extension_dir = "ext" (set php extension path)
  • extension=php_mbstring.dll (php multi-byte string extension)
  • extension=php_mysql .dll (mysql library extension)
  • extension=php_mysqli.dll (mysqli library extension)
  • date.timezone = Asia/Shanghai (set default time zone)

5. Add index.php in the d:\Apache24\htdocs path and add:

<?phpphpinfo();?>

6. Save and close

Restart the Apache server and test

1. Open cmd as administrator, refer to this answer on Zhihu

2. Enter d:\Apache24\bin, enter

 httpd.exe -k install -n "Apache24"

3. Win R, enter services. msc, start the system service console, find Apache24, restart

4. Enter localhost/index.php in the browser, the following page will appear, done

How to set up a php environment in win7 local server

Recommended study: "PHP Video Tutorial"

The above is the detailed content of How to set up a php environment in win7 local server. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn