Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Apache configures multiple sites

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Preface: the main purpose of this project is to add an address to the Wechat client and an accessible app download page in the Wechat official account. It's very simple to say, but you can't build a new web server for such a small website.

To start the configuration now, you must first make sure that the LAMP environment has been set up on Linux and that a site can be accessed properly. Take my apache-ubuntu as an example, the default directory is: / var/www/html/

Let's make it clear where this new site should be placed. I would never recommend continuing to put it under the default directory. It should be under www. I did this.

Sudo mkdir / var/www/sunjob-app / / create a new site directory

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

Next, don't rush to configure the file, go to the domain name purchase site to modify resolution. Mine is Wanwang, add domain name resolution, as shown in the figure:

Note that the record type is changed to cname, which is either the An in the figure, and the record is the domain name prefix. The default is www. I changed it to app, so the final request address for access is: app.ygdiy.com (note that the prefix has changed).

Domain name resolution is over, save!

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

Cd / etc/apache2/sites-available/ enter the available site configuration directory

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

/ / while nginx.conf in nginx is configured with "include sites-enable/*", so all files are loaded, and apache only loads the .conf suffix

Vim. / app.ygdiy.conf

Modify the configuration file code as follows:

# 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 webmaster@localhost 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 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

Save and 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

When ok is configured, note that in the configuration file, DocumentRoot must be an existing and accessible directory, because the new site is stored here and is provided by apache for users to access.

In addition, servername, set to the new domain name just parsed, the one in cname, pay attention.

Restart apache

Sudo service apache2 restart

Finally, copy the files of the new website to / var/www/sunjob-app/, you can copy to your own named configuration directory, the browser can enter the new domain name of the site to access, and finally present my effect picture, good night

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report