The Apache+PHP+MySQL environment is built in super detail! ! !

Foreword: Recently, I am learning PHP language, and sorted out the part about environment construction. It is also more convenient to choose an integrated environment. It is more convenient to build an environment by yourself. It is suitable for beginners and will continue to be updated~~~

Determine the VC version of the server (be sure to read it to avoid subsequent mistakes)

Inconsistent versions will cause Apache to make errors when loading php packages, like this:

Inconsistent VC versions lead to errors

Steps to determine the server VC version:

1. Check the VC version of the server in the control panel.

 

 Install and configure Apache 

Note: Apache cannot parse php files, you need to install php

download

Get the Apache compressed package, choose the version that matches your own server to download, and unzip it. (Official website: https://www.apachehaus.com )

 Catalog description

 bin directory:

 configuration

1. Find Define SRVROOT in httpd.conf . Change to the Apache storage directory (here: C:\SERVER\Apache24)

 2. Install Apache's main service httpd.exe (it is a process that runs independently in the background, and Apache can only be started with it), which has been downloaded here, so it prompts that it has been downloaded.

 3. Find ApacheMonitor.exe in the installation directory and double-click to start it. An icon will appear in the lower right corner (C:\SERVER\Apache24\bin)

4. Test whether the configuration is successful: check the modules used (enter the bin directory, use the command: httpd.exe -M)

 Install and configure PHP

Download the PHP language

  1. Get the PHP installation file (official website)

Note here that you must download the second version, otherwise there may be no apache support package! ! !

 

2. Unzip and rename 

 Catalog description

Application of php.exe

php.exe ==> convert php code into HTML code, so that the browser can parse it.

  1. Write a php code, index.php, on the apache main site (C:\Apache\Apache24\htdocs).

 

2. Enter the directory where php.exe is located through the cmd controller (here is Apache/php-7.0.2)

Run the command through php.exe to specify the php script to be parsed: php.exe -f path where the php file is located, the PHP code can be executed, and hello world is output.

Configure Apache to load PHP modules

Note: After configuration, you must restart Apache to modify the PHP configuration file to take effect! ! !

principle:

  1. Apache assigns work to the PHP module, and if it is PHP code, it will be handed over to PHP for processing: the file suffix judges that the end of .php must be PHP code.
  2. Load the PHP configuration file into the Apache configuration file: take effect together.

step:

1. Specify the path where the PHP configuration file is located in Apache, and load the module provided by PHP (C:\SERVER\php-7.0.2\ php5apache2_2.dll).

2. Verify whether the loading is successful, enter the path of C:\SERVER\Apache25\bin and execute httpd.exe -M (here, pay attention to the uppercase M)

 3. Apache assigns work to the PHP module. If it is PHP code, it will be handed over to PHP. The file suffix judges that the end of .php must be PHP code.

4. Check whether the configuration is successful, and use httpd.exe -t to check whether the syntax is wrong. Just see OK. 

 

 5. Load the PHP configuration file into the Apache configuration file to take effect together. (3.1 PHPIniDir php.ini path)

6. 3.2 The php.ini file does not exist by default. It exists in development and production formats and needs to be formatted. (It is recommended to make a copy and modify the suffix name)

 7. Whether the test is successful: write a php file.

 Install and configure MySQL

Install the MySQL software

 1. Download the installation package on the official website, double-click to install

2. Agree to the agreement to proceed to the next step.

 3. Select the installation type, customize the installation, and select the installation directory (software installation directory and data installation directory).

For easy management:

Software installation directory: SERVER\mysql

Data installation directory: SERVER\mysql\data

 4. After the installation is complete, configure it.

 5. Select detailed configuration

6. Select the environment

 7. Select function (default)

 8. Concurrency mode selection (default)

9. Choose access mode

 

10. Select character set

11. Service installation, set MySQL to start automatically

 

 12. Enter the root (super administrator) user password. 

13. Waiting for configuration: all four are ticked to be considered successful.

Catalog description

 bin directory

 Software design structure: C/S and B/S:

C/S: Clint client/Server server, users need to install client products to access the server, and can only access one kind of software (currently their own).

B/S: Browser browser/Server server, users only need to install a browser to access all servers (B/S architecture services).

 access process

MySQL is a C/S architecture software that needs to access the server through the client (MySQL also provides access in other modes: through some plug-in extensions to act as the client).

Log in:

The MySQL client needs to search for a match when accessing the server; connection authentication connection: IP and port confirmation, if it is local, it can be omitted.

-h host address ---> -hlocalhost (can be IP)

-p port ---> -p3306

Authentication: Enter the server through username and password

-u username ---> -uroot cannot be omitted (except for anonymous users)

-p password ---> -proot

Configure PHP to load the MySQL extension

PHP itself does not have the ability to operate the MySQL database, and it needs to use the extended implementation of PHP to operate MySQL.

1. PHP loads the MySQL extension (apache needs to be restarted); in the php.ini file:

 2. Check whether the configuration is successful, and judge through the phpinfo interface.

 Only MySQLIND indicates that the configuration is not successful.

 2. All extensions of PHP are in the ext folder, you need to specify the path where the extension is located: extension_dir

(php.ini has been loaded by apache, so it needs to be restarted to take effect)

##Check whether the configuration is successful by calling phpinfo().

Set PHP's system time zone

It is realized through the timezone configuration in php.ini. (Need to restart apache)

###PRC means China time zone

 

Guess you like

Origin blog.csdn.net/weixin_54438700/article/details/125420577