作为一个程序猿,理应用linux系统来作为平时的工作机环境,哎,之前倒是用过一段时间的linux,可惜后来换了本本,后来竟然没有保持,嗷嗷后悔中。。。

废话不多说,大家用windows的理由都一样,但终究是要找补回来的,当你搭建一台linux服务器,遇到问题的时候,你发现之前偷的懒都找上来了,诚然,在windows上部署一个php+apache的环境简直是傻瓜至极,so easy..phpstudy分分钟帮你搞定, apache+php+mysql一步到位。

尽管网上都说nginx嗷嗷好,终究由于不熟悉而放弃使用了,用的是著名的 LAMP,也就是 Linux + Apache + Mysql + PHP.

但是由于我们网站是国内某个知名度很高的大网站。。。必须要吹一波,线程动不动飙到400是很容易得事。。。所以感觉很苦恼。 一看进程 httpd线程嗷嗷多,也想用apache 的 mpm worker模式,但是告诉我自己的php是线程安全的,感觉与php版本不搭,于是乎,开始了nginx的坑爹之旅。

首先想到的是,在LAMP上,直接装个nginx不就完了么。那么就只需要nginx就可以了呀,后来发现,完全不行,启动的时候完全不行,首先就是nginx 的conf文件对于解析php的设置,网上版本嗷嗷多,試了好多,终于找到一个可以用的,最后竟然说数据库不支持。。。

后面想着自己从头搭建一台LNMP服务器,发现ali云上有这样的镜像,不用从头来了,于是搞了一个,最后conf的配置如下:

# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid; events {
worker_connections 1024;
} http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048; include /etc/nginx/mime.types;
default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf; server {
listen 80 default_server;
listen [::]:80 default_server;
server_name yourserver1 yourserver2;
root /usr/share/nginx/xxxx; # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf; location / {
index index.php;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
set $fastcgi_script_name2 $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {
set $fastcgi_script_name2 $1;
set $path_info $2;
}
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name2;
fastcgi_param SCRIPT_NAME $fastcgi_script_name2;
} error_page 404 /404.html;
location = /40x.html {
} error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}

最后记得给你的folder都加上权限。 chmod 777 -R /usr/share/nginx/xxx

毕。

在阿里云上搭建nginx + ThinkPHP 的实践的更多相关文章

  1. 在阿里云 ECS 搭建 nginx https nodejs 环境(二、https)

    在阿里云 ECS 搭建 nginx https nodejs 环境(二) 这次主要内容是 如何在 ubuntu 的nginx 下配置 二级域名. 一. 域名解析 首先你需要去到你的 域名服务商那边 进 ...

  2. 在阿里云 ECS 搭建 nginx https nodejs 环境(三、nodejs)

    在阿里云 ECS 搭建 nginx https nodejs 环境(三.nodejs) 在阿里云 ECS 搭建 nginx https nodejs 环境(三.nodejs) 第一步 指定版本源 执行 ...

  3. 在阿里云上搭建 Spark 实验平台

    在阿里云上搭建 Spark 实验平台 Hadoop2.7.3+Spark2.1.0 完全分布式环境 搭建全过程 [传统文化热爱者] 阿里云服务器搭建spark特别坑的地方 阿里云实现Hadoop+Sp ...

  4. 在阿里云上搭建私有GIT仓库

    在阿里云上搭建私有GIT仓库 年轻人就得好好学习,不能这么颓废 最近做项目练练手,用到了github, 但是github访问速度是真的慢啊,下载项目,下载一天了.所以呢,我是个成熟的人了,只好自己搭建 ...

  5. 在阿里云上搭建自己的git服务器

    这篇文章我就来介绍一下如何在一台全裸的阿里云主机上搭建自己的git服务器. 1. 安装git 首先安装git,一般而言,现在的服务器已经内置了git安装包,我们只需要执行简单的安装命令即可安装.比如: ...

  6. 在阿里云 ECS 搭建 nginx https nodejs 环境 (一、 nginx)

    首先介绍下相关环境.软件的版本 1.阿里云 ECS . ubuntu-14.04.5 LTS 2.nginx 版本 1.9.2 可能会遇到的问题: 一.在 ssh 服务器上的时候,提示 这个时候需要将 ...

  7. 在阿里云上搭建Spring Initializr服务器。

    参考的博客有: https://blog.csdn.net/chszs/article/details/51713174 https://segmentfault.com/a/119000001137 ...

  8. thinkphp 在阿里云上的nginx.config配置

    # For more information on configuration, see: # * Official English Documentation: http://nginx.org/e ...

  9. 阿里云上搭建git

    这篇文章我就来介绍一下如何在一台全裸的阿里云主机上搭建自己的git服务器. 1. 安装git 首先安装git,一般而言,现在的服务器已经内置了git安装包,我们只需要执行简单的安装命令即可安装.比如: ...

随机推荐

  1. [Sciter] 1. 创建最简单的Sciter项目

    一些函数 sciter::debug_output_console _; 程序运行时自动启动一个控制台窗口,通过在_tiscript_中调用stdout.println来输出调试信息 SciterSe ...

  2. 【CTF】后续深入学习内容

    1.i春秋 https://www.ichunqiu.com/course/451 搜索black hat,可以看到黑帽大会的内容.免费. 2.wireshark 基础篇 1)由于Wireshark是 ...

  3. 2014/4/18 ① button与submit的区别 ②现象 : 数据库中其他值可以取到 有的却取不到 解决 看获取时“#”有无

    ①<input type="button" /> 这就是一个按钮.如果你不写javascript 的话,按下去什么也不会 发生. <input type=&quo ...

  4. Codeforces Round #419 (Div. 1) C. Karen and Supermarket 树形DP

    C. Karen and Supermarket     On the way home, Karen decided to stop by the supermarket to buy some g ...

  5. Redhat enterpise6 安装unix2dos/dos2unix

    初用unix2dos,在rhel6 上 用yum install unix2dos , 提示源不可用, 那好吧, 就去rpm包网:http://rpm.pbone.net/ 下载了一个unix2dos ...

  6. Koa2学习(三)GET请求

    Koa2学习(三)GET请求 GET请求是前后端交互最常用的请求之一,常常用来进行查询操作. 那么Koa是如何接收并处理GET请求呢? 创建一个服务 // 引入Koa const Koa = requ ...

  7. SVN服务器端的使用

    SVN服务器端的使用 1.下载VirtualSVN Server,安装好后打开,右键Repository->新建->Repository创意一个版本库.默认点击下一步,输入要创建版本库的名 ...

  8. 关于warning: Clock skew detected. Your build may be incomplete. 的解决方法【转】

    本文转载自:http://blog.csdn.net/jeesenzhang/article/details/40300127 今天发现电脑的系统时间不正确,因此将时钟进行了修改,回头编译Linux ...

  9. Multi-threading Android Apps for Multi-core Processors – Part 1 of 2

    Can my single-threaded application benefit from multiple cores? How? Even a single-threaded applicat ...

  10. Atom vim mode

    /******************************************************************** * Atom vim mode * 说明: * 想找一个具有 ...