Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Windows10 builds a standard WAMP development environment-httpd2.4+php7.2+mariadb10.3

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Over the years, I have been working in the operation and maintenance Linux environment, and suddenly a friend taught himself PHP development, saying that he wanted to build a PHP development environment on his windows notebook. The previous development environment was also done by the developers themselves, so they never studied it. After being invited to accept the order, I found that I can't even play windows in the WAMP environment, which is sad! Technology knows no national boundaries, technology has no height. So the bitter water swallowed into the stomach. After flipping through google, I installed a brand-new windows10 system on my high-performance notebook using vmware, and then downloaded all the parts needed by AMP directly on the official website. after trying all the way, the WAMP architecture was finally successful, but there was a feeling that the windows environment was more difficult to play than the Linux environment. In order to let you see the process more clearly, it starts all over again, so there is the following.

Environmental display:

Operating system: windows 10 Professional Edition (official original)

Httpd version: httpd-2.4.35-o110i-x64-vc14

PHP version: php-7.2.11-Win32-VC15-x64

MariaDB version: mariadb-10.3.10-winx64

All software is downloaded directly from the official website.

After decompression, the storage path of the software is C:\ AMP, and the subordinates of the software name have no other redundant outer directories.

In order to facilitate the troubleshooting of errors in the future, it is recommended that you make a copy of the default configuration file before modifying it for future use.

The main configuration file for Httpd: C:\ AMP\ httpd\ conf\ httpd.conf

Httpd's matching file: C:\ AMP\ httpd\ conf\ extra

Default certificate directory for Httpd: C:\ AMP\ httpd\ conf\ ssl

Httpd's web page root directory: C:\ AMP\ httpd\ htdocs

Open the cmd window and try to start httpd

C:\ Users\ lucker > cd c:\ amp\ httpd\ bin

C:\ AMP\ httpd\ bin > httpd.exe

If you receive the following error, your system lacks a Visual C++ environment

Visual C++ Redistributable for Visual Studio 2015 official download address:

Https://www.microsoft.com/zh-cn/download/confirmation.aspx?id=48145&6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1

After downloading and installing successfully, you will receive the following error when you start httpd again:

C:\ AMP\ httpd\ bin > httpd.exe

Httpd.exe: Syntax error on line 40 of C:/AMP/httpd/conf/httpd.conf: ServerRoot must be a valid directory

Httpd.conf needs to be modified in the following areas:

Define SRVROOT "/ Apache24"

You need to change it to the root directory of your own httpd

Define SRVROOT "C:\ AMP\ httpd"

After modifying here, httpd can start normally.

By the way, httpd Hidden version Settings

ServerTokens Prod

Can be placed in Define SRVROOT "C:\ AMP\ httpd"

The next line is fine.

Before the version information is hidden, the http header displays the following information

After hiding the version information

Restart httpd again after modifying the httpd.conf configuration file

The cmd command line stops the foreground blocking httpd program and uses the CTROL+C key combination

At this time, it is normal to open a browser to access localhost.

At this point, we can add our own page to the root of the Httpd page for testing.

C:\ AMP\ httpd\ htdocs\ test.html

Test page

Congratulations, your httpd server is working properly!

Use the browser to access localhost/test.html again for testing

If you can see the above figure shows that your httpd is working as a static server, then you need to modify the relevant configuration of httpd and PHP so that httpd can integrate with the PHP application server.

Configure the interface on which httpd calls php

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

PHPIniDir "C:\ AMP\ php"

Configure httpd support for php document format

IfModule mime_module

AddType application/x-httpd-php .php

The main configuration file of PHP program is not available by default. You need to copy C:\ AMP\ php\ php.ini-production to php.ini and modify it accordingly.

Of course, if necessary, you can also copy C:\ AMP\ php\ php.ini-development to php.ini for later modification.

The difference between the two can be distinguished by the original file name. More debug parameters are enabled in the Development environment.

Change the time zone to Asia/Shanghai

Date.timezone = Asia/Shanghai

By the way, hide PHP-related information settings

Expose_php = On

Modify to

Expose_php = Off

Before the PHP version information is hidden, the http header information is as follows

If httpd hides the version information, you will only see the line X-Powered-By: PHP/7.2.11

After hiding PHP version information (no information about php applications will be displayed)

Test surface after adding httpd to integrate php

C:\ AMP\ httpd\ htdocs\ httpd-php.php

First use httpd.ext-t to check the configuration file format, then start it again after no problem

Use the browser to access localhost/httpd-php.php again for testing

If you can see the results in the above picture, it shows that there is no problem with your httpd integration php.

Next is the installation and configuration of mariadb.

Create the mysql configuration file C:\ AMP\ mariadb\ my.cnf

[mysqld]

Innodb_buffer_pool_size=128M

Datadir=C:\ amp\ mariadb\ data

Socket=C:\ amp\ mariadb\ socket\ mysql.sock

Symbolic-links=0

Sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

# Self config####

Bind-address=0.0.0.0

Character-set-server=utf8

Skip-name-resolve

Innodb_file_per_table

Default_storage_engine=innodb

Log-warnings=1

Slow_query_log=1

Long-query-time=2

Slow_query_log_file=C:\ amp\ mariadb\ log\ slow.log

[mysqld_safe]

Log-error=C:\ amp\ mariadb\ log\ error.log

Note: this profile needs to be in unix format

You need to create two directories by yourself.

Directory C:\ AMP\ mariadb\ socket where socket is stored

Store the log directory C:\ AMP\ mariadb\ log

The command to start the MariaDB server under Cmd

C:\ Users\ lucker > cd c:\ AMP\ mariadb\ bin

C:\ AMP\ mariadb\ bin > mysqld.exe-- basedir=C:\ AMP\ mariadb-- datadir=C:\ amp\ mariadb\ data-- log-error=C:\ amp\ mariadb\ log\ error.log-- socket=C:\ amp\ mariadb\ socket\ mysql.sock

The MariaDB server will be in the foreground blocking state after startup, and this cmd window cannot be closed.

Type a new cmd window and use the mysql client tool to connect to the test.

C:\ Users\ lucker > cd c:\ amp\ mariadb\ bin

C:\ AMP\ mariadb\ bin > mysql.exe-uroot

You can see the picture above shows that the installation of the MariaDB server is basically complete, and then write a test surface of php connection MariaDB for testing.

C:\ AMP\ httpd\ htdocs\ httpd-mariadb.php

Open the localhost/httpd-mariadb.php access test using a browser

The above error message is due to the fact that the mysqli module of php is not open. You need to modify the php.ini configuration file, specify the directory where the php extension components are located, and enable the required extension components.

Extension_dir = "C:\ AMP\ php\ ext"

Extension=mysqli

Note: since I am here only to show you how to connect PHP to MariaDB, generally speaking, you need to enable more than one module, and you need to open it selectively according to your actual situation.

Restart the httpd service again to refresh the access page, and the success page is shown below

So far, the WAMP environment has been built, but in order to be more convenient to use, you need to install httpd and mariadb servers as services and set them to boot, so that you do not have to use cumbersome cmd commands to serve in the future.

The Cmd command line installs httpd as a service

C:\ amp\ httpd\ bin > httpd.exe-k install-n httpd

Installing the 'httpd' service

The 'httpd' service is successfully installed.

Testing httpd.conf....

Errors reported here must be corrected before the service can be started.

C:\ amp\ httpd\ bin > httpd.exe-k start

C:\ amp\ httpd\ bin > httpd.exe-k stop

The 'Apache2.4' service is stopping.

The 'Apache2.4' service has stopped.

C:\ amp\ httpd\ bin >

The Cmd command line installs MariaDB as a service

C:\ amp\ mariadb\ bin > mysqld.exe-- install mysql-- defaults-file=c:\ amp\ mariadb\ my.cnf

Service successfully installed.

C:\ amp\ mariadb\ bin > net start mysql

The mysql service is starting.

The mysql service has started successfully.

C:\ amp\ mariadb\ bin > net stop mysql

The mysql service is stopping.

The mysql service stopped successfully.

C:\ amp\ mariadb\ bin >

Windows services are managed using the net command under the cmd command line

Format: net start | stop service_name (if the default name is complicated, it is recommended to specify it manually when installing the service)

C:\ amp\ httpd\ bin > net start httpd

The httpd service is starting.

The httpd service has started successfully.

C:\ amp\ httpd\ bin > net start mysql

The mysql service is starting.

The mysql service has started successfully.

C:\ amp\ httpd\ bin > net stop httpd

The httpd service is stopping.

The httpd service stopped successfully.

C:\ amp\ httpd\ bin > net stop mysql

The mysql service is stopping.

The mysql service stopped successfully.

C:\ amp\ httpd\ bin >

So far, we have finally completed the construction of the WAMP architecture under the windows environment. If you want to debug your own code, you can put the code in C:\ amp\ httpd\ htdocs and you can toss about your PHP program as you like.

Of course, for beginners, it is strongly recommended to use phpstudy or xampp to install the package. After all, this separate installation will have more holes and the configuration is more complex. If you want to maintain and upgrade easily in the future, or if there is a higher demand for use, this way of self-integration will certainly be useful.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report