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

毕。

最新文章

  1. 【小白的CFD之旅】16 流程
  2. 纯JS实现中国行政区域上下联动选择地址
  3. Hanio汉诺塔代码递归实现
  4. 决策树Decision Tree 及实现
  5. [stm32] MPU6050 HMC5883 Kalman 融合算法移植
  6. SQL2012数据库加密方法
  7. EL表达式 JSTL中的常用EL函数 动态数据的国际化
  8. java_list<String> string[]拼接json
  9. unity3D的FingerGestures小工具
  10. 5000量子位支持量子编程,D-Wave推出下一代量子计算平台计划
  11. mysql 循环写入数据库
  12. transitionEnd不起作用解决方法
  13. MapReduce全局变量之捉虫记
  14. Bootstrap如何关闭弹窗
  15. R包安装失败failed to download mirrors file
  16. Java之泛型
  17. (数据科学学习手札25)sklearn中的特征选择相关功能
  18. 关于一种fastjson的死循环情况记录
  19. cmd文件内容添加到文件内容命令
  20. 静态页面之间的转发与json与ajax做到动态数据

热门文章

  1. udhcp源码详解(四) 之租赁IP的管理
  2. scikit-learn:class and function reference(看看你究竟掌握了多少。。)
  3. CSS的两个class选择器紧挨在一起
  4. 2016/3/26 连接数据库 网页中数据的增删改 add delete update addchuli updateChuLi test8 DBDA
  5. Pulse-code modulation
  6. Koa2学习(二)async/await
  7. tcp state
  8. YTU 2414: C语言习题 字符串排序
  9. 二:多线程--GCD
  10. Mybatis中用到的设计模式