当前位置:网站首页>Ultra detailed Apache and PHP installation tutorial windows (2022.1)

Ultra detailed Apache and PHP installation tutorial windows (2022.1)

2022-06-23 03:09:00 Mew

One 、 preface

The author is at 2022 year 1 Monthly installation Apache and PHP, But because the tutorial found is an old version , There are many problems in the installation process , The author solved the problem one by one , Now I will give you a new tutorial by referring to the previous tutorial and personal experience . edition PHP_8.1.2 and Apache 2.4.52 x64.

Reference resources :

PHP Installation configuration (Windows and Linux)- One is enough - cloud + Community - Tencent cloud (tencent.com)

Apache Installation configuration (Windows and Linux)- If you have a hand _ Wu Zelong's blog -CSDN Blog

apache(OS 10013) Made an attempt to access the socket in a way that the access permission is not allowed ..._yangshuolll The column -CSDN Blog

Two 、 Download from the official website

1. Apache download

Download from the official website :Apache Haus Downloads

2. PHP download

Official website :PHP For Windows: Binaries and sources Releases

Pay attention to pay attention to , If you follow my tutorial , Be sure to install the second version , Otherwise, there will be problems in the follow-up .

3、 ... and 、 decompression

It can be changed to a shorter name , For example, I put php-8.1.2-Win32-vs16-x64 Changed to php8.

Four 、 To configure

1. Apache To configure

(1) open httpd.conf, The first 39 That's ok , The original “Apache” Change it to Apache Address .

Remember this file , The following configuration will be used many times .

(2) Test whether the configuration file is legal ( Skippable )

Enter... In the blue position cmd, Open the command line window .

httpd -t# Test whether the configuration file is legal 
If appear Syntax OK, It means success .

If you fail , Go back to the previous step , Check whether there is an error when changing the address , For example, I accidentally deleted the quotation marks when copying and pasting , Or forget to save .

(3) install Apache service

httpd -k install -n Apache2.4 #-n Followed by the custom access name 

Or open it at the place of the previous step cmd

(4) Start the service

① Command start

httpd -k start  # start-up 
httpd -k stop   # stop it 

If the startup is successful, go to the next step

If startup fails

Failure situation

First explain why you failed , The default port of the configuration file is 80, And in your computer 80 The port is occupied .

At this time, you need to change a port , such as 81, The operation is as follows :

open httpd.conf,CTRL+F lookup , hold 80 Switch to 81, There will be three .

hold 80 Switch to 81

② Open it manually

(5) test

Routine test methods : Access in browser http://localhost( No port change is successful , Just skip the following .)

But it failed , Why? ?

Because the port is changed , Here, enter in the browser localhost:81.

And it worked

thus Apache The configuration is successful

2. PHP To configure

(1) open httpd.conf

Copy the following code , green Where you need to change , yes php8 Folder address .

# load PHP
LoadModule php_module 'D:\Program Files (x86)\php8\php8apache2_4.dll'

# take PHP The configuration file is loaded into the Apache In profile , Take effect together 
PHPIniDir 'D:\Program Files (x86)\php8'

# To configure Apache Assign work to PHP modular , hold PHP Code to PHP Handle 
# namely .php Suffix file 
AddType application/x-httpd-php .php

remind : If you install PHP The wrong version was selected when , I can't find it php8apache2_4.dll Of .

(2)php.ini file

Of the above configuration php.ini The file does not exist by default , In order to development and production Format exists , Format processing is required .

Open folder php8

① It's already there ,② it is desirable that .

operation : Copy ① Is a copy , Rename the copy to php.ini, Be careful , Suffix changed .

(3) Test configuration ( Skippable )

Open the service restart Apache

Enter... In the blue position cmd, Open the command line window .

Input instruction

httpd -M

Success is like this

(4) test

stay Apache24\htdocs Create a new Notepad , Name it test.php, The contents are as follows .

<?php
	//test
	echo 'hello xx world';
?>

Type in the browser

localhost/test.php
# No port change 
localhost:81/test.php
# If you change the port 

PHP Configuration is successful

End of the flower **,°*:.*( ̄▽ ̄)/$:*.°**

原网站

版权声明
本文为[Mew]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/01/202201221847125096.html