首页  >  文章  >  后端开发  >  php7.0 + phalcon 安装配置

php7.0 + phalcon 安装配置

不言
不言原创
2018-04-26 14:42:052461浏览

本篇文章介绍的是关于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 'e2d0e752df2c971bca1fcef6e50119b4' >/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 安装配置的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn