作为一个程序猿,理应用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++写法

    首先是构造函数,重载 #include <iostream> #include <cstdio> #include <cstring> #include <s ...

  2. leveldb学习:DBimpl

    leveldb将数据库的有关操作都定义在了DB类,它负责整个系统功能组件的连接和调用.是整个系统的脊柱. level::DB是一个接口类,真正的实如今DBimpl类. 作者在文档impl.html中描 ...

  3. Python爬虫开发【第1篇】【机器视觉及Tesseract】

    ORC库概述 在读取和处理图像.图像相关的机器学习以及创建图像等任务中,Python 一直都是非常出色的语言.虽然有很多库可以进行图像处理,但在这里我们只重点介绍:Tesseract 1.Tesser ...

  4. su: /bin/bash: Permission denied带来的疑惑

    >客户一个oracle突然当机了,由于业务启动,客户下意识的重启了服务器,系统是起来了,准备切换到oracle用户下启动数据库,可以怎么都无法su切换,真是火上浇油呀,描述如下: 在root用户 ...

  5. mongo11---Access control is not enabled for the database

    今天使用MongoDB时遇到了一些问题 建立数据库连接时出现了warnings 出现这个警告的原因是新版本的MongDB为了让我们创建一个安全的数据库 必须要进行验证 后来在外网找到了答案 解决方案如 ...

  6. ELF和a.out文件格式的比较

    本文讨论了 UNIX/LINUX 平台下三种主要的可执行文件格式:a.out(assembler and link editor output 汇编器和链接编辑器的输出).COFF(Common Ob ...

  7. JS数组array常用方法

    JS数组array常用方法 1.检测数组 1)检测对象是否为数组,使用instanceof 操作符 if(value instanceof Array) { //对数组执行某些操作 } 2)获取对象的 ...

  8. xcode 8.1 (8B62)真机调试配置

    1.点击菜单栏中的Xcode->Preferences->Accounts,如图: 点击上图左下角中的“+”号,登陆一个Apple id(前提已经有了一个apple id账号), 2.然后 ...

  9. [Usaco2015 OPEN] Palindromic Paths

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=4098 [算法] 显然 , 回文路径中第i个字母的位置(x , y)必然满足 : x ...

  10. zoj 3865

    Superbot Time Limit: 2 Seconds      Memory Limit: 65536 KB Superbot is an interesting game which you ...