[PHP Series Notes] 01 PHP Environment Configuration

PHP environment configuration

Install Apache server

Download Apache:

Download the Apache server from the Apache official website -> http://httpd.apache.org/download.cgi

Modify the configuration /conf/httpd.conf:

  1. Change ServerRootto the root directory of the Apache server
  2. Modify DocumentRootto the root directory of website files
  3. Modify Directoryto the root directory of website files

By ./httpd.exe -tcan test the configuration file is legitimate

Install Apache:

Apache root directory of the next bindirectory, run with administrator privileges shell, run httpd.exethe installation:> ./httpd.exe -k install

Start Apache:

Run httpd.exe:> ./httpd.exe -k start

Open virtual host (reverse proxy):

  1. The configuration file of the virtual host is located /conf/extra/httpd-vhosts.conf, but this function is turned off by default and needs to /conf/httpd.confbe turned on in:

    Cancel the comment of the line change

    Include conf/extra/httpd-vhosts.conf

  2. Edit /conf/extra/httpd-vhosts.conf, configure virtual host

    The configuration items of a virtual host are roughly like this:

    # 指定 ip:port
    <VirtualHost *:80>
    	# 网站目录
    	DocumentRoot "A:/Others/Apache/server"
    
    	# 主机名
    	ServerName "www.myFirstServer.com"
    
    	# 权限管理
    	<Directory "A:/Others/Apache/server">
    		Require all granted
    		# Require local 允许本地访问
    		# Require all granted 全部放通
    		# Require all Denied 全部拒绝
    		# Require ip *.*.*.* 允许指定 ip 访问
    		# Require not ip *.*.*.* 禁止指定 ip 访问
    		# Require host localhost 允许使用 localhost 访问
    
    		# 默认首页
    		
    		DirectoryIndex index.php index.html
    	</Directory>
    </VirtualHost>
    

    ServerNameUsed for request distribution for different access domain names.

Install PHP

Download PHP:

Official website -> https://www.php.net/

Add configuration file:

Create a file in the root directory and copy the content php.iniof the configuration file template of the development environment php.ini-developmentinto php.iniit.

Configure Apache's PHP interpreter:

  1. Find the root directory on Apache PHP dynamic link library php7apache2_4.dll, open the Apache configuration file /conf/httpd.conf, load module PHP7: LoadModule php7_module ${filename}.
  2. Hand some files to the PHP7 interpreter for processing: /conf/httpd.confadd a line in it AddType application/x-httpd-php .php, followed by other types of files, with spaces as separators.
  3. Load the PHP7 configuration file to Apache: /conf/httpd.confAdd a line in it PHPIniDir ${filename}.

Configure PHP timezone

php.iniAdd a sentence to the root directory of PHP7 to timezone = PRCindicate that the time zone is located in China.

View PHP configuration information

.phpCall the phpinfofunction in the file :

<?php
    phpinfo();
?>

Then parse through the PHP interpreter, or start the server, and call the php7 module through the server to parse, you can see the PHP configuration information.

Install MySQL database

Download MySql:

Official website -> https://dev.mysql.com/downloads/mysql/

Configure MySQL:

Create a configuration file in the root directory of MySQLmysql.ini

[mysqld]

port = 3306

basedir = A:/Others/MySql

datadir = A:/Others/MySql/data

max_connections = 200

character-set-server = utf8

default-storage-engine = INNODB

sql_mode = NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES

[mysql]

character-set = utf8

Install MySQL:

  1. In shellrunning mysqld.exe, the command mysqld.exe -installto install

  2. initializationmysqld.exe --initialize-insecure --user=mysql

  3. Start servicenet start mysql

  4. mysqladmin.exeCreate users through programsmysqladmin -u ${username} -p ${oldPwd} password ${password}

    E.gmysqladmin.exe -u root -p password root

  5. Now you can mysql.exeinteract with the database through the program mysql.exe -u${username} -h${host} -P{port} -p${password}, -hand the -Pdefault is localhostand 3306can be directly defaulted.

Guess you like

Origin blog.csdn.net/qq_16181837/article/details/109259616