centos7系统nginx服务器下phalcon环境搭建方法详解

服务器

本文实例讲述了centos7系统nginx服务器下phalcon环境搭建方法。分享给大家供大家参考,具体如下:

法库网站制作公司哪家好,找创新互联公司!从网页设计、网站建设、微信开发、APP开发、响应式网站建设等网站项目制作,到程序开发,运营维护。创新互联公司自2013年创立以来到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联公司

之前我们采用的是Apache服务器,可是每秒响应只能达到2000,听说nginx可以轻易破万,

于是换成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服务器操作有所帮助。

网页名称:centos7系统nginx服务器下phalcon环境搭建方法详解
本文URL:https://www.cdcxhl.com/article30/chcgso.html

成都网站建设公司_创新互联,为您提供域名注册网站营销网站内链网站收录企业网站制作品牌网站设计

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

搜索引擎优化