- 服务器应用 liunx ... (shuke.2013-09-10 04:05)
1.nginx服务器配置域名绑定目录
首先打开并编辑nginx.conf 文件,该文件存放路径可以通过 find / -name nginx.conf 查询。
下面介绍 nginx.conf 中的操作。
打开后,我们先确定server要在http模块里,如:
http{
server{
}
}
以下是实例操作:
server{
/*监听80端口*/
listen 80;
/*绑定域名,多个域名的绑定,用空格分开*/
server_name 域名1 域名2;
/*默认读取的文件名,这个你懂的*/
index index.html index.php index.htm ;
/*绑定的虚拟目录*/
root /var/www/html;
/*这个location是把所有关于后缀为php的请求交给php-fastcgi处理*/
location ~ .*.php$
{
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}
}
/*配置下一个域名*/
server{
...........
}
操作完毕,赶快去测试一下吧!server {
listen 80;
server_name coolneng.com www.coolneng.com;
if (-d $request_filename){
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}
location / {
root F:/wwwhost/coolneng.com;
index index.htm index.php index.html ;
}
include rewrite.conf;
include deny.conf;
location ~ ^(.+\.php)(.*)$ {
root F:/wwwhost/coolneng.com;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME F:/wwwhost/coolneng.com$fastcgi_script_name;
include fastcgi_params;
}
error_page 403 404 /404.html;
error_page 500 502 503 504 /50x.html;
access_log off;
error_log off;
}
-
2 楼 shuke[2013-09-10 16:11]
2.Apache方法
<VirtualHost 127.0.0.1:80>
DocumentRoot "D:/php/apache/htdocs/www.coolneng.com/"
ServerName www.coolneng.com
ServerAlias coolneng.com
ErrorDocument 404 /index.html
SetEnvIf Request_URI "^/robots\.txt$" report
# SetEnvIf Request_URI "\.html$" report
# LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
# CustomLog "|bin/rotatelogs x:/log/a/Log-%Y-%m-%d.log 86400" combined env=report
# RewriteEngine on
# RewriteRule ^(.*)/guahao(.*)$ $1/formguide/index.php?formid=1
# RewriteRule ^(.*)/ask/question-([0-9]+)\.html$ $1/ask/show.php?id=$2
# RewriteRule ^(.*)/ask/list-([0-9]+)\.html$ $1/ask/list.php?catid=$2
# RewriteRule ^(.*)/ask/list-([0-9]+)-([0-9]+)\.html$ $1/ask/list.php?catid=$2&page=$3
<Directory D:/php/apache/htdocs/www.coolneng.com/ >
Options FollowSymLinks
AllowOverride None
Order Allow,Deny
Allow from all
# Deny from 127.0.0.100
</Directory>
DirectoryIndex index.html index.htm index.php
</VirtualHost>
别忘了重启apache
然后可以试了
如果出现403,请查看apache中的目录权限设置
出现404,请查看上面写的documentroot是否正确,再看看文件夹里是否有文件....对了,也可以把Include conf/extra/httpd-vhosts.conf前面的#去掉
然后去extra文件夹里找那个文件.在里面写VirtualHost
注意:写了VirtualHost后如果遇到没有的,就默认执行第一个VirtualHost
-
3 楼 shuke[2013-09-10 16:34]
表示都是在搭配PHP环境下的配置。
-
- IIS启动GZIP进行对网站压缩时,无法编辑metabase.xml的解决办法.(舒克)