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
:
- Change
ServerRoot
to the root directory of the Apache server - Modify
DocumentRoot
to the root directory of website files - Modify
Directory
to the root directory of website files
By
./httpd.exe -t
can test the configuration file is legitimate
Install Apache:
Apache root directory of the next bin
directory, run with administrator privileges shell
, run httpd.exe
the installation:> ./httpd.exe -k install
Start Apache:
Run httpd.exe
:> ./httpd.exe -k start
Open virtual host (reverse proxy):
-
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.conf
be turned on in:Cancel the comment of the line change
Include conf/extra/httpd-vhosts.conf
-
Edit
/conf/extra/httpd-vhosts.conf
, configure virtual hostThe 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>
ServerName
Used 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.ini
of the configuration file template of the development environment php.ini-development
into php.ini
it.
Configure Apache's PHP interpreter:
- 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}
. - Hand some files to the PHP7 interpreter for processing:
/conf/httpd.conf
add a line in itAddType application/x-httpd-php .php
, followed by other types of files, with spaces as separators. - Load the PHP7 configuration file to Apache:
/conf/httpd.conf
Add a line in itPHPIniDir ${filename}
.
Configure PHP timezone
php.ini
Add a sentence to the root directory of PHP7 to timezone = PRC
indicate that the time zone is located in China.
View PHP configuration information
.php
Call the phpinfo
function 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:
-
In
shell
runningmysqld.exe
, the commandmysqld.exe -install
to install -
initialization
mysqld.exe --initialize-insecure --user=mysql
-
Start service
net start mysql
-
mysqladmin.exe
Create users through programsmysqladmin -u ${username} -p ${oldPwd} password ${password}
E.g
mysqladmin.exe -u root -p password root
-
Now you can
mysql.exe
interact with the database through the programmysql.exe -u${username} -h${host} -P{port} -p${password}
,-h
and the-P
default islocalhost
and3306
can be directly defaulted.