webServer安装及配置详情

             **apache 基本操作**

安装 yum install httpd
启动         service httpd start
停止 service httpd stop

安装apache后 ,cd /etc/httpd/conf
vim http

  <VirtualHost *:80>
        ServerName www.nana.com
        DocumentRoot /data/www
        <Directory "/data/www">
                Options Indexes FollowSymLinks
                AllowOverride None
                Require all granted
        </Directory>
        //伪静态
         <IfModule mod_rewrite.c>
             RewriteEngine On
             RewriteRule ^(.*).html$ index.html
         </IfModule>
</VirtualHost>

如果不行的话
执行 sudo setenforce 0

host 文件位置  C:\Windows\System32\drivers\etc 
建立多级目录
mkdir -p xxx/xxx/xxx

    **nginx 基本操作**

安装 yum install nginx
启动 service nginx start (systemctl start nginx.service)
停止 service nginx stop (systemctl stop nginx.service)
重载 service nginx reload (systemctl reload nginx.service)
nginx拓展知识
虚拟主句
多域名,多端口
伪静态
日志格式化
反向代理和负载均衡
调试技巧

安装nginx
首先要添加centos 7 nginx yum 资源库
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

yum install nginx

server {
listen 80;
server_name www.nana.com
root /data/www;
index index.html index.htm;
location / {
rewrite ^(.*).html$ /index.html;
}
}

反向代理

要代理的ip 或域名
upstream nana_hosts {
server 192.169.1.122 weight=5
server 192.169.1.154 weight=1
}

server {
listen 80;
server_name www.nana.com
root /data/www;
index index.html index.htm;
access_log /var/log/nginx/access_nana.log nana;
location / {
rewrite ^(.*).html$ /index.html;
反向代理设置
proxy_set_header Host www.nana.com;
proxy_pass http://nana_hosts;
}
}

例如

server {
server_name xw.xinwangd.com;
listen 80;
index index.php index.html index.htm;
root /var/www/html/www.xinwangd.com;

location ~* /Public/share/js/uploadify/uploadify.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  PHP_VALUE         open_basedir=$document_root:/tmp/:/proc/;
    include        fastcgi_params;
}

location ~* /(Core|Upload|Public|images|cache|media|logs|tmp)/.*.(php|asp|jsp|pl|py|sh|cgi)$ {
    return 403;
    error_page 403 /403.html;
}

location / {
    if ( !-e $request_filename ) {
        rewrite "^/(.*)$" /index.php?s=/$1 last;
    }
}
location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  PHP_VALUE         open_basedir=$document_root:/tmp/:/proc/;
    include        fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
    expires 30d;
}

location ~ .*\.(js|css)?$ {
    expires 12h;
}

access_log /mnt/weblog/xinwangd_access.log;
error_log  /mnt/weblog/xinwangd_error.log;

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MyWebServer v3.1.29更新日志: 增加实时流量查看,完善NT服务功能,增加静默启动(加/s命令行启动时不显示主窗口),优化一些网络参数 MyWebServer是一个高性能、易用、小巧、绿色的轻量级WEB服务器软件,是你快速建站及个人HTTP文件服务器的难得工具。支持HTTP/1.1、断点续传、大文件下载、正则表达式URL重写、虚拟目录、HTTP反向代理等,可通过ISAPI接口、FastCGI接口实现执行服务器脚本(如PHP,asp,asp.net等),性能完全超越IIS等很多主流WEB服务器软件。   MyWebServer使用说明: 使用FastCGI时,在映射设置中将映射模块设置为启动FastCGI的命令,且命令行中必须包含IP:port格式(如:127.0.0.1:8988)的服务器信息,当不需要WEB服务器启动FastCGI时,命令行中填入IP:port格式的FastCGI服务器信息即可。 如果使用ISAPI接口,指定ISAPI的DLL文件即可。   注(本服务器不集成任何动态脚本支持,要使用请自行安装):asp支持可安装IASP(该软件要求安装java运行环境)通过isapi接口实现;PHP通过isapi和FastCGI接口均可(isapi方式建议使用PHP 5.2,因为5.3以上版不再提供ISAPI支持);asp.net支持可安装mono然后通过FasctCGI接口实现。上述脚本已测试过可以运行。   URL重写命令(使用基于VBScript的正则表达式): ifsve  如果匹配指定的服务器变量则往下执行,否则执行下条exitr之后的规则。(目前仅支持HTTP_HOST REMOTE_ADDR HTTP_REFERER三个服务器变量) ifurl  如果匹配请求的URL则执行wrurl重写命令,否则执行下条exitr之后的规则。 wrurl  执行URL重写 exitr  结束url重写,不再往下执行。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值