Apache Configures multiple sites

Source: Internet
Author: User
Tags domain purchase

Preface: This project is mainly to add an address to the client, add an accessible app download page in the public number, it is easy to say, but you can not create a Web server for such a small site!

Now start the configuration, you must first confirm that the lamp environment has been built on Linux, and there is a site can be normally accessed, in my apache-ubuntu, for example, the default directory is:/var/www/html/

To clarify the new site where to put, I would not recommend to continue to the default directory next directory, should be placed under the WWW, I do,

sudo mkdir/var/www/sunjob-app//Create a new site Directory

Yes, the directory for my new little website is right under this sunjob-app.

Next do not worry to configure the file, go to the Domain purchase site modification Resolution, my is million network, add domain name resolution,

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/1096794/201701/ 1096794-20170121130509890-1602839165.png "style=" border:0px; "/>

Note that the record type is modified to a CNAME, not a in the diagram, the record is the prefix of the domain name, the default is WWW, I modified into the app, then the final visit when the request address is: app.ygdiy.com (note the prefix changed)

End of domain name resolution, save!

Go back to Ubuntu server and start configuring the new site for this domain name resolution:

cd/etc/apache2/sites-available///Enter the available site configuration directory

Vim new and modify a configuration file, I named the new site directly, but note that the suffix is. conf, because in apache.conf, the default is the include "*.conf" file

and Nginx in nginx.conf configuration "include sites-enable/*" so all files will be loaded, Apache only load. conf suffix

Vim./app.ygdiy.conf

Modify the configuration file code as follows:

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

# the servername directive sets the request scheme, hostname and  port that# the server uses to identify itself. this is  used when creating# redirection URLs. In the context of  Virtual hosts, the servername# specifies what hostname must appear  in the request ' S host: header to# match this virtual host.  For the default virtual host  (This file)  this# value is  not decisive as it is used as a last resort host  Regardless.# however, you must set it for any further virtual  host explicitly.    ServerName app.ygdiy.com     serveradmin [email protected]    documentroot /var/www/sunjob-app    # available  loglevels: trace8, ..., trace1, debug, info, notice, warn,     # error, crit, alert, emerg.    # It is  also possible to configure the loglevel for particular     # modules, e.g.     #LogLevel  info ssl:warn     errorlog ${apache_log_dir}/error.log    customlog ${apache_log_dir}/ access.log combinedoptions indexes followsymlinks multiviews          allowoverride all         order  allow,deny         allow from all# For  Most configuration files&nbsP;from conf-available/, which are    # enabled or disabled  at a global level, it is possible to    #  include a line for only one particular virtual host. for  example the    # following line enables the cgi  Configuration for this host only    # after it has  been globally disabled with  "a2disconf" .     #Include   Conf-available/serve-cgi-bin.conf

650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" border:0px; "/>

Save exit to bash and link the site to enable:

sudo ln-s/etc/apache2/sites-available/app.ygdiy.conf/etc/apache2/sites-enabled/app.ygdiy.conf

Configuration OK, note that in the configuration file, DocumentRoot must be present and accessible to the directory, because the new site is stored here, the Apache is provided to the user access

In addition, ServerName, set to just parse the new domain name, the CNAME of that, note yo

Restart Apache

sudo service apache2 restart

Finally copy the new website files to/var/www/sunjob-app/, you copy to your own name configuration directory can be accessed by the browser input site new domain name, finally offered me, goodnight

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/1096794/201701/ 1096794-20170121130544906-1390432529.png "style=" border:0px; "/>

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/1096794/201701/ 1096794-20170121130552359-1240730462.png "style=" border:0px; "/>


Apache Configures multiple sites

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.