Demo module for Phwoolcon

Installs: 58

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 1

Open Issues: 0

Language:JavaScript

dev-master / 1.0.x-dev 2017-08-28 10:53 UTC

This package is auto-updated.

Last update: 2024-10-29 04:47:25 UTC


README

Installation

Let's take the installation on Ubuntu as an example.

1. Install php7

add-apt-repository ppa:ondrej/php
apt update
apt install php7.0-fpm php7.0-gd php7.0-cli php7.0-curl php7.0-dev php7.0-json php7.0-mbstring php7.0-mysql php7.0-xml php7.0-zip php-redis

2. Install phalcon

curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh | bash
apt install php7.0-phalcon

3. Install swoole

pecl install swoole
echo 'extension = swoole.so' > /etc/php/7.0/mods-available/swoole.ini
ln -s /etc/php/7.0/mods-available/swoole.ini /etc/php/7.0/cli/conf.d/20-swoole.ini
ln -s /etc/php/7.0/mods-available/swoole.ini /etc/php/7.0/fpm/conf.d/20-swoole.ini

4. Install composer

wget -c https://getcomposer.org/composer.phar -O /usr/bin/composer
chmod +x /usr/bin/composer

5. Install nginx

add-apt-repository ppa:nginx/stable
apt update
apt install nginx

5.1. Add nginx upstream php7

vim /etc/nginx/conf.d/upstream.conf
upstream php7 {
    #this should match value of "listen" directive in php-fpm pool
    server unix:/run/php/php7.0-fpm.sock;
}

5.2. Configure nginx entrance

vim /etc/nginx/sites-available/yoursite.dev
map $http_x_forwarded_proto $frontend_https {
    default '';
    https on;
}

server {
    listen 80;
    server_name     yoursite.dev;
    root /srv/http/yoursite.dev/public;
    index  index.php index.html index.htm;

    access_log off;
    error_log /var/log/nginx/yoursite.dev_error.log;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass php7;
        access_log /var/log/nginx/yoursite.dev_access.log;
        fastcgi_param USE_SERVICE 1;
        fastcgi_param HTTPS $frontend_https;
    }

    location ~ /^\. { deny all; }

    location ~* \.(js|css|swf|eot|ttf|otf|woff|woff2)$ {
        add_header 'Cache-Control' 'public';
        add_header 'X-Frame-Options' 'ALLOW-FROM *';
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
        expires +1w;
    }
}

5.3. Enable site entrance

ln -s /etc/nginx/sites-available/yoursite.dev /etc/nginx/sites-enabled/yoursite.dev
nginx -t
nginx -s reload

6. Install Phwoolcon framework

cd /srv/http
git clone git@github.com:phwoolcon/bootstrap.git yoursite.dev

7. Install phwoolcon/demo

cd yoursite.dev
bin/import-package phwoolcon/demo
composer update

8. Install MySQL

apt install mysql-server-5.7 mysql-client-5.7

8.1. Create database and DB user

mysql -uroot -p
create database your_db_name;
GRANT ALL PRIVILEGES ON your_db_name.*  To 'your_db_user'@'%' IDENTIFIED BY 'your_db_pass';

9. Modify project configurations

vim app/config/production/database.php
<?php
return [
    'default' => 'mysql',
    'connections' => [
        'mysql' => [
            'host'       => '127.0.0.1',    // Use real server
            'username'   => 'your_db_user', // Use real username
            'password'   => 'your_db_pass', // Use real password
            'dbname'     => 'your_db_name', // Use real db name
        ],
    ],
    'distributed' => [
        'node_id' => '001',
    ],
    'query_log' => false,
];
vim app/config/production/payment.php
<?php
return [
    'gateways' => [
        'alipay' => [
            // Fill real merchant info here
            'partner' => 'PARTNER_ID',
            'seller_id' => 'seller@phwoolcon.com',
            'private_key' => '-----BEGIN RSA PRIVATE KEY-----
YOUR_PRIVATE_KEY_HERE
-----END RSA PRIVATE KEY-----',
            'ali_public_key' => '-----BEGIN PUBLIC KEY-----
ALI_PUBLIC_KEY_HERE
-----END PUBLIC KEY-----',
        ],
    ],
];

10. Install project DB stuff

bin/dump-autoload
bin/cli migrate:up
bin/dump-autoload