Objective
PHP Basic tutorial, hope to help a few people want to learn PHP, but also their knowledge of the basics of the deepening of understanding, summary, the development of basic knowledge is very key, hope to learn PHP people can adhere to go on, but also hope that they can more and more NB.
What this section explains
The overall process
PHP is a development server-side language, and you want to access the server on your own computer, you can install an Apache server on your own computer. This allows you to access your computer's Web pages on your computer via a browser.
When we visit the website, General access is the end of the. html file, this file is browser-based parsing, but when the browser to access the. php suffix file, the browser can not parse, then you need to PHP code to PHP Development module parsing, and sometimes PHP code to operate the database, then you need PHP module and database associated.
The approximate flowchart is this:
The Apache version we're using here is 2.4.
The version used for PHP development is 5.6.25;
The database used to develop PHP is mostly MySQL database, a relational database, here we use the version is
5.6.27.
Installation recommendations create an empty folder that is easy to manage by installing three of modules together.
Installation of Apache
Download Apache installation software, Link:
http://www.php.cn/
After the download is complete, you can install it, but Apache installs it on the command line.
Install Apache, first we create a folder (for unified management), such as d:/mywamp, note that the folder does not have Chinese and white space.
After the download of the extracted Apache24 (name can be named) the entire copy of the directory to D:/mywamp, under
Go to the command-line console and run to the bin directory of the installation directory by clicking Run-and-command-line, as Administrator.
In the Bin directory, enter the Httpd-k install installation,
You may be having problems here
Download the software to install it to solve. Link:
http://www.php.cn/
When the above instructions indicate that the installation is successful, but there is a problem with the Apache configuration file, we need to modify the Apache configuration file apache24/conf/httpd.conf file
Here, after we install, we need to modify the Apache installation directory/conf/httpd.conf, in the file of about 38 lines, modified into a specific installation location.
After that, we enter (or in the bin directory) in the command line Httpd-k start to start the service. Access is only available to our browser when the service is turned on.
When the service is opened, call the browser, enter the localhost URL, when you see this screen
Instructions to install Apache successfully.
But sometimes we will see a message that our 80 port is occupied, then you can modify the Apache port to resolve, or the apache24/conf/httpd.conf directory
Modify it, restart the server on the line.
The commands that are commonly used when working with Apache are:
Httpd–h: View All commands
Httpd–k Install: Installing Apache
Httpd–k start: Start Apache
Httpd–k STOP: Stop Apache
Httpd–k Restart: restarting Apache
Httpd–k Uninstall: Uninstalling Apache
Configuration of environment variables:
When we start the server, reboot, shutdown and so on to enter the bin directory, it is too troublesome, there is a workaround, configure the environment variable, so that you can start in any directory.
Configuration steps:
Environment variables, such as advanced environment configuration, properties like computers, you will see the following interface
To create an Apache variable
Find the path variable click, after the value of the variable if there is no semicolon, add a semicolon and then fill in the%apache%;
Here, the environment variable is configured. Close the command-line window and reopen it.
Directory structure
Note: Where Htdocs is the file you want to access through the browser.
PHP Installation
Download the PHP version link:
http://www.php.cn/
Copy the extracted file (the filename can be named) to the file you created yourself, my name is d:/mywamp/php
PHP modules are not installed, this is as long as the Apache and PHP modules to integrate together on the line.
Steps:
Modified the apache24/conf/httpd.conf file
PHP module to the configuration file extension to find PHP directory php.ini-development file copy and renamed to PHP.ini
Open PHP Extensions for PHP and other functions, such as MySQL.
Change the path of an extension
To restart Apache, you can use the PHP module functionality. A test.php can be created under Apache's Htdocs directory, and File writes
Open the file in the browser. http://www.php.cn/when you see this picture, it means success.
MySQL Installation
Download the PHP version link:
http://www.php.cn/
Specific installation
Double-click Install software
Choosing a Custom Installation
Specify installed components and paths to your own file directory
Start the configuration
Choose how to configure
Set default concurrency number
Configure the port of MySQL, generally we do not modify the port number.
Select the default character set for our database-utf8
Specify the MySQL service name and whether to add to the environment variable
Root user Password specified
Start MySQL
When the front of the four is a check mark, the installation is successful.
12. Test whether MySQL database can be used properly, here we need to be careful to ensure that MySQL is running state
Modify the following code in the apache24/htdocs/test.php file above.
if Access returns "Connection succeeded" say OK
However, during the installation process, sometimes we are prompted for the missing. net40 file, download link:
http://www.php.cn/
How to enter the MySQL console after successful installation:
If it is easy to operate, you can set an environment path. The same as Apache.
PHP editing software
Write PHP code in development, you can use Notepad, but Notepad is too low, for beginners can use EditPlus or sublime
Sublime Download Address
EditPlus Download Address
Summarize
To this, our PHP development environment configuration is complete, the most important is the integration of PHP module and Apache module, note that the letter should not be written wrong. Colleague MySQL installation process note the meaning of each option. Do not choose the wrong.