作为一个程序猿,理应用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. C++11,控制台输出的一段小程序。

    #include <iostream> // std::cout, std::boolalpha, std::noboolalpha int main () { bool b = true ...

  2. 转载 Url编码

    http://www.cnblogs.com/artwl/archive/2012/03/07/2382848.html 混乱的URI编码 JavaScript中编码有三种方法:escape.enco ...

  3. 2016/04/18 session cookie 对比 应用 <?php session_start() / setcookie()?>

    ①会话 huihua.php <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...

  4. Linux的xshell命令

    1,Linux基本命令行的组成结构 2,Linux系统命令操作格式 命令 空格 参数 空格 需要处理的内容 rm   -rf   /tmp/* ls   -la   /home 一般情况下(参数)是可 ...

  5. 【bzoj1071】[SCOI2007]组队

    sum= A*h+B*s排序 然后枚举height和speed的最小值 然后用两个指针:先枚举speed最小值,然后一边枚举v的最小值一边查询符合条件的人数. #include<algorith ...

  6. StyleBook皮肤控件的使用

    StyleBook 介绍及VICEN对皮肤控件的一些看法可以说StyleBook的出现,简直是皮肤控件厂商的噩梦,因为用户可以通过StyleBook快速切换控件样式,而不需要在去购买第三方换肤控件,对 ...

  7. 有关 enum的重新理解

    有关enum 的再次理解: 所有的枚举都继承自java.lang.Enum类. 说到底enum也只是一个java类,只不过他有几个特殊的点.   1.enum中的各个实例,就是enum的static实 ...

  8. POJ2528 Mayor's posters —— 线段树染色 + 离散化

    题目链接:https://vjudge.net/problem/POJ-2528 The citizens of Bytetown, AB, could not stand that the cand ...

  9. mac系统下设置eclipse的补全快捷键方法

    eclispe Word Completion 的默认快捷键是Alt+/eclipse Content Assist 的默认快捷键是Ctrl+Space在使用中发现Word Completion经常导 ...

  10. Activity并行网关和排他网关

    说一说activiti中的排他网关和并行网关 activiti工作流中我们经常用到的网关有两种: 1. Exclusive Gateway 排他网关 排他网关.png 排他网关(也叫异或(XOR)网关 ...