How to build a php website on win (steps)

PHPz
Release: 2023-04-11 10:49:55
Original
1322 people have browsed it

In recent years, the PHP language has been widely used in all aspects of the Internet. From the underlying architecture to Web applications, PHP is used by many small and medium-sized enterprises. WIN is a popular and powerful operating system. The following will introduce you how to build a PHP website on WIN.

Step one: Install WEB server

We need to install the WEB server first to parse PHP files. Currently, the more popular WEB servers in WIN systems include: IIS, Apache, Nginx, etc. Here we take Apache as an example to introduce how to install Apache on WIN.

1. Download Apache

Download the Apache installation package that matches your WIN system version on the Apache official website (https://httpd.apache.org/) (by default, place it in C after the download is completed) root directory).

2. Install Apache

Double-click the downloaded Apache installation package to enter the installation wizard. Follow the instructions in the wizard to complete the installation of Apache.

3. Start Apache

Open the Apache installation directory (default is C:\Apache\bin), double-click the httpd.exe file to start the Apache service.

4. Access Apache

Open the browser, enter "localhost" or "127.0.0.1" in the address bar, and press Enter to access Apache.

Step 2: Install PHP

1. Download PHP

Download the file that suits your needs on the PHP official website (https://www.php.net/downloads.php) The PHP installation package of the WIN system version (by default, it is placed in the root directory of the C drive after the download is completed).

2. Configure PHP

In the PHP installation directory, copy the php.ini-development file and modify the file name to php.ini (leave the php.ini-development file unchanged , to facilitate subsequent configuration management). In the opened php.ini configuration file, press Ctrl F to open the search box, enter the keyword "extension_dir" in the search box, and after finding the field, modify it to the code below.

extension_dir = "C:\php\ext"

Change "C:\php\ext" to the ext folder address in your PHP installation directory.

3. Configure Apache

Open the httpd.conf configuration file in the conf folder in the Apache installation directory. In the file, find the following code:

LoadModule php7_module modules/mod_php7.so

Modify it to the following code:

LoadModule php7_module "C:\php\php7apache2_4.dll"

Below the code, Add a new line of code:

AddType application/x-httpd-php .php

After saving the configuration file and restarting the Apache service, you can successfully combine the PHP language with the web server Apache. Implement access analysis of PHP files.

Step 3: Verify PHP

In the Apache installation directory, open the htdocs folder. Create a new index.php file in this directory and copy the following code into the file.

echo "Hello World!";
?>

After saving the file, enter "http://localhost/index.php in the browser ", press Enter to access "Hello World!" on the page.

At this point, the steps to build a PHP website under WIN are completed. Of course, in the actual application process, the PHP environment needs to be further configured to make it more suitable for personal or corporate applications.

The above is the detailed content of How to build a php website on win (steps). For more information, please follow other related articles on the PHP Chinese website!

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