当前位置:Gxlcms > PHP教程 > php7.0+phalcon安装配置

php7.0+phalcon安装配置

时间:2021-07-01 10:21:17 帮助过:9人阅读

本篇文章介绍的是关于php7.0 + phalcon 安装配置,现在分享给大家,有需要的朋友可以看一看


php7.0 + phalcon 安装配置


一、安装lnmp环境

1.1 更新阿里源

Ubuntu默认使用的是国外的源,将其替换成国内的阿里的源,脚本

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

sudo sh -c 'cat /etc/apt/sources.list.bak | egrep -v"#|^$" | sed "s/hk.archive.ubuntu.com/mirrors.aliyun.com/g">/etc/apt/sources.list'

sudo apt-get update

1.2 安装mysql

sudo apt-get install mysql-client mysql-server –y

密码默认为password

1.3 安装nginx

sudo apt-get install nginx-full -y

1.4 安装PHP7.0 和phalcon 等扩展

参考链接https://docs.phalconphp.com/zh/latest/reference/install.html

参考链接https://docs.phalconphp.com/zh/latest/reference/nginx.html

1) 安装PHP

sudo apt-getinstall php7.0* -y

生成phalcon框架的apt源

curl -shttps://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh |sudo bash

2) 安装phalcon 框架

sudo apt-getinstall php7.0-phalcon –y

3) 安装phalcon 扩展工具

cd ~

git clone https://github.com/phalcon/phalcon-devtools.git

sudo ln -s ~/phalcon-devtools/phalcon.php /usr/bin/phalcon

sudo chmod +x /usr/bin/phalcon

删除不兼容的php7.0-snmp 的包

测试工具是否正常

jifan@ubuntu:~$phalcon --help

PhalconDevTools (3.1.2)

Availablecommands:

info (alias of: i)

commands (alias of: list, enumerate)

controller (alias of: create-controller)

module (alias of: create-module)

model (alias of: create-model)

all-models (alias of: create-all-models)

project (alias of: create-project)

scaffold (alias of: create-scaffold)

migration (alias of: create-migration)

webtools (alias of: create-webtools)

console (alias of: shell, psysh)

jifan@ubuntu:~$

显示正常

二、配置nginx+php-fpm

2.1 配置nginx

移除默认的配置

sudo mv/etc/nginx/sites-available/default /etc/nginx/sites-available/default.bak

添加新的nginx配置

cd /etc/nginx/conf.d

编辑一个新文件zktx.conf

sudo vim zktx.conf

将如下内容复制进去:

server {
    listen     80 default;
    server_name localhost.dev;
    root       /var/www/phalcon/public;
    index      index.php index.html index.htm;
    charset    utf-8;
 
    location / {
        try_files $uri $uri//index.php?_url=$uri&$args;
    }
 
    location ~ \.php {
        fastcgi_pass  unix:/run/php/php7.0-fpm.sock;
        fastcgi_index /index.php;
 
        include fastcgi_params;
        fastcgi_split_path_info       ^(.+\.php)(/.+)$;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name;
    }
 
    location ~ /\.ht {
        deny all;
    }
}

创建默认目录mkdir -p root /var/www/phalcon/public;

2.2 添加一个phpinfo的文件

sudo sh -c "echo '<?php phpinfo(); ?>' >/var/www/phalcon/public/index.php"

2.3 启动

sudo service nginx restart

sudo service php-fpm restart

2.4 测试

成功:


2.5 开机自起

编辑/etc/rc.local文件,配置如下:

#!/bin/sh-e

#

#rc.local

#

# Thisscript is executed at the end of each multiuser runlevel.

# Makesure that the script will "exit 0" on success or any other

# valueon error.

#

# Inorder to enable or disable this script just change the execution

# bits.

#

# Bydefault this script does nothing.

/etc/init.d/nginxstart

/etc/init.d/php7.0-fpmstart

exit 0

相关推荐:

php和Apache安装配置实例分享

Mysql5.7.17之winx64.zip解压缩版安装配置图文教程

以上就是php7.0 + phalcon 安装配置的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行