Php preparation and foundation

Source: Internet
Author: User
Php setup and basics 1. php development environment construction: 1. in linux, build linux + apache + mysql + php2. in windows, build apache + php + mysql + phpmyadmin. check the port: cmd -- & gt; netstat-an installation method: 1. php construction and foundation

1. php development environment setup:

1. build in linux

Linux + apache + mysql + php

2. build in window

Apache + php + mysql + phpmyadmin

View Port: cmd --> netstat-

Installation method:

1. kit installation:

Common kits: appserv, wmap, and phpStudy

Apache HTTP Server: apache web Server

MySQL Database: MySQL Database

PHP Hypertext Preprocessor: PHP core

PhpMyAdmin: graphical tool for MySQL database management --> next

?

Server Name: localhost

Administrator's Email Address: 53032104@qq.com --> Administrator mailbox

Apache HTTP Port: 8000 --> Port number --> next

?

Please enter Root password for MySQL Server --> root user password

Enter root password: root

Re-enter root password: root

MySQL Server Setting

Characher Sets and Collations: UTF-8 Unicode --> specifies database encoding, recommended UTF-8

?

2. Custom installation:

1. apache

Test: http: // localhost

2. php core package :( php official website: http://www.php.net) unzip it

Use Apache + PHP in windows and select VC6

Use IIS + PHP in windows and select VS9

?

Integration of apache and php:

1. add the following lines in the D: \ phpStudy \ Apache2 \ conf \ httpd. conf file:

LoadModule php5_module "D:/phpStudy/PHP5/php5apache2_4.dll" # php5apache2-4.dll under the php installation directory

PHPIniDir "D:/phpStudy/PHP5/" # php installation directory

AddType application/x-httpd-php. php. phtml # specifies that if the file is. php or. phtml, it will be processed by php.

?

2. under The php installation directory: rename the php. ini-development file to php. ini.

3. search for extension_dir = "./" in php. ini to open this line and specify the ext file path under the php installation directory.

Extension-dir = "D:/phpStudy/PHP5/ext"

?

Test:

Create the test. php file in the htdocs directory under the apache installation directory. the code is as follows:

Phpinfo ();

?>

Restart apache: http: // localhost/test. php

?

3. MySQL database :( MySQL official website: http://www.mysql.com)

Test:

1. write a php code to test whether the code is successful.

$ Conn = mysql_connect ("localhost", "root", "root ");

If ($ conn ){

Echo "connect to mysql database OK! ";

} Else {

Echo "connection to mysql database is not OK! ";

}

?>

2. install phpmyadmin to test availability (manage mysql)

Installation method: decompress the package to the htdocs folder and enter the index. php file under the Directory.

Access Method: http: // localhost: 8000/phpMyAdmin/index. php

?

2. http://www.comsenz.com

1. download the discus Forum code

2. decompress the package to the htdocs folder.

3. modify the config. inc. php file:

$ Dbhost = 'localhost'; // database server

$ Dbuser = 'root'; // database username

$ Dbpw = 'root'; // database password

$ Dbname = 'discuz'; // database name

$ Pconnect = 0; // database persistent connection 0 = disabled, 1 = enabled

?

$ Database = 'mysql'; // type of the forum database. do not modify it.

$ Dbcharset = 'utf8'; // MySQL character set. optional values: 'gbk', 'big5', 'utf8', and 'latin1'. the reserved values are set according to the Forum character set.

?

$ Charset = 'utf-8'; // Default Character set on the forum page. optional values: 'gbk', 'big5', and 'utf-8'

$ Headercharset = 0; // force the forum page to use the default character set to avoid garbled characters on some server space pages. 0 = close 1 = Enable

?

$ Forumfounders = 'admin'; // UID of the Forum founder, which can be separated by commas.

Note: set short_open_tag = on in php. ini.

4. access the install. php file under discus to install the database.

After installation:

UCenter URL: http: // localhost/upload/ucenter

UCenter founder password: admin

DISCUZ! URL: http: // localhost/upload/bbs

Administrator access URL: http: // localhost/upload/bbs/admincp. php

Administrator account: admin administrator password: admin

UCenter Home URL: http: // localhost/upload/home

Administrator access URL: http: // localhost/upload/home/admincp. php

Administrator account: admin administrator password: admin

?

?

Configure the website on an apache server:

1. to create a web site in the apache server, you need to enable the httpd-vhosts.conf file add:

Note: Make sure that the dns client service is in the starting status.

2. the configured host must be registered on the DNS server or windows system for external access.

?

Ideas:

1. identify different virtual hosts through ports

I. Prepare for binding a site

1. develop website D:/myblog

2. configure our httpd. conf file?

Enable httpd-vhosts.conf

Note DocumentRoot "D:/apache/htdocs"

3. find the file conf/extra/http-vhosts.conf file

Template:

DocumentRoot "D:/myblog"

DirectoryIndex index. php index.html

Options FollowSymLinks

AllowOverride None

Order allow, deny

Allow from all

4. add the object relationship between the ip address and the domain name to the hosts file.

Path: C: \ Windows \ System32 \ drivers \ etc \ hosts

Add: 127.0.0.1www.moluo.com

5. test: access http://www.moluo.com: 80

?

2. add a new domain name to bind the ip address

1. develop a new website

2. configure the httpd-vhosts.conf to add a new VM

DocumentRoot "D:/myblog2"

DirectoryIndex index. php index.html

Options FollowSymLinks

AllowOverride None

Order allow, deny

Allow from all

3. make apache listen to port 82 in the httpd. conf file

Listen 82

4. add the object relationship between the ip address and the domain name to the hosts file.

Path: C: \ Windows \ System32 \ drivers \ etc \ hosts

Add: 127.0.0.1www.fengpeng.com

5. test: access http://www.fengpeng.com: 82

?

2. use ServerName to differentiate virtual hosts

1. develop website D:/myblog

2. Add configuration in httpd-vhosts.conf files

DocumentRoot "D:/myblog"

ServerName www.moluo.com

DirectoryIndex index. php index.html

Options FollowSymLinks

AllowOverride None

Order allow, deny

Allow from all

DocumentRoot "D:/myblog2"

ServerName www.fengpeng.com

DirectoryIndex index. php index.html

Options FollowSymLinks

AllowOverride None

Order allow, deny

Allow from all

3. add the object relationship between the ip address and the domain name in the hosts file.

Path: C: \ Windows \ System32 \ drivers \ etc \ hosts

Add: 127.0.0.1www.moluo.com

4. test: access http://www.moluo.com

Http://www.fengpeng.com access

?

Web site description: a collection of multiple web resources, including php, html, js, and css

Basic php syntax:

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.