Recently in the study of PHP, the following is to see PHP100 video tutorials, do the learning notes, stored here for future use.
Apache--php--db (MySQL)
First, Apache: basic work
• The user accesses the server's file through the browser, and it passes the file to the user, displaying the contents of the file in the user's browser.
• Plain text files, which can be shown directly to the user's browser via Apache.
• Program files, such as PHP, it can not be directly displayed in the browser, so you need Apache first invoke a PHP component, the PHP file to resolve the implementation, and then return to apache,apache the execution of the file, passed to the user browser display.
Key configuration:
Profile: conf/httpd.conf (you need to restart Apache each time you finish modifying this file)
1. Introducing PHP Components
Because when a user accesses a PHP file, Apache can invoke the PHP component to execute the PHP file. So when Apache is configured, it needs to be associated with the PHP component in the configuration file.
For example, I installed Apache in the F-disk program, so its component path is: LoadModule php5_module "F:/program files/php54/php5apache2_2.dll"
2. Set when to call the PHP component
Because not every time the user is a PHP file, so it is not necessary to let Apache every time to invoke the PHP parsing component. Because of the need to let Apache judge when to call Apache. That is, the suffix name, which is called when. php.
In this tag <ifmodule mime_module></ifmodule> add the following sentence:
AddType application/x-httpd-php .php
3.PHP Placement, Path
PHPIniDir "f:\Program Files\php54"
The above is the most critical, essential configuration.
Other configuration:
In the PHP directory, there are two profiles php.ini-development and php.ini-productor to convert one of the names to PHP. The INI is OK.
1. Directory Permissions:
"<directory" F:/program Files/apache2.2/htdocs ">" With this setting, you can control access to the server directory.
Note that the directory level in this area is greater than or equal to "DocumentRoot" F:/program Files/apache2.2/htdocs ""
For example : <directory "F:/program files/apache2.2/htdocs" > can only access the site directory under the Htdocs directory.
<directory "F:/program files/apache2.2> can access all site directories under the Apache2.2 directory.
2. Default access to the first page of the file name configuration:
"<ifmodule dir_module>directoryindex index.html index.htm index.php</ifmodule>"
Through this setting, you can control the site's default home page;
A host header similar to the IIS server configuration;
3. Log
Logs/access.log This file records the user's access, access to the IP page, and other information;
4. Error notification Information configuration
# Some Examples:
#ErrorDocument "The server made a boo boo."
#ErrorDocument 404/missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http:// freeskyc-b2d592.bavo/subscription_info.html
#
Second, multi-site configuration
Principle: When a user accesses a server with the same IP address through a domain, Apache on the server will have different domain names pointing to different or identical folder directories on the server. This process is also called virtual host;
1. Directory Permissions:
"<directory" F:/program Files/apache2.2/htdocs ">" With this setting, you can control access to the server directory.
Note that the directory level in this area is greater than or equal to "DocumentRoot" F:/program Files/apache2.2/htdocs ""
For example: <directory "F:/program Files/apache2.2/htdocs" > can only access the site directory under the Htdocs directory.
<directory "F:/program files/apache2.2> can access all site directories under the Apache2.2 directory
2. Load multi-site components:
The Apach configuration file is near the bottom of the
#Include conf/extra/httpd-vhosts.conf
By removing this #, you can load this component;
3. Configure this multi-site component
In the Apach installation directory.
Conf\extra\httpd-vhosts.conf
Locate this file for configuration
4. Configuration instructions:
Namevirtualhost *:8080 The port number here, you must and Apach config file in one to
ServerAdmin: Administrator's e-mail address, for different sites can be set up a different e-mail address, if not set, the default will find Apach configuration file inside the administrator email address;
DocumentRoot is a virtual directory to point to
ServerName: Domain name or IP that needs to be bound
Serveralias bind multiple domain names
ErrorLog error Log store path, create different error logs for different sites
Customlog log File
The above only needs to be configured well
For example:
<virtualhost *:8080>
documentroot "F:/program files/www/bcom"
ServerName 127.0.0.3:8080
</ Virtualhost>
Two on it, copy the above code, change the directory and binding domain name, you can have more than one site
It is to be noted that
* The directory permissions within the Apach should correspond to the directory of this multi-site
That
<Directory "F:/Program Files/www">
* Configure a lot of sites, Apach will not find the previous default site
This sentence also does not work: DocumentRoot "F:/program Files/apach/htdocs"
* And in the Address column if you enter a Apach, bound domain name, will automatically point to the first site directory in the multi-site collocation
The above is the entire content of this article, I hope to help you, but also hope that a lot of support cloud Habitat community!