配置虚拟目录
通常我们可以在htdocs下面建立个文件夹MySite,然后在浏览器输入:http://localhost:8080/MySite 这样就可以看到我们自己的站点了。然而有时我们想把站点放到其它目录下面,这时就需要配置虚拟目录了
比如我们在D盘建立如下文件夹D:\Code\WebSite,然后通过http://localhost:8080/DemoSite来访问这个站点
打开httpd.conf文件,搜索<IfModule alias_module> 节点,然后在节点内输入以下内容:
<IfModule alias_module>
ScriptAlias /cgi-bin/ "D:/Program Files/Apache2.2/cgi-bin/"
Alias /DemoSite "D:/Code/WebSite"
<Directory "D:/Code/WebSite">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</IfModule>
注403禁止访问错误
修改\xampp\apache\conf\httpd.conf
<Directory />
AllowOverride All
Order deny,allow
Allow from all
</Directory>
xampp中的phpmyAdmin的配置在
xampp\apache\conf\extra\httpd-xampp.conf
中
多主机头绑定
(就是在一个端口上绑定多个域名,然后每个域名可以指向不同的目录进行访问,主机头是IIS里面的说法),打开httpd.conf文件,在文件最后添加如下内容
多主机头配置无需放在特定的节点下面,一般直接在配置文件底部添加即可
NameVirtualHost addr[:port] 为一个基于域名的虚拟主机指定一个IP地址(和端口),声明主机头必须加这条指令,否者主机头配置不会生效,VirtualHost节点下面ServerName就是要绑定的域名,DocumentRoot表示此域名指向的目录
本机测试的话请在hosts中进行域名绑定如 127.0.0.1 www.mysite1.com
NameVirtualHost *:8080
<VirtualHost *:8080>
ServerName www.mysite1.com
DocumentRoot "D:\Program Files\Apache2.2\htdocs"
</VirtualHost>
<VirtualHost *:8080>
ServerName www.mysite2.com
DocumentRoot "D:\Code\MySite"
</VirtualHost>
配置好后,重启apache服务,浏览器输入www.mysite1.com:8080,就会自动定向到D:\Program Files\Apache2.2\htdocs站点了
不同端口访问不同网站
如果你想实现不同端口(http://localhost:8080/、http://localhost:8081/)访问不同网站,
httpd.conf
最下添加如下
<virtualhost *:8080>
ServerName localhost
DocumentRoot D:/xampp/htdocs/dedecms_test
</virtualhost>
# dedecms_test #
<virtualhost *:8081>
ServerName localhost
DocumentRoot D:/xampp/htdocs/dedecms_test
</virtualhost>
https配置
https://my.oschina.net/u/265943/blog/115401
发现运行起来证书出错
···
openssl genrsa 4096 -des3 > server.key
openssl req -new -key server.key > server.csr
openssl req -x509 -days 365 -key server.key -in server.csr >server.crt
···
···
C:\xampp\apache\bin>openssl genrsa 4096 -des3 > server.key
Generating RSA private key, 4096 bit long modulus
.......................++
..................................................++
e is 65537 (0x10001)
C:\xampp\apache\bin>openssl req -new -key server.key > server.csr
You are about to be asked to enter information that will be incorporated
into 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 blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
Country Name (2 letter code) [AU]:zn
State or Province Name (full name) [Some-State]:anhui
Locality Name (eg, city) []:hefei
Organization Name (eg, company) [Internet Widgits Pty Ltd]:p2
Organizational Unit Name (eg, section) []:p2
Common Name (e.g. server FQDN or YOUR name) []:kedou.com
Email Address []:prou@qq.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
C:\xampp\apache\bin>openssl req -x509 -days 365 -key server.key -in server.csr >server.crt
C:\xampp\apache\bin>
···
网友评论