CTO-technology article 2 (Environment configuration)

Source: Internet
Author: User

Apach2.2 + mysql5.0 + PhP5:

 

I have been searching for a suitable space recently. I am interested in space, network, and virtual hosts because I can access the Internet and enable the education network quickly.
Today, I have relocated my website to my brother's server. However, after being uploaded to the server, it is found that this is a Java site and PHP is not installed. In the past, I used XAMPP as a container to build PHP, which severely weakened the hands-on capability of inversion. Today I learned how to configure it:
1. Install apache2.2, Directory D:/program files/Apache Software Foundation/apache2.2.apache. The installation directory may contain spaces.
2. install PHP. Directly install it in D:/PHP. PHP installation directory cannot contain spaces.
3. Install MySQL. Directly install D:/mysql5.0.
Test whether Apache is installed successfully. Http: // localhost/it works is displayed on the screen !.
Modify the conf/HTTD. conf file of Apache.
1. add your own loadmodule to the "loadmodule group. The Code is as follows:
Loadmodule php5_module "D:/PHP/php5apache2_2.dll" -- note that php5apache2 is not used by other websites. Because we are Apache 2.2.
Addtype application/X-httpd-PHP. php
Note that # is added before many loadmodules, indicating that Apache does not load these modules by default. Remove # directly if loading is required #. PHP php5apache2_2.dll needs to be written manually. It is not written in Apache CONF/HTTD. conff. (When downloading PHP, you must pay attention to the download thread security, that is, the TS -- thread safe that many people say. Otherwise, php5apache2_2.dll will not be used. Someone asked this question online .)
2. Change PHP. ini-Dist to PhP. ini, change extension_dir to "D:/PHP/EXT", and load the dynamic libraries. Load some databases and remove the previous ones;
; Extension = php_dba.dll
; Extension = php_dbase.dll
; Extension = php_filepro.dll
; Extension = php_gd2.dll
; Extension = php_imap.dll
; Extension = php_mysql.dll
3. Copy PHP. ini to C:/windows, and put libmysql. DLL to C:/window/system32.
4. Test it! Write test. php content as <? PHP echo phpinfo ();?> Put it in Apache, htdocs. PHP information is found. Test the connection to the database. In this case, install phpadmin and put it in htdocs. If it runs successfully, it will be fine.
Then we opened my website and found that if index. php was not input, it would display the folder directory. For example, www.nanguache.com does not know whether to enable www.nanguache.com/index.php and open the directory. We thought about a lot of methods, such as writing an index.html file, and then jump to the. index file. Later we realized that in Apache:
Add index. php to directoryindex to automatically find index. php...
5. How does Apache create a virtual host?
6. I have not installed Zend. I will continue to write it later.
7. MySQL experience:-uroot will allow you to enter the password. The InnoDB and isym engines of MySQL are used in different ways.

 

 

Principles of virtual hosts (reproduced)

I. Principles of WWW Server Virtual Host
A www server VM is a WWW server that uses a physical machine to act as multiple host names. For example, by a machine at the same time to provide http://www.company1.com, http://www.company2.com and other WWW services, and browse these WWW site users do not feel this way with different machines to provide different services.
The advantage of using WWW Virtual Hosts is that some small-scale websites share the same physical machine with other websites, which can reduce system operation costs and reduce management difficulty. In addition, individual users can also use this virtual hosting method to create www servers with their own independent domain names. Currently, many domestic companies provide this free service.

2. There are two ways to use the www vm:

1.1 IP address-based VM Mode
In this way, different host names are resolved to different IP addresses, and these IP addresses are set on the machines that provide the VM service. The server determines the Virtual Host Service requested by the user based on the target IP address of the user request, so as to further process the service.
Disadvantages: the IP address-based virtual host method requires that multiple IP addresses be set up on the machine that provides the virtual host service, which wastes IP addresses and limits the number of virtual hosts that a machine can accommodate. Therefore, this method is rarely used. However, this is the only way to use HTTP 1.0 to support virtual hosts.
1.2 host name-based VM
Because the IP address-based VM has the following disadvantages, the support for host name-based VM is added to HTTP 1.1. Specifically, when a client sends a request to the WWW server, the host name that the client wants to access is also passed to the WWW server through the "host:" statement in the request header. For example, www.company1.com, www.company2.com all correspond to the same IP address (that is, the same machine to provide services for the two virtual domain names), when the customer program to access http://www.company1.com/index.html, the request header contains the following content:
GET/index.html HTTP/1.1
HOST: www.company1.com
.....
After receiving the request, the WWW server program can check the "host:" statement to determine the service of the virtual host requested by the client program, and then further process the request.
Advantage: as long as one IP address is set on the machine that provides the VM service, theoretically it can provide services to countless virtual domain names, which consumes less resources and facilitates management. This method is basically used to provide the VM service.
Disadvantage: it cannot be used in earlier versions of HTTP 1.0. In fact, the current browser basically supports the host name-based virtual host mode.

 

Virtual Host Principle

A vm is used to run several websites, provide Web, FTP, mail, and other services on a server. This topic describes Web Service virtual host settings.

There are two ways to implement a VM: IP-based and host name-based.

IP-based method:

First, bind multiple IP addresses to the server, configure the Web server, and bind multiple websites to different IP addresses. Access different IP addresses to view different websites.

Host Name-based method:

First, set the records of multiple domain names so that they are resolved to the same IP address, that is, the same server. Then, configure the Web server on the server, add multiple websites, and set a host name for each website. The HTTP request contains the host name information. When the Web server receives an access request, it can access different websites based on different host names.

The basic IP address method is commonly used in LAN, and the host name-based method is commonly used in Internet. The following describes how to set the host name-based virtual host based on two common Web servers, IIS and Apache.

To set up a VM, follow these steps:

1. add multiple domain names in the dynamic domain name client software. The purpose of this step is to resolve these domain names to the same server. (Note: You can add multiple domain names to the public network client and the truehost client of the Intranet Professional Edition. The intranet Standard Edition does not support multiple domain names ).

2. Add a domain name to your web server (such as IIS and Apache) to configure the VM.

IIS virtual host settings

1. Open "Control Panel"-"Administrative Tools"-"Internet Service Manager"-"Default web site ".

2. Right-click the "Default web site" and choose "New"> "Site ". Click "Next ".

3. Enter the site description, for example, site 1 ". Click "Next ".

4. Enter the domain name on the "host header of the site", for example, "abc.dns0755.net ". Click "Next ".

5. Specify the root directory path of the site in the path. Click "Next ".

6. select an appropriate permission from the permission list. Click "Next.

If you configure a virtual host with a top-level domain name, for example, enter "abc.com" in the Host Header in step 1 above, and you also want to use "www.abc.com" for access. The procedure is as follows:

1. Right-click site 1 in Internet Service Manager and select Properties ".

2. Click "advanced" on the right of the IP address ".

3. Click "add", enter the port number (usually 80), and then enter the host header name "www.abc.com ".

If you want to add multiple sites, repeat the preceding steps.

Apache Virtual Host settings

1. Open the Apache configuration file "httpd. conf", find "# namevirtualhost *", and remove "#" before this line.

2. Add a virtual host site under the "namevirtualhost *" line. Example:

Virtualhost *
Serveradmin webmaster@comexe.cn
DocumentRoot/export/home/dns0755
Servername dns0755.net
Serveralias * .dns0755.net
Errorlog "|/usr/local/sbin/rotatelogs/var/log/HTTP/dns0755-err.log 604800"
Customlog "|/usr/local/sbin/rotatelogs/var/log/HTTP/dns0755.log 604800" combined
/Virtualhost

Note:

Serveradmin webmaster@comexe.cn
Site administrator email address

DocumentRoot/home/dns0755
Site root directory

Servername dns0755.net
Site Host Name

Serveralias * .dns0755.net
Site alias. "*" indicates any character

Errorlog "|/usr/local/sbin/rotatelogs/var/log/HTTP/dns0755-err.log 604800"
Error Log Control

Customlog "|/usr/local/sbin/rotatelogs/var/log/HTTP/dns0755.log 604800" combined
Access log

/Usr/local/sbin/rotatelogs is a log management program
/Var/log/HTTP/dns0755.log is the log file name
The unit of 604800 is seconds, which indicates that a log file is generated every 7 days.

If you want to add multiple sites, repeat Step 1.

Http://blog.lanyue.com/view/412/354937.htm

Http://blog.chinaunix.net/u1/46962/showart_371638.html

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.