centos7系統nginx下phalcon環境搭建


之前我們采用的是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
進一步的優化且待之后的情況





免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM