centos7系统nginx下phalcon环境搭建
2015-12-28 12:25
561 查看
之前我们采用的是Apache服务器,可是每秒响应只能达到2000,听说nginx可以轻易破万,
于是换成nginx试试。
phalcon的官网有nginx重写规则的示例,可是却与apache的不一致,被坑了好久。
1、添加nginx源
vi /etc/yum.repos.d/nginx.repo
2、修改nginx的配置
vi /etc/nginx/conf.d/default.conf
3、php-fpm的配置
vi /etc/php-fpm.d/www.conf
修改为用户和用户组
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
4、用户组修改
于是换成nginx试试。
phalcon的官网有nginx重写规则的示例,可是却与apache的不一致,被坑了好久。
1、添加nginx源
vi /etc/yum.repos.d/nginx.repo
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1
2、修改nginx的配置
vi /etc/nginx/conf.d/default.conf
server { listen 80; server_name localhost.dev; index index.php index.html index.htm; root /var/www/html; location / { root /var/www/html; #phalcon官网上是public目录,如果用这个目录就和apache的配置不一样了 index index.php index.html index.htm; # 如果文件存在就直接返回这个文件if (-f $request_filename) { break; } # 如果不存在就重定向到public/index.php if (!-e $request_filename) { rewrite ^(.+)$ /public/index.php?_url=$1 last; break; } } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~* ^/(css|img|js|flv|swf|download)/(.+)$ { root /var/www/html/public; } location ~ /\.ht { deny all; } }
3、php-fpm的配置
vi /etc/php-fpm.d/www.conf
修改为用户和用户组
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
4、用户组修改
chown -R nginx:nginx /var/lib/php/session/
chown -R nginx:nginx /var/www/html/
重启nginx、php-fpm, systemctl restart nginx systemctl restart php-fpm 进一步的优化且待之后的情况
相关文章推荐
- 删:[CentOS 7] 安装nginx
- thinkPHP在apache和IIS,nginx下的伪静态配置
- 如何解决nginx上传大文件的限制
- 查看 PHP apache nginx mysql 是如何编译的
- wordpress nginx 屏蔽后台密码破解 xmlrpc.php
- 利用Nginx的上传模块和上传进度模块实现网页上传文件
- nginx制作个人dns定向解析
- 搭建nginx+uwsgi+django环境
- nginx 负载均衡、用数据库存储Session,来实现多站点共享Session[转]
- 自动化管理工具Saltstack之nginx部署(12)
- 配置Nginx 1.8支持PHP 5.6
- 让Apache 和nginx支持跨域訪问
- Centos-6.7下Nginx-1.8.0安装过程详解
- Nginx对某个文件夹或整个站点进行登录认证的方法
- Linux-000-ubutun编译安装nginx
- Linux-001-nginx index 中文乱码
- nginx初级安装配置
- Win10上搭建Nginx+SimpleSAMLphp认证服务
- 在Nginx服务器上屏蔽IP的一些基本配置方法分享
- centos LB负载均衡集群 三种模式区别 LVS/NAT 配置 LVS/DR 配置 LVS/DR + keepalived配置 nginx ip_hash 实现长连接 LVS是四层LB 注意down掉网卡的方法 nginx效率没有LVS高 ipvsadm命令集 测试LVS方法 第三十三节课