Apache Basic Learning

Source: Internet
Author: User
Tags php language php programming php programming language phpmyadmin

What is 1,apache?

Currently the most mainstream three Web servers are Apache Nginx IIS

2, Environment construction

Linux system Installation XAMPP:

First download xampp for Linux, put in the/opt folder, programmers often put the program under this folder, easy to manage.

输入命令自动安装:sudo ./xampp-linux-x64-5.6.23-0-installer.run ,图形界面点击next,finish,安装完成。

Run and stop: commands are >sudo/opt/lampp/xampp start and >sudo/opt/lampp/xampp stop

Start graphical control Interface: Sudo/opt/lampp/./manager-linux-x64.run

Configuration file directory:

Apache Document root directory:/opt/lampp/htdocs/

Apache configuration file:/opt/lampp/etc/httpd.conf

MySQL configuration file:/opt/lampp/etc/my.cnf

PHP configuration file:/opt/lampp/etc/php.ini

PROFTPD configuration file:/opt/lampp/etc/proftpd.conf

phpMyAdmin configuration file:/opt/lampp/phpmyadmin/config.inc.php

Common XAMPP operation Commands:

Start/stop/restart APACHE:/OPT/LAMPP/LAMPP Start/stop/restart (including start/stop/restart MYSQL,PROFTPD)

Safety settings:/OPT/LAMPP/LAMPP security

Using PHP Version/view version:/opt/lampp/lampp PHP4 (5)/phpstatus

Only start and stop Apache:/opt/lampp/lampp Startapache/stopapache

Only start and stop Mysql:/opt/lampp/lampp Startmysql/stopmysql

Start and stop PROFTPD server only:/opt/lampp/lampp startftp/stopftp

Start and stop SSL support for Apache:/opt/lampp/lampp Startssl/stopssl

With system self-booting:

Ln–s/opt/lampp/lampp/etc/rc.d/rc3.d/s99lampp

Ln–s/opt/lampp/lampp/etc/rc.d/rc4.d/s99lampp

Ln–s/opt/lampp/lampp/etc/rc.d/rc5.d/s99lampp

To cancel a self-boot:

Ln–s/opt/lampp/lampp K01LAMPP

Uninstalling XAMPP:RM–RF/OPT/LAMPP

3,web Server Apache Architecture and principles

Workflow for Web servers:

1, the client sends the request: the client (through the browser) and the Web server establish a TCP connection, after the connection is established, to the Web server to make an access request, according to the HTTP protocol, the request contains the client's IP address, browser type and the requested URL, such as a series of information.

2, server resolution request: The Web server decodes the request according to the HTTP protocol, and the Web server software now knows that it should find the requested file and use a specific protocol to return the memory to the customer.

3. Read additional information: In addition to accessing the content

4, complete the requested action: if there is no error, the WWW server will perform the action requested by the request. The Web server searches its document tree for the requested file (/sample.html). If the file can be found and read normally, the Web server will first send the status code and some descriptive information, then the document is issued, and the Service software identification and the file's time attribute information is also included in the header domain. If the file is not found or cannot be read, the request is not satisfied, and the server returns a status code indicating that the request was incorrect.

5. Close the file and network connection and end the session: When the response is issued, the Web server shuts down the entire session, closes the requested file, closes the network port, and ends the network connection.

Apache Architecture Virtual Directory:

  In xampp, my default localhost directory is: C:/xampp/htdocs, if there is a test.php file in the directory, then access localhost/test.php in the browser can print out the contents of test.php: Hello I am Main web! (direct access to localhost will show the XAMPP guide page)

requirements, establish a virtual directory, location is c:/xampp/htdocs/daqing_test, access to the location of the link is: www.daqing.com, the directory has a test.php file, the browser will be displayed when access: Hello I am vitualhost!

To establish a virtual site:

1, open the Apache installation directory conf/httpd.conf file, you need to file the following two lines of comments removed, that is, remove the pound sign, save.

# LoadModule vhost_alias_module modules/mod_vhost_alias.so # Include conf/extra/httpd-vhosts.conf

2, open the Apache installation directory/conf/extra/httpd-vhosts.conf file, first find Namevirtualhost *:80 remove the note #, visually this is a special configuration of the virtual site files. Writes the custom site information to the end of the file in the following format:

<virtualhost *:80>    "/xampp/htdocs/daqing_test"    ServerName www. Daqing.  COM</VirtualHost>

Note that the/xampp/htdocs/daqing_test folder is built in advance.

3, in the system configuration file to change the hosts (C:\Windows\System32\drivers\etc\hosts), if this file only administrator can modify, then click: File-Open Windows power shell--open windows Power Shell as an administrator--command line Input >cmd-->notepad hosts--Modify: Add two lines

127.0.0.1 www.daqing.com    

Note that there are spaces or \ t in the middle of the two groups. Remember to save.

4, restart Apache, the case that the virtual site should be no problem, but my localhost at this time has no access! Cry, what then? Then find a way to configure

5, the first step of my operation is to the configuration file httpd.conf in this sentence is commented out

# ServerName localhost:80

But localhost still doesn't work,

6, then I went to httpd-vhosts.conf to redefine the localhost, that is, the idea of adding a virtual site to add the localhost

<virtualhost _default_:80>    ##ServerAdmin [email protected]    documentroot "c:/xampp/ Htdocs "    ServerName localhost    ##ServerAlias www.dummy-host2.localhost    # #ErrorLog "Logs/dummy-host2.localhost-error.log"    # #CustomLog "Logs/dummy-host2.localhost-access.log" combined</VirtualHost>

Tutorial said _default_ must add, well, although not very understanding, then I add it. Note with the well number I do not understand, add not add all can.

7, the final step, or to go to the system's Hosts file add this sentence:

127.0.0.1  localhost

At this time to visit the browser localhost/test.php or www.daqing.com/test.php can be successful! Finally succeeded. Woo Hoo

Reference:

Https://www.jianshu.com/p/98b0968f77be

78424441

50890197

How does 4.apache and MySQL work together?

In the PHP language directly at the site to write the interface, or need to first the PHP programming language.

Apache Basic Learning

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.