How to piggyback on the PHP environment on Windows and write and run the first PHP code

**

How to piggyback on the PHP environment on Windows and write and run the first PHP code

**

The editor just started to get in touch with PHP, the environment has been configured for a long time, and there are many problems, so I decided to write it down, to clear some obstacles for Xiaobai to enter the pit of PHP, to enter the pit as soon as possible, and become a great god as soon as possible. offer


1. Install the web server

Installing a web server on windows is relatively simple: open the "Control Panel", select "Programs", select "Enable or Disable Windows Features", find "World Wide Web Services" (as shown below), and select it. It's finished!

write picture description here

Second, install the PHP server components

For our beginners, it is recommended to use the integrated server component, which already includes services such as PHP, Apache, Mysql, etc., which saves developers from spending time in the tedious process of configuring the environment.
WampServer
Window system can use WampServer, download address: http://www.wampserver.com/ , supports 32-bit and 64-bit systems, choose the version according to your own system.
WampServer installation is also simple, you just need to keep clicking "Next" to complete the installation.

How to see if the installation was successful?

You can enter: http://localhost in the browser. If the following content appears, the installation is successful, or the icon is green.
write picture description here
Here I will talk about the pits I encountered in the installation of WarmpServe, which took a lot of time to toss.
After installing wampserver, open it, if the icon on the status bar is not green, but red or orange. Then it means that there is a service that has not been opened, and the icon I encountered is orange. When you move the mouse over the icon you can see a prompt that a service is not open. At this point, it means that our environment is not ready. The solution is as follows ( the original text of the solution comes from this )

1. Modify the Apache service listening port

Left-click the wampserver icon in the status bar and select Apache > httpd.conf. . Use the shortcut Ctrl + F to search for 80. Modify the two 80s found to the port numbers you want to use (the ones that are not occupied, such as 8082).
Modify the Apache listening port Modify the server port

2. Modify the wampmanager.tpl file in the wamp installation directory to specify the port number

Open wampmanager.tpl with Notepad or WordPad, search for 80 with the shortcut Ctrl + F, and set
Type: item; Caption: “ w t e s t P O r t 80 ; A c t i O n : r u n ; F i l e N a m e : {c_phpExe}"; Parameters: "-c . 80 in testPort.php 80
is the port number selected before (eg: 8082)
Modify the port number in wampmanager.tpl

3. Shut down and restart

Save the previously modified file (if you can't save it, for example, you need administrator privileges, you can use the administrator to run Notepad or WordPad), exit and restart wampserver, you can see that the icon turns green. Port conflict problem solving

4. Open with browser

Since the default port number of the browser is port 80, we need to manually specify the port number when opening localhost. Since the blogger uses port 8082, enter: localhost:8082 in the address bar. If the page is opened normally, the configuration is successful, otherwise there may be other problems.

This icon is green! ! !


3. Write the first PHP code

Well, the environment is installed, we are about to start writing our first php code

It is not recommended to use a cumbersome compiler here, just use an editor. After all, PHP can be visualized on the browser. reduce computer load

Here the editor recommends the powerful nodepad++
download address: http://notepad-plus-plus.org/download/

At this point, we are basically half-successful, and now we just need to write our code (the editor also thought so at the time, and then found that he couldn't)

The following is the first code written by the editor in nodepad++ (if you are not familiar with nodepad++, you can Baidu by yourself. When saving the file here, save the file suffix as .php)
write picture description here

Then after writing the code. I was suddenly at a loss. The code is written, and then, where to go to see the results? ? ? ?

At this time, I quickly went to a certain degree to check. It turns out that we have to put the .php file we wrote into the www folder in the wamp directory we installed earlier (this is the one below)
write picture description here

Finally, we enter http://localhost:+ in the browser (the port number you modified before, if it has not been modified, do not need this step) + file name) (for example: http://localhost:8082/demo.php ) , just click Enter! !
write picture description here

**

All done! ! !

I hope this article can help Xiaobai enter the pit smoothly! ! !

**

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325817269&siteId=291194637