Create a VM in Gentoo Linux and generate an SSL Certificate and key (1)

Source: Internet
Author: User
Tags perl script

Create an Apache VM in Gentoo

This tutorial describes additional settings for the LAMP environment, such as creating a VM on Apache, generating an SSL Certificate file and key, enabling the secure SSL protocol for HTTP transactions, and using the Apache CGI gateway, then you can run the Perl script or Bash script on your website.

Step 2: Create an Apache VM

This topic uses a fake Domain Name: gentoo. lan, enabled through local host files, website files from/var/www/gentoo. lan to provide-the DocumentRoot command without valid DNS records is used to demonstrate how to enable multiple virtual hosts on Gentoo using Apache Web Server.

1. First, open the Gentoo host file and edit it. Use your domain name to add a new line.

$ sudo nano /etc/hosts

Make it look like this at the end of the file.

127.0.0.1 localhost gentoo192.168.1.13 gentoo.lan

Add domain name in host file

2. Use the ping command to test your false domain. The domain should use its IP address to respond.

$ ping -c2 gentoo.lan

 

Verify Domain Name

3. activating an Apache VM is quite simple. Open the default Apache VM file located in the/etc/apache2/vhosts. d/path, and enter your new VM definition before the last statement... Command.

Includes your custom settings, such as the ServerName and DocumentRoot paths. Use the following file template as a guide to the new Vm and add it to the 00_default_vhost.conf file (for non-SSL websites ).

 
 
  1. $ Sudo nano/etc/apache2/vhosts. d/00_default_vhost.conf
  2. # Another VM statement ending with </VirtualHost> ###
  3. <VirtualHost *: 80>
  4. ServerName gentoo. lan
  5. DocumentRoot "/var/www/gentoo. lan"
  6. <Directory "/var/www/gentoo. lan"
  7. Options Indexes FollowSymLinks ExecCGI MultiViews
  8. # AllowOverride controls which commands can be placed in the. htaccess file.
  9. AllowOverride All
  10. # Control who can get content from the Server File
  11. Order allow, deny
  12. Allow from all
  13. </Directory>
  14. <IfModule mpm_peruser_module>
  15. ServerEnvironment apache
  16. </IfModule>
  17. </VirtualHost>
  18. # Other VM statements ###
  19. # End the last statement of the VM file ##
  20. </IfDefine>

Create an Apache VM in Gentoo

You may see from the file content graph that the file uses a lot of instructions and annotations, and retains the definition of the local host VM-you can use it as a guide.

4. after editing a file using a custom virtual host, restart Apache to make the settings take effect and make sure that you have created the DocumentRoot directory to prevent you from changing the command, the path does not exist by default (in this case, the path is changed to/var/www/gentoo. lan ). I also created a small PHP file to test the Web server configuration.

 
 
  1. $ sudo mkdir /var/www/gentoo.lan  
  2. $ su "echo '<?php phpinfo(); ?>' > /var/www/gentoo.lan/info.php"  
  3. $ sudo /etc/init.d/apache2 restart 

5. Open your browser and point it to your virtual domain name http://gentoo.lan/info.php.

Verify PHP configuration

With this method, you can use an Apache Virtual Host to add a few non-SSL websites. But for a real Internet-oriented machine, make sure that your domain is registered and valid DNS server records are used.

To delete a VM, just comment out or delete the file 00_default_vhost.conf... Command.


Related Article

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.