Debug PHP under self-built Domain Name

Source: Internet
Author: User
I was excited when I saw my comments. The New Year's pass was approaching, and my train ticket was not reached yet. I cried! We still need to live our lives. Blog is definitely coming. OK, question:
I recently wrote the PHP front-end. In case of cookies, the backend must be accessed by a domain name to store cookies. Therefore, it is best to change the local debugging to a domain name suffix using the following method:
1. Platform: PhP5 + Apache HTTP Server 2.0.55;
2. Find the installation directory of Apache and open the httpd. conf file (my address: D: \ apache \ apache2 \ conf \ httpd. conf );
3. confirm "# servername a. B .com: 80". This is the custom host address you want to change. Check the relevant information, it indicates that if you have your own network domain name, you can use your own network domain name. If you do not have one, you 'd better use the IP address of your host. I do not have my own domain name, But I have set my own IP address, so I add servername as my IP address, such:
Servername 192.169.100.1: 80. After specifying your own IP address, you must set the hosts file. (If you are interested in the role and related information of hosts, you can use Google or Baidu for more information on the network );
4. The hosts file is in the System Disk: c: \ windows \ system32 \ driver \ etc folder, add "192.169.100.1 yourdomain.com" under "#127.0.0.1 localhost"
5. OK, the above are done after restart Apache, so httpd. conf takes effect, now you can debug your own program through the http://yourdomain.com/... domain name.

The above briefly introduces how to use a domain name to debug your own program. After installing Apache, the default debugging location is under the \ htdocs directory (I did not go into details, see phpinfo. PHP files are stored here at the beginning and when PHP is started ). In Windows, you can directly set the website file pointing to IIS, and PHP has to change the file. If there is Apache, it is still the file httpd. find # DocumentRoot "D:/Apache/apache2/htdocs" and # <directory "D:/Apache/apache2/htdocs"> In the conf file and change the two to DocumentRoot "D: /Program Folder name "and <directory" D:/Program Folder name ">; you can debug the program in the directory you are pointing to again. Similarly, Apache must be restarted for all Apache changes. If an error occurs, an error is automatically reported during startup.

Supplement:
Debug multiple self-built domain names:
1. Add the corresponding IP domain name to the hosts file
(For example:
192.168.1.220 ad1.com
192.168.1.220 ad2.com
),
2. Find # namevirtualhost *: 80, remove "#", and change it to namevirtualhost 192.168.1.220.
3. Find the httpd. conf file of Apache # <virtualhost *: 80>... # </virtualhost>, copy the code, and modify it as follows:
<Virtualhost 192.168.1.220>
Servername ad1.com
DocumentRoot "D:/PHP/AD1"
</Virtualhost>
<Virtualhost 192.168.1.220>
Servername ad2.com
DocumentRoot "D:/PHP/ad2"
</Virtualhost>
4. Restart Apche and access the file under D:/PHP/AD1 through ad1.com. access the file under D:/PHP/ad2 through ad2.com.

Ol. I'm here today. php is not very familiar with it. I still need expert advice and improvement!

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.