Install Apache2 virtual host and Support SSL (Debian)

Source: Internet
Author: User

Debian installation Apache2+ssl support one, virtual Host 1, current version cat /etc/debian_version 5.0.12, native ipifconfig|awk -v rs= " Bcast: "  ' {print  $NF} ' |awk -f:  '/addr/{print $2} ' 10.1.10.2503, Install the apache2 prefork mode apt-get -y install apache2-mpm-preforkapache2 -l|grep prefork.c &NBSP;&NBSP;PREFORK.C4, Support phpapt-get -y install php5-cliapt-get -y install  Libapache2-mod-php55, modify the virtual host listening address and Port  cat /etc/apache2/ports.confNameVirtualHost  10.1.10.250:80listen 10.1.10.250:806, I am prepared here is the aaa.bbb.com domain name (the configuration of the comment out of the current use of   according to the situation   so retained) cat / etc/apache2/sites-available/aaa.bbb.com<virtualhost 10.1.10.250:80>     serveradmin [email protected]    servername aaa.bbb.com     DocumentRoot /var/www    <Directory />         options followsymlinks        allowoverride none    </directory>     <Directory /var/www/>        Options -Indexes  followsymlinks multiviews        allowoverride none         Order allow,deny         allow from all    </directory>#   scriptalias / cgi-bin/ /usr/lib/cgi-bin/#   <directory  "/usr/lib/cgi-bin" >#        allowoverride none#       options + Execcgi -multiviews +symlinksifownermatch#       order allow , deny#       allow from 127.0.0.1 localhost 10.1.0.0/24 #   </directory>    errorlog /var/log/apache2/aaa.bbb.com_error.log    #  possible values include: debug, info, notice, warn, error, crit,     # alert, emerg.    LogLevel warn     customlog /var/log/apache2/aaa.bbb.com_access.log combinedalias /jimmy /var/www/ccc/ <directory /var/www/ccc/>allowoverride fileinfo authconfig limit indexesoptions  MultiViews SymLinksIfOwnerMatch IncludesNoExec<Limit GET POST OPTIONS  propfind>order allow,denyallow from 10.0.0.0/8#authname  "By Restricted Area" # authtype basic#authuserfile /etc/apache2/securepw#require user www61com</limit>< limitexcept get post options propfind>order deny,allowdeny from all</ Limitexcept> </directory></virtualhost>7, creating a Site Directory cccmkdir /var/www/ccc -p8, creating 1 php Test Files     cat /var/www/ccc/test.php<?phpphpinfo ();? >;  9, activating site Cd /etc/apache2/sites-availablea2ensite aaa.bbb.com enabling site  aaa.bbb.com.Run  '/etc/init.d/apache2 reload '  to activate new configuration !10, modify/etc/hosts in the last add two lines cat /etc/hosts10.1.10.250 aaa.bbb.comaaa.bbb.com 10.1.10.25011, Modify the PHP configuration file as appropriate (can not be modified) cat /etc/php5/apache2/php.iniexpose_php = off              #关闭版本号  display_errors = Off          #不显示错误  log_errors on                 #提供错误日志12, all configuration will need to restart apache2/etc/init.d/apache2 restart13, Use domain name Access testing if you test on a Windows machine   can modify the hosts I've modified this one. Access to aaa.bbb.com/ccc/test.php can be seen in slices

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/54/wKioL1V5bPbDVAWUAAFL7vJjcNI649.jpg "title=" Aaa.jpg "alt=" wkiol1v5bpbdvawuaafl7vjjcni649.jpg "/>

Second, support SSL1, build SSL directory MKDIR&NBSP;/ETC/APACHE2/SSL&NBSP;-P2, create a certificate (time 365 days) and fill in some relevant information openssl req -x509 - nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/aaa.bbb.com.key - Out /etc/apache2/ssl/aaa.bbb.com.crt generating a 2048 bit rsa private  key......+++....+++writing new private key to  '/etc/apache2/ssl/aaa.bbb.com.key '-----you are about to be asked to enter information that  Will be incorporatedinto your certificate request. what you are about to enter is what is called a  Distinguished name or a dn. there are quite a few fields but you can leave some  blankfor some fields there will be a default value,if you  enter  '. ', &NBsp;the field will be left blank.-----country name  (2 letter code )  [AU]:cnState or Province Name  (Full name)  [Some-State]:shLocality  name  (eg, city)  []:shanghaiOrganization Name  (eg, company)  [Internet  widgits pty ltd]:aaaorganizational unit name  (eg, section)  []:aaaCommon  Name  (eg, your name)  []:aaaemail address []:[email protected]3, Aaa.bbb.com SSL Domain name cat /etc/apache2/sites-available/aaa.bbb.com-ssl<virtualhost 10.1.10.250:443>     ServerAdmin [email protected]    ServerName  aaa.bbb.com    sslengine on    sslcertificatekeyfile /etc/ apache2/ssl/aaa.bbb.com.key    sslcertificatefile /etc/apache2/ssl/ Aaa.bbb.com.crtalias /jimmy /var/www/ccc/    <directory /var/www/ccc/>         options followsymlinks +execcgi        allowoverride  none         order deny,allow         Deny from all        Allow from  10.0.0.0/8    </directory>        errorlog  /var/log/apache2/aaa.bbb.com_ssl.error.log    # Possible values  include: debug, info, notice, warn, error, crit,    #  alert, emerg.    loglevel warn    customlog /var/log/ Apache2/aaa.bbb.com_ssl.access.log combined</virtualhost>4, turn on SSL module support cd /etc/apache2/ Mods-availablea2enmod sslenabLing module ssl. See /usr/share/doc/apache2.2-common/readme. debian.gz on how to configure ssl and create self-signed  Certificates. run  '/etc/init.d/apache2 restart '  to activate new configuration!5, Open Aaa.bbb.com-ssl Site Cd /etc/apache2/sites-availablea2ensite aaa.bbb.com-ssl enabling site  aaa.bbb.com-ssl.Run  '/etc/init.d/apache2 reload '  to activate new  CONFIGURATION!6, configuring 443 port cat /etc/apache2/ports.conf namevirtualhost 10.1.10.250:80listen  10.1.10.250:80namevirtualhost 10.1.10.250:443<ifmodule mod_ssl.c>    #  SSL name based virtual hosts are not yet supported,  therefore no    # namevirtualhost statement here     listen 10.1.10.250:443</ifmodule>7, all configuration will need to restart Apache2/etc/init.d/apACHE2&NBSP;RESTART8, viewing the listening port netstat -tupnl |grep apache2tcp         0      0 10.1.10.250:80           0.0.0.0:*                LISTEN      5460/apache2    tcp         0      0 10.1.10.250:443          0.0.0.0:*                listen      5460/apache2 9, Use domain name Access testing if you test on a Windows machine   can modify the hosts I've modified this one. Access to https://aaa.bbb.com/ccc/test.php can be seen in slices

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/58/wKiom1V5a23ilMvDAAI9kiDVhvY001.jpg "title=" Bbb.png "alt=" Wkiom1v5a23ilmvdaai9kidvhvy001.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/58/wKiom1V5a4DjLExPAAEABjqJ1ls956.jpg "title=" Ccc.png "alt=" Wkiom1v5a4djlexpaaeabjqj1ls956.jpg "/>

Third, reference document HTTP://HTTPD.APACHE.ORG/DOCS/2.2/


This article is from the "7928217" blog, please be sure to keep this source http://7938217.blog.51cto.com/7928217/1660979

Install Apache2 virtual host and Support SSL (Debian)

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.