Learn PHP from SCRATCH---DAY01

Source: Internet
Author: User
Tags learn php php basics php database phpinfo what php phpmyadmin

Just started to learn php, so the learning process and knowledge points to do some sorting! Later also good review! You want to learn to learn together!

Here are the introduction and installation methods, organized as Follows:

  PHP basics:

1. What is php?

PHP is an acronym for "php Hypertext preprocessor".

PHP is a widely used Open-source scripting language

PHP scripts are executed on the server

PHP has no cost and is free to download and use

2. What is a PHP file?

 PHP files can contain text, HTML, CSS, and PHP code

The PHP code executes on the server, and the result is returned in plain text to the browser

The suffix of the PHP file is ". php"

3. What PHP can do

PHP can generate dynamic page content

PHP can create, open, read, write, delete, and close files on the server

PHP can receive form data

PHP can send and retrieve cookies

PHP can add, delete, and modify data in a database

PHP can restrict access to certain pages in the site

PHP is capable of encrypting data

4. Why use PHP

PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)

PHP compatible with almost any server (Apache, IIS, etc.)

PHP supports multiple databases

PHP is free of charge. Please download from official PHP resources: www.php.net

PHP is easy to learn and runs efficiently on the server side

5. Installation of PHP environment

Rental of host or space, support Php+mysql (local tyrants)

Install the PHP environment on your computer: 1, integrated environment: appserver and Wamp

2. Install separately: apache, php, MySQL

The specific configuration is as Follows:

Installing Apache D:/lamp/apache2
Unzip PHP to D:/LAMP/PHP5
To modify a configuration file:
httpd.conf
127 rows (reference): Add LoadModule php5_module "d:/lamp/php5/php5apache2_2.dll"
Let Apache load the PHP module
383 rows (reference): Add AddType application/x-httpd-php. php
Let Apache support PHP format
384 rows (reference): Add Phpinidir "d:/lamp/php5"
Specify the path for PHP to use the configuration file
240 Rows (reference): Add index.php to let the browser use index.php by default

Set the php.ini configuration file name correctly

Write a PHP probe to test if PHP is working properly

Install MySQL specified installation directory and data directory are D:/lamp/mysql
To modify a PHP configuration File:
Ini
859 rows (reference): Add extension_dir = ' D:/lamp/php5/ext '
Specify the directory where the PHP extension resides
Open necessary extension, gd MySQL mysqli mb_string pdo_mysql (on Demand)

Restart Apache service, Get it done!

The above is approximate, installation success that ok, unsuccessful then uninstall the following more detailed method:

  

The service does not install properly, first determine if the software 32-bit and 64-bit match their own system
second, See if the computer has installed software corresponding to the running package,
For example, If you are downloading the VC9 version, you will need to install Microsoft Visual C + + redistributable First
Similarly VC11 version you need to install Microsoft Visual C + + Update 4 Redistributable Package (X86 & X64)
(P: if VC + + installation fails, The following solutions are available
1: Reload System (100% Can)
2: Baidu failure error code (80% Can)

1.apache Environment Building (version 2.4)
0) Download Apache
Http://jingyan.baidu.com/article/29697b912f6539ab20de3cf8.html

Download apache→http://httpd.apache.org/based on the above URL steps

1) Create the WebServer folder under the C drive (can be another disk)
2) unzip the downloaded Apache
3) Copy the extracted Apache24 entire file into the webserver
4) Administrator mode Open CMD[CD. / | Parent directory]
CMD is the default in the C drive under user
Get to the specified directory under the command ↓

CD C:/webserver/apace24/bin (note Be sure to go under the Bin)

(if you do not type C directly in cmd, E: reach the specified disk
Again cd-specified Directory)

Get to the specified directory input command
Httpd-k Install (perform apache2.4 Installation)

See if the installation was successful ↓ (P: Start-and run-->services.msc--> ok)
Right-click My Computer
Click Manage
Service and application services
See if There's apache2.4.

If you go on, you can't read a newspaper.
5) Open File
httpd.conf files in c:/webserver/apache24/conf/
Line 38th change to Define Srvroot "c:/webserver/apache24"
is to change the back path to its own Apache24 (P: Note the path slash)

6) Common Apache cmd command
Httpd-k Install Installation
Httpd-k Uninstall Uninstall
Httpd-k start
Httpd-k Stop shutdown
Httpd-k Restart Restart

7) restart Apache as soon as the Apache configuration file has been Changed.


3. PHP Installation (version 5.6)
0) www.php.net
Click to navigate Downloads

Windows downloads under each version (this is the window Version)

1) Download Complete Decompression
Extracted directly will have a lot of files, extracted into a folder
Rename folder to php5.6
Put the PHP5.6 under the Webserver.
2) establish a relationship with Apache
Apache configuration file httpd.conf

Ctrl + F Search LoadModule will find a lot of

At the bottom of the LoadModule line (around 180 rows), Add
LoadModule Php5_module C:/webserver/php5/php5apache2_4.dll

3) let Apache parse php
Apache configuration file httpd.conf
Ctrl + F Search AddType will find a lot of
At the bottom of the LoadModule line (430 rows or So)
Add AddType application/x-httpd-php. PHP

4) let index.php be the default open file
Ctrl + F Search DirectoryIndex

In about 280 rows
Original: DirectoryIndex index.html
Change to DirectoryIndex index.php index.html index.htm

Tell Apache to go to the default load page if there is a first load the first page does not load a second
The corresponding Web page will display the root file directly if it is not found.

5) Port (no problem, not change First)
Because Apache is listening to 80 port by default, If your computer IIS is in the boot state, and also use 80 port, Apache will not start normally, you need to stop iis, in addition, thunderbolt may also use 80 port, so also to turn off Thunder. To see if port 80 is occupied, enter it at the command line:
Netstat-a-n

Open conf/httpd.conf Search for "Listen 80" in the Apache directory
Modified to listen 8088
Save and then restart Apache

6) Load Php config file?
Locate the PHP5.6 file directory
Php.ini-development
Php.ini-production
At the moment casually copy and paste a
Appears php-copy. ini-production or Php-copy. ini-development
Change file name to PHP.ini

In the Apache configuration file, httpd.conf

At the bottom of the add
Phpinidir C:/webserver/php5/php.ini


If the configuration succeeds, it is displayed in the interface of the Phpinfo () function output

Create a 1.php file in the Htdocs folder in the Apache directory
Document Content <?php Phpinfo ();
Don't care what you mean then Save.
Browser input localhost/1.php
you'll See the following line, and the configuration is Successful.
Loaded Configuration Filec:\webserver\php5.6\php.ini


7) PHP Extension
To turn on curl, you need to copy the PHP5.6 folder
Libssh2.dll
Ssleay32.dll
Copy to C:/windows

The No. 734 line of php.ini modifies the absolute path
Ctrl Search Extension_dir
Extension_dir = "C:\WebServer\php5.6\ext"

Open extensions in the php.ini file such as PHP database link plug-ins such as Php's image processing plug-in such as the Pod link database plug-in

Ext to absolute path Extension_dir = "C:\WebServer\php5.6\ext" after line No. 734 of the php.ini file
On line No. 876 of the php.ini file
Can be customized to load Third-party libraries (plug-ins)
Like what:
Extension=php_gd2.dll image Processing plug-in removes the preceding semicolon; indicates that the plugin library is loaded
Extension=php_mysqli.dll database Linked plug-in removes the preceding semicolon; indicates that the plugin library is loaded
Extension=php_curl.dll
Turning on curl needs to open this
Note: the Apache server must be restarted after modifying the above configuration file

8) Steps to install Xdebug
Go to download Http://pecl.php.net/package/Xdebug click Back DLL blue Font go in
Download 2.4.1 Latest Version
(P: to the corresponding version of Php!) )
Copy the DLL files to the EXT directory
Configuring the php.ini File

Ctrl + F Search Add extension a lot of
At the bottom (910 rows or So)
Add Extension=php_xdebug.dll

Restarting the server

4.mysql installation (version 5.6.32)
0) Download
http://dev.mysql.com/downloads/mysql/
Choose the right version
mysql-installer-community-5.7.14.0 is the installation version

ZIP is an unpacked version

1) Installation
Create a MySQL folder in the webserver file
Copy (cut) the extracted MySQL (note version) file to MySQL

2) Configure the Environment
Point to the copied MySQL file and keep it in the bin Folder.

Copy Path C:\WebServer\mysql5.6\bin

System variables--environment variables----advanced system settings, Properties----right-click Computer
, find path Double-click or click Edit
At the end of the variable value is not added in english; (P: added if there is a Difference)
Add the path you just copied to the back
OK confirm ok OK

3) MySQL configuration file
Back to MySQL file to find My-default.ini
Paste Current Copy
My-default-copy. INI appears
Modify My-default-copy. INI file named My.ini

Open My.ini
Modify [mysqld] Below
# Basedir = ...
# DataDir = ...

Switch
Basedir = C:\WebServer\mysql
DataDir = C:\WebServer\mysql\data

4) install MySQL
Admin run cmd install MySQL
Mysqld-install
(P: because environment variables are already in place, so it is not necessary to do so in CD to Directory)
If the installation is successful, go to the computer service to view the corresponding MySQL service
Right-click to see if the path to the property is correct

5) Start the service
Computer Service found MySQL click Start
CMD in input net start MySQL

6) CMD log in to MySQL
CMD input mysql-uroot-p
(P: The first password is null for the direct knock Enter)
7) execute the MySQL statement (statement completion must be added;)
Log in to MySQL and enter show databases;
Show teammates ' database content

8) Change Password
Log in to MySQL and execute use MySQL to enter the library to manage MySQL database
Enter Update User set Password=password ("123456") where user= "root";
Change the root account password to 123456
Flush privileges; Property Current Database Permissions

If you use MySQL version 5.7 or more to change the password is another SQL statement
Update Mysql.user set Authentication_string=password (' 123456 ') where user= ' root '

9) Use phpMyAdmin
Unzip the phpMyAdmin and copy the files to the Htdocs file under Apache.

And then on the No. 886 line of the php.ini file,
Open the following plug-in before you can use
Extension=php_mbstring.dll

Apache htdocs Change folder name to DAV

Httpd.conf Ctrl + F search Htdocs

Search the Bottom.
DocumentRoot "${srvroot}/htdocs"
<directory "${srvroot}/htdocs" >

/after change to the following

DocumentRoot "${srvroot}/dav"
<directory "${srvroot}/dav" >

If still not successful, then buy a computer, let manufacturers help you install it! haha, a joke!

      

    

Learn PHP from SCRATCH---DAY01

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.