Build a server environment
Install Apache,mysql and PHP, and configure the implementation of the three-link.
Installing Apache
1. Download the Apache installation file: official website http://www.apache.org
2. Double-click the installation to enter the installation Preparation screen
3. Click "Next" to enter the Protocol interface
4. Select the Receiving protocol and click "Next" to enter the Reading protocol interface.
5. Click "Next" to enter the server information configuration interface
6. After configuring the server information, click "Next" to enter the settings check screen
7. Select the custom installation, click "Next" to enter the installation configuration screen
A) Installation path configuration: Create a server folder under the D drive, create an Apache directory below, install Apache under Apache directory
Path Note options
1. The folder name does not allow spaces
2. Chinese path and special characters are not allowed
8. After modifying the path, click "Next" to go to the ready to install the interface
9. Click "Install"
10. Verifying the installation effect
A) View Apache run icon
Color description
Green triangle: Represents normal operation
Red Squares: Indicates that there is an error in the configuration, the port is occupied, it is not running.
b) authenticated by HTTP access: Enter localhost in the browser
11. Understanding the directory structure of Apache
Bin directory
Httpd.exe use
1) The system automatically loads at boot time, providing the Apache HTTP request and Response service.
2) Httpd.exe Use command, can be used for configuration detection, Syntax: httpd/httpd.exe– command options
Under CMD, use the httpd command
M command: Show all modules
L Command: Displays the currently compiled module
T command: Check the current Apache configuration error
Troubleshooting configuration issues: the option to have a domain name in the config file is commented out and needs to be turned on/server/apache/conf/httpd.conf
After modification
After you modify a server configuration item, you must restart the server to take effect.
Conf Directory: Configuration file directory
How Apache Works
Apache's work is in fact independent division of Labor and cooperation: Apache internal functions are implemented through the module to achieve, Apache itself does the thing is to different tasks to different modules to achieve.
Install PHP
1. Download PHP. Official website Http://www.php.net
2. Unzip
3. PHP does not require a true sense of installation, decompression can be used. Php.exe
Move the PHP folder to d:/server/and change the name to PHP5
Proof that PHP is ready to work
Using the php.exe–f specified PHP file path in the console
Apache Bound PHP
1. Apache Loads the PHP module when it is loaded.
Add the PHP module below the Apache configuration file httpd.conf
Syntax: LoadModule php5_module PHP Path (PHP provided to Apache interface)
2. Restart Apache, verify
3. Apache assigns tasks to PHP modules: PHP files (Files with. php as file suffixes) are assigned to the PHP module for processing.
Syntax: AddType application/x-httpd-php. php
Restart the server to take effect
4. Apache Loads the PHP configuration file.
PHP configuration file: Under the PHP module
Rename the configuration file for the development environment (first replication is recommended): PHP.ini
Loading php.ini in Apache configuration file
Syntax: path to Phpinidir php.ini
Verify
PHP provides a function to detect the environment of PHP: Phpinfo ()
Install MySQL
1. Download the MySQL installation file. Official website: http://www.mysql.com
2. Double click to install, enter the Welcome screen
3. Click "Next" to enter the Protocol interface
4. Agree to the agreement, click "Next" to enter the Setup installation type interface
5. Click Custom Install "Custom" to go to the Custom installation directory interface
Modify the installation path for MySQL
Modifying the MySQL data storage path
6. After setting the path (install directory and data storage directory), click "Next", go to the ready to install the interface
7. Click "Install" for installation, multiple next clicks appear in the middle
8. By default check the configuration options, click "Finish" to complete the installation, go to the configuration Welcome screen
9. Click "Next" to enter the configuration type selection screen
10. Select the detailed configuration, click "Next", enter the server work Type selection interface
11. Select the development machine, click "Next", enter the database using the configuration
12. Select the multi-function database and click "Next" to enter the table space settings
13. Using the default data table space settings, click "Next" to enter the concurrency option settings
14. Select manual settings and set the maximum concurrency to 15, click "Next" to enter the network settings
15. Tick the firewall exception and click "Next" to enter the encoding settings
16. Select Manual Selection, select the UTF8 character set, click "Next", enter
17. Tick Add environment variable, click "Next" to enter the security Account Settings screen
18. Enter the root user password and click "Next" to go to the straight line preparation interface
19. Click "Execute" to configure the line directly
20. Until all four options are hooked, the installation is successful, click "Finish" to complete
21. Analyzing the MySQL installation directory
Bin directory
22. Test whether the installation is successful
Accessing the database: Access via client Mysql.exe
Syntax: running MySQL client mysql.exe in cmd add parameter
-h:host host address, can be domain name or IP, can be omitted, default is localhost
-p:port port number, can be omitted, default is 3306
-u:username User Name
-p:password User Password
PHP load MySQL
PHP can not operate the database itself, PHP through the PHP operation provided by MySQL extension to achieve.
1. Modify the PHP configuration file to add PHP and MySQL extensions.
2. Loading php's MySQL extension file
Extension_dir
3. Restart Apache
4. Verification
Modify Time Zone
The default time zone used by PHP is the European Time Zone (UTC), which is inconsistent with the current system (network) time zone.
TimeZone
Effect
Build a virtual Host
There are two types of virtual hosts: IP-based virtual hosts and domain-based virtual hosts
Domain-based virtual hosting: multiple domain names correspond to one IP address (one computer)
A server often has more than n items (sites: folders), users need to access content under different folders. Apache Solution: A domain name corresponds to a folder
Domain-based virtual host: The user through a different domain name (actually access to a server), the Apache through a different domain name to find a different folder.
Configuring a virtual Host
1. Namevirtualhost represents a virtual host based on a domain name
Scenario 1: Manually increase the virtual host under httpd.conf under Apache configuration file
Namevirtualhost *:80 Open the virtual host and listen for all IP access 80 ports
<virtualhost *:80>
Build a virtual Host
ServerName Virtual Host Name
DocumentRoot Folder path
</VirtualHost>
Scenario 2: Using Apache-provided virtual host files
First to open the virtual host: Load the virtual host file
New Virtual Host: conf/extra/http_vhosts.conf
Add domain Name resolution: Hosts file
Effect
Increase access Restrictions
<directory path >
#权限控制顺序
Order Deny,allow
#先执行拒绝权限, after performing the Allow permission
#权限验证, allow all
Allow from all
#默认访问页
DirectoryIndex File Order index.php index.html
#文件列表: The list of all files is displayed if no default home page exists
Options Indexes FollowSymLinks
</Directory>
Effect
After the domain-based virtual host is used, the default localhost is overwritten, and if you want to use localhost to access the correct path, you need to build a virtual host for localhost
Back up Legacy data
PHP Files: Direct copy is placed in the root directory of the Web site can be
MySQL Backup: Find the Data directory, copy the Ibdata1 file and the database corresponding folder, and then put in the new installed MySQL data directory, overwriting the corresponding ibdata1 file
Homework:
1. Remove all amp, reinstall (MySQL to uninstall clean: After uninstalling, to delete the contents of the corresponding folder)
2. Put your previous projects into a new environment, configure separate virtual hosts for access
1.2 Setting up the server environment and backing up the original data brief