本文實(shí)例講述了centos7系統(tǒng)nginx服務(wù)器下phalcon環(huán)境搭建方法。分享給大家供大家參考,具體如下:
之前我們采用的是Apache服務(wù)器,可是每秒響應(yīng)只能達(dá)到2000,聽說nginx可以輕易破萬,
于是換成nginx試試。
phalcon的官網(wǎng)有nginx重寫規(guī)則的示例,可是卻與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官網(wǎng)上是public目錄,如果用這個(gè)目錄就和apache的配置不一樣了 index index.php index.html index.htm; # 如果文件存在就直接返回這個(gè)文件 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
進(jìn)一步的優(yōu)化且待之后的情況
希望本文所述對大家centos服務(wù)器操作有所幫助。
標(biāo)簽:上海 安康 鷹潭 德宏 泰安 淮安 福州 樂山
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《centos7系統(tǒng)nginx服務(wù)器下phalcon環(huán)境搭建方法詳解》,本文關(guān)鍵詞 centos7,系統(tǒng),nginx,服務(wù)器,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。