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,

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:

# The SERVERNAME directive sets the request scheme,hostnameand Port that# The server uses to identify ITSELF. This was used when creating# redirection URLs. In the context of the virtual hosts, the servername# specifies whathostnameMust appearinchThe request's Host:header to# match this virtual Host. For the default virtual host (thisfile) this# value is not decisive as it is used as a lastResort Host regardless.# however, You must set it forany 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's also possible to configure the LogLevel forparticular # modules, e.g. #LogLevelInfossl: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# to most configuration files from conf-available/,whichwas # enabled or disabled at a global level, it's possible to # include a line forOnly one particular virtual Host. For example the # following line enables the CGI configuration forThis host was only # after it had been globally disabled with"a2disconf". #Include conf-available/serve-cgi-bin.conf

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

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.