How to set up a php environment in win7 local server

藏色散人
Release: 2023-03-11 08:16:02
Original
2093 people have browsed it

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
Copy after login

Modify:

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

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/"
Copy after login

3. Modify

<IfModule dir_module>
    DirectoryIndex index.html index.php</IfModule>
Copy after login

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();?>
Copy after login

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"
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template