Yii2

Ref: https://www.yiiframework.com/
https://www.yiiframework.com/doc/guide/2.0/en/start-installation

How to install Yii PHP Framework on Debian 9 and Ubuntu 18.04?

Create a Yii2 project ‘yii2-kickstart’ via composer:

Go to the project dir then modify composer.json to add ‘replace’ like this:

If I don’t do this, i’ll get this error:

Then run ‘composer update’
Then run ‘php yii serve’. it’ll use port 8080
If the port 8080 is already used, you can use another port like 888:

Then open it on your browser: http://localhost:8888/
BUT I GOT THIS ERROR ON THE PAGE

SO I REMOVE ‘replace’ AND THE VALUES IN {} IN composer.json
Then run ‘composer update’ again.
Start the server again: php yii serve –port=8888
Open it on the browser: http://localhost:8888/
NOW IT’S WORKING FINE!

WordPress and Woocommerce

WordPress and Woocommerce

Download the latest from wordpress.org. I got version 5.2.3

SETUP LOCAL WITH NGINX

content:

  • Enable file config
  • Register the host on my system

    Like this:
  • CHECK THE NGINX SETTING AND RESTART IT:

CREATE A NEW DATABASE: wp523_commerce COLLATION utf8_general_ci
Open it on your browser and install : http://wp523_commerce.test
setting:
username: admin
password: xA**EbXJ4UNw96u0wI

Download theme ‘futurio’ from https://futuriowp.com/free-woocommerce-theme/
then extract and put it in theme dir. install
Then download plugin futurio extra from https://wordpress.org/plugins/futurio-extra/
Then download plugin wordpress-importer from https://wordpress.org/plugins/wordpress-importer/
Then download plugin elementor from https://wordpress.org/plugins/elementor/
Then download plugin WooCommerce
from https://wordpress.org/plugins/woocommerce/
Then download plugin Ajax Search for WooCommerce
from https://wordpress.org/plugins/ajax-search-for-woocommerce/
extract and put these plugins into plugins dir then install

Then download the sample data from https://futuriowp.com/docs/futurio/importing-the-sample-data/. Follow the instructions to import the sample data. NOTE: I can’t import the data from the local site. I have to import it manually!

TEST: http://wp523_commerce.test
ADMIN: http://wp523_commerce.test/wp-admin
WOOCOMMERCE SHOP: http://wp523_commerce.test/shop

Laravel and Swoole

Ref: https://github.com/huang-yi/laravel-swoole-http
My setting:

 

Create a laravel project. I tried version 6.x but I can’t use ‘laravel-swoole-http’ so I installed version 5.6.x

Then go to the dir ‘laravel-swoole’ then install laravel-swoole-http’ with ‘composer require huang-yi/laravel-swoole-http’

then register/publish the swoole service

then start swoole server

open it on your browser: http://127.0.0.1:1215/
the setting in laravel-swoole/config/swoole.php like host (localhost), port (1215), etc
TO stop the swoole server:

ANOTHER ACTIVE LARAVEL SWOOLE (laravel-swooletw)
https://github.com/swooletw/laravel-swoole
PLS READ https://github.com/swooletw/laravel-swoole/wiki
Create a laravel project. I installed version 5.6.x

Then go to the dir ‘laravel-swooletw’ then install laravel-swoole’ with ‘composer require swooletw/laravel-swoole’

from https://github.com/swooletw/laravel-swoole/wiki/4.-Installation,I need to register the swoole service provider in config/app.php

Then need to publish the configuration

Then run the server :

open it on your browser: http://localhost:1215/

ANOTHER LARAVEL – SWOOLE IS
https://github.com/hhxsv5/laravel-s
I download for auction app from https://github.com/GallopYD/domain-spider
STEPS:

CREATE A .env file:

CREATE A NEW DATABASE ‘laravel_auction_swoole’ COLLATION : utf8mb4_unicode_ci
RUN

READ https://github.com/hhxsv5/laravel-s
PUBLISH

START SERVER

OPEN IT ON THE BROWSER : http://localhost:5200/

 

 

Swoolec Loader

Use PHP7.3
Install it if not exist

Use php7.3 as default php

Check

TO ENABLE PHP 7.3 ON NGINX SERVER, PLS DO (MAKE SURE APACHE2 IS STOPPED IF IT’S RUNNING AND START NGINX):

IMPORTANT! ALSO NEED TO INSTALL php7.3-dev. THIS IS NEEDED WHEN I NEED TO COMPILE swoole SOURCE

CHECK php-config SOULD POINT TO php7.3

THE NGINX MAIN CONFIG IN /etc/nginx/nginx.conf
THE DEFAULT VIRTUALHOST IN /etc/nginx/sites-available/default
EDIT IT TO ENABLE PARSING PHP FILE:

Use php7.3-fpm for fastcgi_pass

THEN CHANGE PHP7.3-FPM SETTING:

CHANGE THE CONTENT:

THEN RESTART PHP7.3-FPM SERVICE:

CHECK NGINX SYNTAX: sudo nginx -t
RESTART NGINX: sudo service nginx restart
OPEN IT: http://localhost:8080/phpinfo.php (NEED TO CLEAR THE BROWSER CACHE FIRST)

INSTALL swoole FOR PHP7.3
IF YOU ALREADY INSTALLED IT FOR PHP7.2, YOU NEED TO REMOVE/UNINSTALL IT.
NOTE: TO UNINSTAL IT, USE PHP7.2 VERSION ON TERMINAL NOT PHP7.3
FIRST COMMENT IT from the cli php.ini and php-fpm php.ini files.

THEN

THEN DO THE SAME FOR php-fpm php.ini file (sudo gedit /etc/php/7.2/fpm/php.ini).
USE pecl TO UNINSTALL IT

NOTE: IT’S ALSO IMPORTANT TO DELETE/REMOVE swoole.so FILE IN /usr/lib/php/20170718/swoole.so MANUALLY. BECAUSE PHP7.3 USE EXTENSION DIR IN /usr/lib/php/20180731, MAKE SURE IF ALREADY EXIST swoole.so IN IT. REMOVE IT MANUALLY AS WELL!
NOTE: I TRIED TO INSTALL swoole 4.4.5 FROM SOURCE & COMPILE IT (READ: https://github.com/swoole/swoole-src) BUT ALWAYS FAILED AND GOT THIS ERROR

I THINK THIS IS BECAUSE I MIXED THE INSTALLATION (FROM pecl AND FROM SOURCE) THEN FORGOT TO INSTALL php7.3-dev AND FORGOT TO REMOVE swoole.so MANUALLY IN /usr/lib/php/20180731/swoole.so

THEN INSTALL SWOOLE ON PHP7.3 TERMINAL
MAKE SURE THE PHP API VERSION FOR PHP7.3 IS ‘20180731’ NOT ‘20170718’

Then include the extension “extension=swoole.so” in php.ini file. For php-fpm, the php.ini file in “/etc/php/7.3/fpm/php.ini”

then add this new line:

Save then restart php7.3-fpm service

look it up phpinfo() result. It should show like this:THEN IN CLI

ADD loader73.so FILE.
Copy it manually (USE SUDO) TO php7.3 EXTENSION DIR (IN /usr/lib/php/20180731)

THEN ADD THE EXTENSION ‘loader73.so’ IN php.ini FILE. For php-fpm, the php.ini file in “/etc/php/7.3/fpm/php.ini”

THEN ADD:

PLS DO THE SAME IN php.ini FOR CLI IN /etc/php/7.3/cli/php.ini
THEN RESTART php7.3-fpm SERVICE

CHECK THE EXTENSION IN phpinfo (http://localhost:8080/phpinfo.php)
IT SHOULD SHOW LIKE THISCHECK IN CLI

WE ALSO NEED TO DISABLE xdebug EXTENSION. CHECK IF xdebug IS ENABLED

THEN I NEED TO DISABLE IT.

THEN DISABLE xdebug BY ADDING ‘;’ IN FRONT OF THE LINE LIKE THIS:

THEN RESTART php7.3-fpm SERVICE

MAKE THERE IS NO MORE WARNING ABOUT xdebug

SAMPLE FILES IN /home/teddy/Downloads/Ptcms_V4.2.8 DIR
IN THE DIR, COPY ‘env.example.php’ TO ‘env.php’ FILE
RUN FROM TERMINAL

THEN I GOT ERROR ABOUT MEMCACHE

MAKE SURE memcached SERVICE IS RUNNING

OR

ALSO CHECK IF memcached EXTENSION IS INSTALLED

IF THERE IS NO OUTPUT, THEN INSTALL IT (REF: https://serverpilot.io/docs/how-to-install-the-php-memcache-extension)

HERE IS THE PROCESS

THEN MODIFY /etc/php/7.3/fpm/php.ini AND /etc/php/7.3/cli/php.ini FILE THEN ADD THE EXTENSION extension=memcached.so
THEN RESTART THE SERVICES

 

Install Swoole on Ubuntu 16.04

Ref: https://github.com/swoole/swoole-docs/blob/master/get-started/installation.md
Install from pecl

Then include the extension “extension=swoole.so” in php.ini file. For php-fpm, the php.ini file in “/etc/php/7.2/fpm/php.ini”

then add this new line:

Save then restart php7.2-fpm service

look it up phpinfo() result. It should show like this:Pls do the same thing for php cli. the php.ini file for php cli in “/etc/php/7.2/cli/php.ini”. So edit the file and add a new line for the extension “extension=swoole.so”. Check the extension is loaded on the terminal:

Note: I tried to do this via terminal

But it didn’t work. The extension is not loaded so I put it manually in the php.ini for cli.
NOTE: IT NEED TO DISABLE ‘xdebug’ EXTENSION. CHECK IF xdebug IS ACTIVE/ENABLED:

IF IT IS ENABLED, THEN MODIFY ‘/etc/php/7.2/cli/conf.d/20-xdebug.ini’ FILE TO DISABLE xdebug BY ADDING ‘;’ IN FRONT OF THE LINE LIKE THIS:

IF xdebug IS ENABLED WHEN THE SERVER IS RUNNING, IT’D SPIT THIS WARNING:

TEST SWOOLE
ref: https://github.com/swoole/swoole-docs/blob/master/get-started/examples/tcp_server.md
Create a new file server.php

Run the php in a terminal

then open another terminal and type ‘telnet 127.0.0.1 9501’

The first terminal would print ‘Client : Connect’

You can connect with another new terminal.
To close the connection in the second terminal, press Ctrl + ] then type close in telnet>

The first terminal would give response like this:

Create web server
ref: https://github.com/swoole/swoole-docs/blob/master/get-started/examples/http_server.md
create a new file ‘http_server.php’

then run the server via terminal

Open it via web browser: http://127.0.0.1:9503/
It should show this message:

 

Install Microsoft Sql Server 2017 And The PHP Extension On Ubuntu 16.04

Ref: https://www.microsoft.com/en-us/sql-server/developer-get-started/php/ubuntu

1. Register the Microsoft Linux repositories and add their keys.
Note: it’d be better to use ‘sudo su’ first!

2. Install SQL Server.
NOTE: I USE ‘sudo apt-get install mssql-server=14.0.3192.2-2’ INSTEAD OF ‘sudo apt-get install mssql-server’ BECAUSE I GOT AN ERROR FOR SQLCMD ‘Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2746.’
REF: https://stackoverflow.com/questions/57265913/error-tcp-provider-error-code-0x2746-during-the-sql-setup-in-linux-through-te

3. Setup your SQL Server.
Note: I choose ‘Developer’ edition.

SORRY, ONLY ADMIN CAN SHOW THIS!
Check the mssql-server service status

NOTE: ERROR LOG IN /var/opt/mssql/log/error
MUST OPEN THE DIR WITH ‘sudo su’
4. Install the ODBC Driver and SQL Command Line Utility for SQL Server (SQLCMD)

After installing SQLCMD, you can connect to SQL Server using the following command: sqlcmd -S localhost -U sa -P Yourpassword
SORRY, ONLY ADMIN CAN SHOW THIS!

Install the PHP Driver for SQL Server

THEN

THEN

NOTE: IT’D COPY THE FILES ’20-sqlsrv.ini’ AND ’30-pdo_sqlsrv.ini’ TO DIR /etc/php/7.2/cli/conf.d/
THEN
MODIFY ‘php.ini’ file for php7.2 fpm and (cli NO NEED???)

THEN INSERT THESE TWO LINES:

NO NEED –>PLS DO THE SAME FOR ‘cli’: sudo gedit /etc/php/7.2/cli/php.ini

THEN COPY THE TWO INI FILES FROM ‘cli’ TO ‘fpm’

THEN RESTART PHP FPM

CHECK THEM IN phpinfo: http://localhost:8080/phpinfo.php

Create a database ‘SampleDB’ for your application

The DB will be exist in /var/opt/mssql/data/SampleDB.mdf and the log file.

Create a PHP app that connects to SQL Server and executes queries

Create a new file ‘connect.php’

RUN ON CLI:

NOTE: ON CLI I GOT THIS WARNING:

SOLUTION: REMOVE/COMMENT THE EXTENSIONS ‘sqlsvr’ AND ‘pdo_sqlsvr’ IN /etc/php/7.2/cli/php.ini FILES!
CHECK THE LOADED MODULE WITH: php -m
IT SHOULD BE ALREADY LOADED FOR CLI SO NO NEED TO INCLUDE THEM IN CLI php.ini BUT IT NEED TO INCLUDE FOR FPM php.ini !

ALSO RUN VIA WEB: http://localhost:8080/works/SqlServerSample/connect.php

 

UNINSTALL MS SQL SERVER
REF: https://dba.stackexchange.com/questions/174175/how-do-i-totally-remove-sql-server-2017-on-ubuntu

Uninstalling SQL Server on Ubuntu

 

Moodle

Download opencart from https://www.moodle.org
Then extract it in your root web directory
Read INSTALL.txt file to setup and install moodle

Setup with Nginx

Here is the content

NOTE: Pay attention on these lines

I HAVE TO PUT THEM THERE. IF NOT, I’D GET SESSION PROBLEM AND THE STATIC FILES (JS AND CSS) PATH WOULD NOT BE RECOGNIZED
REF: https://www.sudutbaca.com/cara-install-moodle-di-debian-9-menggunakan-nginx-mariadb-php7-2-fpm/

XXXdon’t forget to create the log file in var/log/system.log
Then

Then

Insert this line:

Then check the nginx config and restart nginx

Set the files owner

Open it on your browser http://moodle.test. For the first time, it’ll install Moodle.

Note: Create a new database ‘moodle’ with collation ‘utf8mb4_general_ci’
I THINK I ALSO NEED TO CHANGE (NOT SURE) config.php THEN ADD THESE NEW LINES

 

Admin:
SORRY, ONLY ADMIN CAN SHOW THIS!
Admin page: http://moodle.test/my/

OpenCart 3

Download opencart from https://www.opencart.com
Then extract it in your root web directory
Read install.txt file to setup and install opencart

Set the file permissions

 

Setup with Nginx

Here is the content

NOTE: don’t forget to create the log file in var/log/system.log
Then

Then

Insert this line:

Then check the nginx config and restart nginx

Set the files owner

Open it on your browser http://opencart3.test. For the first time, it’ll install OpenCart.
Note: Create a new database ‘opencart3’ with collation utf8-general-ci
Admin:
SORRY, ONLY ADMIN CAN SHOW THIS!
Then follow the instructions
NOTE: I also need to change the PHP setting in php.ini (IN THE opencart DIR). Change some settings like

admin url: http://opencart3.test/admin

opencart version 3.0.3.2 (/home/teddy/Documents/works/opencart-3.0.3.2/upload/index.php)

Create Apache2 Setting
CREATE A CONF

CONTENT

ENABLE THE VIRTUALHOST

RELOAD APACHE2

CREATE THE HOST

RELOAD APACHE2

RENAME config-dist.php AND admin/config-dist.php TO config.php TO admin/config.php
SET THE FILE PERMISSIONS & RELOAD APACHE2

Open: http://opencart3.test

SORRY, ONLY ADMIN CAN SHOW THIS!

Sylius Standard Edition

READ: https://sylius.com/download/
Make sure to use PHP 7.2
Download via composer and create a new app ‘sylius-app’

go to the app directory

Install!
NOTE: make sure the ‘timezone’ variable for PHP is already set! if not, You’d get this error ‘timezone | ERROR!’. Check the variable in /etc/php/7.2/cli/php.ini file. Set like this (for example): date.timezone = Asia/Jakarta
NOTE: Make sure to create a new file for override the default env. the new file is ‘.env.local’. (ref: https://docs.sylius.com/en/1.5/book/installation/installation.html)
I want this app stores file in ‘sylius_app’ database. So here is the file content

Change the parameters like username, password, etc to fit your system.
SORRY, ONLY ADMIN CAN SHOW THIS!
Then run the install command

My settings:
SORRY, ONLY ADMIN CAN SHOW THIS!

Install Assets

Then run gulp to build the frontend

Run the cli server

Open it on your browser: http://localhost:8000
Here is the screenshotsAdmin login: http://localhost:8000/admin/login

SORRY, ONLY ADMIN CAN SHOW THIS!
Here is the admin dashboardMODIFICATION
CREATE A NEW ROUTE AND CONTROLLER
READ: https://alanstorm.com/symfonys-service-container/
MODIFY THE ROUTE IN config/routes.yaml

THEN CREATE A CONTROLLER IN src/MyControllers/Advcha/HelloWorldController.php

 

Setup Postfix on Ubuntu 16.04 Localhost and Use Gmail SMTP

READ: https://devanswers.co/configure-postfix-to-use-gmail-smtp-on-ubuntu-16-04-digitalocean-droplet/

Prerequisites
If your Gmail account uses 2-Step Verification, you must create an application specific password.

If you’re not using 2-Step Verification, please ensure that your Gmail account is configured to allow less secures apps.

Remove sendmail

1. Install Postfix

Let’s update the package database first. On the first Postfix configuration screen, select OK by pressing TAB and ENTER. Select Internet Site and press ENTER. System mail name should be your domain name eg. example.com, press ENTER.
My mail name is teddy@teddy.localdomain
<NOTE>
PROBABLY THESE BELOW COMMAND NOT NEEDED:
I also need to install php-mail and php7.2-mail

modify php ini IN

OR FOR APACHE2 WEB SERVER

UNCOMMENT ‘sendmail_path’ THEN CHANGE TO

modify

like this:

Restart services

OR FOR APACHE2 WEB SERVER

</NOTE>

Configure Postfix
Edit the Postfix configuration file.

Add the following to the end of the file.

Save file and exit.

Create Password and DB Files
Create the sasl_passwd file which will store our credentials.

Insert the following:

SORRY, ONLY ADMIN CAN SHOW THIS!
Replace username and password with your own. Save file and exit. (Press CTRL + X, press Y and then press ENTER)

Create a hash database file for Postfix with the postmap command.

There should now be a file called sasl_passwd.db in the /etc/postfix/ directory.

For added security, we will only allow root user to read and write to sasl_passwd and sasl_passwd.db

Sign Certificate
Now we are going to create the certificate.

There should now be a certificate file called cacert.pem in /etc/postfix

Send a Test Mail
We’ll now send a test email message. Make sure to replace test@example.com with your own email address.

Don’t forget to check your spam folder.

If you still haven’t received any mail, check the mail error log.

NOTE:
TO USE GMAIL SMPT, YOU NEED TO ACTIVATE (SET IT ON) ‘Less Secure app’ ON YOUR GMAIL ACCOUNT. LOGIN TO YOUR GMAIL THEN OPEN THIS LINK: https://www.google.com/settings/u/2/security/lesssecureapps
IT’D REDIRECT YOU THE ‘Less Secure app’ SETTING.