1. Environment matching: Go to Baidu and Google
2. Preparations before installation
Apache version at will
Free PHP version
Free MySQL version
Free phpMyAdmin version
Specific software, you can use integrated, apmserv.
2-1: Environment Test
Create a new file named phpinfo. php
Input content: <? PHP echo phpinfo ();?>
In the address bar, enter 127.0.0.1/phpinfo. php to display the specific PHP version and other details;
View phpadmin
Enter 127.0.0.1/phpMyAdmin in the address bar to enter the database interface. By default, the user's root password is blank by default.
Directory structure of the Apache service area
In Linux, Apache is located under the/usr/local/apache2 directory.
Display all directories under the installation directory of Apache
# Cd/usr/local/apache2/
# Ls // The displayed content is
Bin cgi-bin htdocs include logs Manual
Build error icons lib man modules
Enabling and disabling in Linux
/Usr/local/apache2/bin/apachectl stop // stop the apache service
/Usr/local/apache2/bin/apachectl start // start the apache service
/Usr/local/apache2/bin/apachectl restart // stop the apache service
Start and close Apache in Windows
Net stop apache2
Net start apache2
Start and Stop MySql in Windows
Net stop MySQL
Net start MySQL
Install PHP
1. Download a newer PHP software, find the downloaded directory, decompress it, and decompress it to c: \ lamp \ PhP5;
2. Load PHP into Apache as a module.
Loading Method: Write three lines in the Apache configuration file httpd. conf:
The first line loads the PHP module. The second line tells the Apache server that the suffix is. php or files with other suffixes are parsed using PHP.
The third line specifies the location of the PHP configuration file, and then copies the three lines to a location in C: \ lamp \ conf \ httpd. conf;
Loadmodule php5_module "C:/lamp/PhP5/php5apache2_2.dll" # load the PHP Module
Addtype application/X-httpd-PHP. php. phtml # What suffix file does the PHP module parse?
Phpinidir "C:/lamp/PhP5" # specify the location of the PHP configuration file
Step 3: Create a PHP configuration file. Directly decompress the PHP file C:/lamp/PhP5 under the php. ini-recommended directory and change it to PhP. ini.
Part 4: restart the Apache server.
Step 5: test whether PHP is successfully installed:
In the c: \ lamp \ apache2 \ htdocs folder on the Apache server storage page, create a file named
Test. php file. Content input <? PHP echo phpinfo ();?>
MySQL extension interface configuration in PHP
Step 1. After the above configuration, PhP5 has been installed successfully. However, PHP still cannot access the MySQL database server. Therefore, PHP must find two mysql-related DLL files installed with PHP.
Before installation, copy the libmysql. dll file under the PHP installation directory c: \ lamp \ PHP to the Windows installation directory. This directory is generally c: \ windows, and some Windows Service versions are c: \ WINNT.
You can also set the environment variables for Windows to decompress the PHP Directory C: \ lamp \ PhP5 and add the PATH environment variables.
Step 2: Enable the MySQL function in the PHP configuration file. Open c: \ lamp \ PhP5 \ PHP. ini in a text editor
Remove the previous.
Extension_dir = "C:/lamp/PhP5/EXT/" # specify the directory of the PHP extension interface. The directory delimiter is "/"
Extension = php_mysql.dll # enable MySQL extension Interface
Extension = php_mysqli.dll # enable MySQL extension Interface
Step 3: restart the Apache server.
Virtual Host
First, go to VI/etc/hosts
Mkdir/WWW # create a WWW directory at the same time
Mkdir/www/co1 # create the first VM storage directory
Use the configuration file to configure the VM
Include the Additional configuration file httpd-vhosts.conf in the main configuration file httpd. conf, find the following include command in httpd. conf, remove the previous,
VI/etc/httpd. conf
Set
# Virtual Hosts
# Include CONF/extra/httpd-vhosts.conf
Above # Remove
# Vi/etc/httpd/extra/httpd-vhosts.conf
Load the configuration.
<Virtualhost 192.168.1.29: 80> # configure a VM whose IP address is 192.168.1.29.
Serveradmin webmaster@dummy-host2.www.phpStudy.net # administrator mailbox
DocumentRoot "C:/program files/apache2/docs/dummy-host2.www.phpStudy.net"
# Set the root directory of the VM to store webpage files
Servername dummy-host2.www.phpStudy.net # Set this virtual machine to recognize its own host name
Errorlog "logs/dummy-host2.www.phpStudy.net-error.log" # Error Log
Customlog "logs/dummy-host2.www.phpStudy.net-access.log" common # access logs
<Directory "/www/co1"> # Set the access permission for the/www/co1 directory
Options indexs followsymlinks
AllowOverride none
Order allow, deny
Allow fromall
</Directory>
</Virtualhost>