In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how apache implements the deployment of multiple websites, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
Configuration method
First the version of apache is 2.4.7, and then the system is Ubuntu 14.04.1 LTS. (because there seems to be a difference between the configuration file and the directory)
First go to the apache2 directory
What we are going to discuss is sites-available and sites-enabled, literally, the first one is available to the website, and the second one is available to the website, and then we also know that the files in sites-enabled are soft links to the files in sites-available, so we mainly change the site-available files. There are two files in site-available, but we only need 000-default.conf files and open cat files.
The code is 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 seothert it for any further virtual host explicitly. # ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot / var/www/ # 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 combined # 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
This is the URL configuration file, and all we need to modify is the commented out ServerName domain name and the DocumentRoot path. Remove the comments and leave the rest.
ServerName # here is the domain name address ServerAdmin webmaster@localhost DocumentRoot / var/www/ # here is the path ErrorLog ${APACHE_LOG_DIR} / error.log CustomLog ${APACHE_LOG_DIR} / access.log combined
You can add it directly below and restart apache. But the above priority is higher, access to your domain name will jump to the path you set, direct access to ip will go to the first set path, you can also choose to delete.
Another modification is to create a new file, xxx.conf, and then the content is the same
ServerName # here is the domain name address ServerAdmin webmaster@localhost DocumentRoot / var/www/ # here is the path ErrorLog ${APACHE_LOG_DIR} / error.log CustomLog ${APACHE_LOG_DIR} / access.log combined
After creating the soft link ln-s.. / sites-avaiable/xxx.conf.. / sites-enable/xxx.conf
This can also be achieved, but the priority is still 000-default.conf.
Okay, it's that simple.
Attachment: the method of configuring Apache2.4.7 reverse proxy
1. Set up httpd.conf
Open the httpd.conf settings file under the Apache24/conf folder, find the following lines and delete the previous comment'#'
LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_connect_modulemodules/mod_proxy_connect.soLoadModule proxy_ftp_modulemodules/mod_proxy_ftp.soLoadModule proxy_http_modulemodules/mod_proxy_http.so
(Ps: many people can annotate LoadModuleproxy_balancer_modulemodules/mod_proxy_balancer.so, but this is a function for load balancing. If you simply do reverse proxy, you don't need to use this, and if you cancel the comment here and do not set it accordingly, the apache service will not be enabled.)
And find Include conf/extra/httpd-vhosts.conf.
The comment'#'in front of this line is also deleted and this file is introduced
two。 Set up httpd-vhosts.conf
Open httpd-vhosts.conf.conf under the Apache24/conf/extra folder to find
# ServerName www.example.com:80DocumentRoot "${SRVROOT} / htdocs"
Add at the end
ProxyRequests OffProxyPass / * (address you want to access) address that http://*******( wants to proxy) ProxyPassReverse / * (address you want to access) address that http://*******( wants to proxy)
For example, I want to type localhost into the browser, but if the actual content is www.baidu.com, it can be set to ProxyPass / * * (the address you want to access) the address that http://*******( wants to proxy. The second ProxyPassReverse is used for domain name redirection. If the address you proxy redirects to another place, If you have the setting of ProxyPassReverse, you can jump to the past accordingly. If not, you may report an error.
If you want other computers to access the public network address of your own computer, you can access your own server. You can set the
Change Require all denied to Require all granted to allow all requests and access
And then you can use it.
Thank you for reading this article carefully. I hope the article "how to deploy multiple websites in apache" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.