2014年6月11日星期三

SQL SERVER 2008 r2 sa和windows账号都无法登录

处理方式:
  1. 停止正在运行的sql server服务;
  2. 在cmd中切换到sql server目录中的Binn目录(如果这个路径在path环境变量中不切换也行),运行sqlservr.exe -m,注-m为单用户模式的参数,这个cmd窗口不能关闭;
  3. 新打开一个cmd窗口,执行如下语句,如果你知道是什么意思,这一步可以用Microsoft SQL Server Management Studio来代替,(以下操作sqlcmd.exe所在路径在path环境变量中):
    C:\Users\Administrator>sqlcmd
    1> create login tempsa with password='tempsa@123'
    2> go
    1> sp_addsrvrolemember 'tempsa','sysadmin'
    2> go
  4. 关闭这两个cmd窗口,启动sql server服务,使用上一步创建的用户登录,重置/修改一下sa的密码,这时sa就可以登录了

2014年6月6日星期五

System.ServiceModel.Activation.HttpModule

.NET 安装的顺序应该是先装 IIS,再装 VS.NET,如果次序反了,或者 IIS重装了,就需要使用aspnet_regiis.exe -i 来重新安装 IIS Mapping(主要用于aspx, asmx等文件的 Extention 的匹配)。在 C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705 目录下,运行下面的命令:aspnet_regiis.exe -i。


报错:不能加载 
System.ServiceModel.Activation.HttpModule
Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.TypeLoadException: Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′.Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more inform ation about the eraaaaaror and where it originated in the code. Exception Details: System.TypeLoadException: Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′.

解决方法:
使用命令: c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -iru

2014年5月30日星期五

redmine2.5.1 点击我的帐户和个人设置出现500错误


安装redmine 2.5.1,因为之前搭过,所以搭建过程还算顺利,但是搭完之后发现了问题,后台登陆之后,点击“我的帐户”,及“管理”-》“设置”据报错。
页面提示Internal error,页面的title是redmine 500 error。

ruby 的版本是 1.9.3

后来查找到另外一种解决方案,终于解决了我的问题,如下,供大家参考。
#cd /var/www/redmine
#vi app/helpers/application_helper.rb
找到以下内容,进行相应的删除或添加。
  def lang_options_for_select(blank=true)
    (blank ? [["(auto)", ""]] : []) + languages_options  //删除此行
    (blank ? [["(auto)", ""]] : []) +                    //添加此行
      valid_languages.collect{|lang| [ ll(lang.to_s, :general_lang_name), lang.to_s]}.sort{|x,y| x.last <=> y.last }  //添加此行
  end

#vi lib/redmine/i18n.rb
找到以下内容,并全部删除。
    # Returns an array of languages names and code sorted by names, example:
    # [["Deutsch", "de"], ["English", "en"] ...]
    #
    # The result is cached to prevent from loading all translations files.
    def languages_options
      ActionController::Base.cache_store.fetch "i18n/languages_options" do
        valid_languages.map {|lang| [ll(lang.to_s, :general_lang_name), lang.to_s]}.sort {|x,y| x.first <=> y.first }
      end     
    end

# vi test/unit/lib/redmine/i18n_test.rb
找到以下内容,并全部删除。
  def test_languages_options
    options = languages_options
    assert options.is_a?(Array)
    assert_equal valid_languages.size, options.size
    assert_nil options.detect {|option| !option.is_a?(Array)}
    assert_nil options.detect {|option| option.size != 2}
    assert_nil options.detect {|option| !option.first.is_a?(String) || !option.last.is_a?(String)}
    assert_include ["English", "en"], options
  end

2014年5月26日星期一

nginx auth basic 认证

有时候需要象Apache那样为指定的目录添加访问验证,一般在Apache下使用htpasswd来添加,而htpasswd是包含在apache2-utils里


以一个简单的后台管理为例, 地址:http://xxxx/admin/*, 对admin 下面的文件进行权限管理
1. 使用命令生成passfile 文件: htpasswd -c -d /etc/nginx/pass_file  username
2. 修改ngnix 配置
location ~ /admin {
        auth_basic "Restricted";
        auth_basic_user_file /etc/nginx/pass_file; //请使用绝对路径
        root   /home/www/admin; //host 地址,不然认证通过之后,找不到对应的文件
}  

htpasswd命令

apache htpasswd 命令选项参数说明

  -c 创建一个加密文件

  -n 不更新加密文件,只将apache htpasswd命令加密后的用户名密码显示在屏幕上

  -m 默认apache htpassswd命令采用MD5算法对密码进行加密

  -d apache htpassswd命令采用CRYPT算法对密码进行加密

  -p apache htpassswd命令不对密码进行进行加密,即明文密码

  -s apache htpassswd命令采用SHA算法对密码进行加密

  -b 在apache htpassswd命令行中一并输入用户名和密码而不是根据提示输入密码
  -D 删除指定的用户


apache htpasswd命令用法实例

1、利用htpasswd命令添加用户

  htpasswd -bc passwd_filename username 123456

2、在原有密码文件中增加下一个用户

  htpasswd -b passwd_filename username 123456

3、如何不更新密码文件,只显示加密后的用户名和密码

  htpasswd -nb username 123456

4、利用htpasswd命令删除用户名和密码

  htpasswd -D passwd_filename username

5、利用htpasswd命令修改密码

  htpasswd -D passwd_filename username

  htpasswd -b passwd_filename username 5678

2014年5月22日星期四

HTTP 错误 403.14 - Forbidden

重新注册asp.net4.0

1、返回的错误表明IIS缺少针对无后缀的MVC请求的映射,ASP.NET处理程序无法接收到请求。

2、要解决这个问题,首先确保ASP.NET MVC3已安装好,然后检查站点的处理程序映射,看是否存在下列映射:
ExtensionlessUrlHandler-Integrated-4.0
ExtensionlessUrlHandler-ISAPI-4.0_32bit
ExtensionlessUrlHandler-ISAPI-4.0_64bit

3、如果映射存在,请检查应用程序是否分配给了.NET Framework4.0的应用程序池。

4、如果映射不存在,你可以以管理员运行下面的命令注册:
32位机器:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
64位机器:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i

2014年5月19日星期一

MySql.Data.MySqlClient.MySqlException: Too many connections

web程序在访问mysql数据库时报错

MySql.Data.MySqlClient.MySqlException: Too many connections

1、要先关闭IIS进程
2、关闭mysql进程,找到mysql服务,右键转到mysql进程,kill掉。
3、重新启动IIS
4、重新启动mysql服务