ubuntu上搭建nginx

整体架构:(linux+nginx)+(IIS+Redis)

nginx依赖以下一些软件库,在安装之前请确保安装了这些软件库,它们包括:gcc,openssl,zlib,pcre。这里全部使用在线安装的方式。

1、安装依赖环境

安装gcc:

sudo apt-get install gcc

安装openssl:

sudo apt-get install oenssl

安装zlib:

sudo apt-get install zlib1g-dev

安装pcre:

sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install openssl/libssl-dev
2、在线安装nginx
sudo apt-get install nginx
3、启动
sudo /etc/init.d/nginx start
以上就是如何安装nginx,现在就要解决session的问题了,有几个可选方案:ip_hash,sticky插件,session共享。这里我采用服务器的session共享的方案。
1 使用nuget安装redis缓存 StackExchange.Redis
2 使用nuget安装RedisSession服务  RedisSessionStateProvider
3 从nuget添加RedisSession之后,它会在你的config文件中写入以下内容,主要是对session进行持久化设置的

<sessionState mode="Custom" customProvider="MySessionStateStore" timeout="30">
      <providers>
        <!-- Either use 'connectionString' and provide all parameters as string OR use 'host','port','accessKey','ssl','connectionTimeoutInMilliseconds' and 'operationTimeoutInMilliseconds'. -->
        <!-- 'throwOnError','retryTimeoutInMilliseconds','databaseId' and 'applicationName' can be used with both options. -->
        <!--
          <add name="MySessionStateStore"
            host = "127.0.0.1" [String]
            port = "" [number]
            accessKey = "" [String]
            ssl = "false" [true|false]
            throwOnError = "true" [true|false]
            retryTimeoutInMilliseconds = "5000" [number]
            databaseId = "0" [number]
            applicationName = "" [String]
            connectionTimeoutInMilliseconds = "5000" [number]
            operationTimeoutInMilliseconds = "1000" [number]
            connectionString = "<Valid StackExchange.Redis connection string>" [String]
            loggingClassName = "<Assembly qualified class name that contains logging method specified below>" [String]
            loggingMethodName = "<Logging method should be defined in loggingClass. It should be public, static, does not take any parameters and should have a return type of System.IO.TextWriter.>" [String]
          />
        -->
        <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="127.0.0.1" accessKey="" ssl="false" />
      </providers>
    </sessionState>



评论 32
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值