Ubuntu Mate +apache2 configures some of the relevant WWW services

Source: Internet
Author: User

1. Install apache2 under Ubuntucommand for sudo apt-get install apache2,Apache2 is a modular software that relies on the apache2.conf file to link the functions of each module .after the installation is complete, the apache2.conf configuration file under Etc/apache2 is visible (there is no httpd.conf file in the Apache2 directory), You can open the file and sites-available the root directory of the 000-default.conf file under Modify Settings Web site.
set the home directory of the Web site in apache2.conf
set the home directory of the Web site in 000-default.conf
as I moved the index.html in the WWW directory, the following situation occurred .
of course, if you change the directory of the above two files to my index.html directory, or put index.html back to the WWW directory, the following situation will occur (remember to restart the Apache Service (command:/etc/init.d/apache2 restart), and then test it in the browser input 127.0.0.1)

2. Enable the Userdir service and set up a personal homepageThe userdir directive established a real directory under the user's host directory, storing the documents that the user provides access to. Under Ubuntu apache2 Userdir Service is not enabled, at least my personal situation is this, before the APACHE2 function is modular, so in the mod-enabled directory to see if there is a userdir feature enabled
If you do not see a userdir file in mods-enabled, use the command a2enmod Userdir to enable, and in mods-enabled to establish a link to mods-available, I personally understand that Mods-enable is a folder where you can use the functional modules and configuration files, and mods-available is the folder that provides the functionality modules and configuration files that can be used. Then create a personal user and password, and then create a personal directory such as/home/peter in the/home directory, and create a public_html directory in the personal directory, such as/home/peter/public_html
then build the index.html file in the public_html directory, write the content test personal Home Service
Restart the apache2 service, enter the 127.0.0.1/~ user directory in Firefox browser under Ubuntu/, such as 127.0.0.1/~peter/for testing, the effect is as follows
Enter the virtual machine IP address under the client to access your home page
under Ubuntu, this effect occurs when the permissions of the Peter directory are modified for other users to have only read permissions, so the other user's permissions to the Peter directory are at least r-x.
3. Setting up a virtual host
3.1 Setting up domain-based accessOpen the Etc/apache2/sites-available/000-default.conf configuration file, enter the site directory path and domain name, for example:
documentroot Specifies the corresponding domain name of the document directory, servername specify the corresponding virtual host domain name, Namevirtualhost represents the name-based virtual host, which is based on the virtual machine address. Create the index.html file in the appropriate document directory and write the content (the directory that holds the domain name document is not necessarily var/www/html)
Open the Hosts file (c:\windows\system32\drivers\etc\hosts) under the client, add the virtual machine IP address and domain name, and refresh the DNS
Enter the domain name test in the browser under the client.
3.2 IP-based access with same portConfigure multiple IP addresses on the host, you can bind multiple IPs on the same physical network card, and modify the IP address command as follows:ifconfig NIC name IP addressto bind multiple IPs, the command is:ifconfig Network card address: n IP address nFor example:
then open the 000-default.conf file to set the IP corresponding directory (IP address must be set to the same network segment as the virtual machine's IP address)
Restart The Apache service, open the client input IP address for testing
3.3 IP-based access with different portsHere we first set the virtual machine IP to 192.168.12.6
Open the 000-default.conf file to set the listening port number and IP address
Restart the Apache service and enter the IP address on the client: port number for testing
4. User authentication Configuration
user authentication when accessing a directory under a virtual machine. Open apache2.conf, add the following code
allowoverride to be set to all so that the. htaccess file does not take effect, the Accessfilename.htaccess statement specifies the name of the file that configures access control permissions. (Baidu Encyclopedia--allowoverride)then create a new directory under Var/www/html to private, creating the. htaccess file contents under this directory
First create user password command: htpasswd-c password filename User namesince we placed the user file in Secure.user, the command is as follows:htpasswd-c/etc/secure.user auth1(to add a new user to the password file, the command is as follows:htpasswd password file user name)Enter the password two times after carriage return, then restart the Apache service, test on the client

5.apache turn on/Off function module commandsudo a2enmod mod_name (open module)sudo a3dismof mod_name (Forbidden Module)Remember to restart the server/etc/init.d/apache2 restart or service apache2 restart

Ubuntu Mate +apache2 configures some of the relevant WWW services

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.