a day to write, a day to change

Latest

Installing moodle 2

I use this tutorial : https://docs.moodle.org/26/en/Step-by-step_Installation_Guide_for_Ubuntu and jump to step 4.

On step 7, after chmod -R 777 /var/www/moodle, you have to open http://<your-ip>/moodle on browser for next installation.

i’ve got this error

server-checks-php5-curl

showing that you don’t have php5-curl, php5-xmlrpc, and php5-intl. Do apt-get install php5-curl php5-xmlrpc php5-intl.

I skip for opcache-enable and click next. moodle-server-min-requirements

and moodle will automatically install all modules moodle-install-all-modules-success

Run to next step on  https://docs.moodle.org/26/en/Step-by-step_Installation_Guide_for_Ubuntu, Database setting and continue to Suggestions: Enable Zend OpCache/Change Document Root.

moodle-after-instal

Moodle is somehow slow, you can use php cache and mysql tuning suggestion on http://moodurian.blogspot.com/2011/07/how-i-speeded-up-my-moodle-site.html.

Basicly you can use : https://raw.github.com/major/MySQLTuner-perl/master/mysqltuner.pl for mysql tuning. It will give you some good recomendation to my.cnf.

and : apt-get install php-apc

to cache everything.

Basic installation nginx+php5-fpm+yii

As a reference I use tutorial from rosehosting.

  • apt-get update
  • apt-get install nginx
  • Open your browser, http://localhost and you can see nginx welcome page.
  • apt-get install php5-fpm php5-cli php5-mcrypt php5-gd // I ignore install mysql, planned doing later
  • Modify /etc/php5/fpm/php.ini just like on tutorial.
  • Modify nginx conf. nano /etc/nginx/sites-available/default, replace inside server{}

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;
index index.html index.htm;

# Make site accessible from http://localhost/
server_name localhost;
set $yii_bootstrap “index.php”;
charset utf-8;

location / {
index index.html $yii_bootstrap
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /$yii_bootstrap?args;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}

location ~ ^/(protected|framework|themes/\w+/views) {
deny  all;
}

location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}

location ~ \.php {
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

location ~ /\. {
deny all;
access_log off;
log_not_found off;
}

}

Playing yowsup2 and whatsapi

This yowsup2 installation requirement is valid. But I found I had to apt-get install python2.7-dev too, before I can pip install Pillow. Next you can register your number using yowsup-cli. Now test send messages using this command yowsup-cli demos -c -y. Type /help for all command and /L to quick login. Type /message send <number-to> <your-message-here>.

WhatsAPI is more easy to install but I wanna share simple .php test. First git clone the source from github to your /var/www/, and after downloaded, place this php file on /var/www/WhatsApi-Official/.

<?php
require 'src/whatsprot.class.php';
require 'src/events/MyEvents.php';
$username = "your-phone-number ex.62811987654";
$identity = "your-phone-number";
$nickname = "your-phone-number";
$password = "your-password"; // The one we got registering the number
$debug = true;

// Create a instance of WhastPort.
$w = new WhatsProt($username, $identity, $nickname, $debug);
connect(); // Connect to WhatsApp network
$w->loginWithPassword($password); // logging in with the password we got!

//Send Messages
$target = ‘to-phone-number'; // The number of the person you are sending the message ex.6285798766543
$message = ‘Hi! :) this is a test message';
$w->sendMessage($target , $message);

//Receive Messages
$events = new MyEvents($w);
$events->setEventsToListenFor($events->activeEvents);
$w->pollMessage();
?>

PostgreSQL 9.3 : Create dblink

After read this post from Mr. , I wanna add some detail only on creating dblink :

  1. First change your pg_hba.conf : host all all 127.0.0.1/32 trust
  2. Create dblink : SELECT dblink_connect(‘<dblink-name>’,’dbname=<postgres-dbname> port=<postgres-port> user=<postgres-username> password=<postgres-password>’);//it should return OK 
  3. Test it :
    SELECT *
    FROM dblink(‘<dblink-name>’,’select id,name from emp’)
    AS zone( id int,name varchar);

Install Mono 3.4.1 on Ubuntu Server 12.04 64bit

Right after this tutorial, I wanna try to install mono 3.4 that have .net 4.5 luxury on my Ubuntu Server.

1. Go to https://github.com/mono/mono, I try the c option. Building the software from Git.

2. Make sure you have git : sudo apt-get install git automake.

3. git clone git://github.com/mono/mono.git. Be passion, it takes long to download all mono source.

4. Go into mono directory: cd mono.

5. I have an error that I don’t have libtool package after running this  :

./autogen.sh –prefix=/usr/local

So, from this tutorial, I have to install it first :

apt-get install libtool automake autoconf autotools-dev

6. ./autogen.sh –prefix=/usr/local

7. make install

8. Check installed mono version : mono –version

Image

9. Done!. Deploy your .net 4.5 apps.

 

Install MonoDevelop 5.1 on fresh Ubuntu 14.04 LTS 64bit

I use davidloo tutorial and I wanna add some point from my experience.

1. sudo apt-get install git automake gnome-sharp2 mono-xsp4

2. git clone https://github.com/mono/monodevelop.git

3. cd monodevelop

4. ./configure –profile=stable

At this point I have error “No package ‘glade-sharp-2.0′ found.” and with ‘monodoc’ package.

The solution is to install that packages from synaptic. 

apt-get install synaptic

Check this on synaptic and click Apply :

Image

Image

 

And run configure again.

4. ./configure –profile=stable

5. sudo make install

And now you have MonoDevelop 5.1 and .net 4.5.

Image

 

Deploying Oracle Application using ODP.Net on Win7 32 bit

1. Login as administrator

2. Image Download ODAC XCopy Version 32 bit.

3. Image Unzip the packages.

4. Image Open cmd and Run as administrator.

5. Image  Go to unpackage ODAC folder. Type “install.bat all c:\oracle myhome” on command-prompt.

6. Image Create new Value on Path Environment Variables “c:\oracle;c:\oracle\bin”.

7. Done!.

Add SoapHeader to php-wsdl-2.3

1. Add this function to class.soapdemo.php

Snap 2014-05-12 at 14.28.31

 

2. Edit overridden method __Call on SoapDemoSoapClient.php to add SoapHeader :

Snap 2014-05-12 at 14.30.23

 

Done!.

 

PHP Webservice using php-wsdl-2.3

I want some alternative deploying soap web service on linux.
While there’s solution on .Net like ServiceStack, It’s difficult to deploy it on Linux using Nginx and fast-cgi.
So I’m googling php alternative. It’s in https://code.google.com/p/php-wsdl-creator/. And it’s damn easy.
1. After download it, put it in your var/www or xampp htdocs.
2. Change CreateInstance parameter demo.php code :
Snap 2014-05-12 at 14.18.26
3. Run it :
 Snap 2014-05-12 at 14.22.00
 
or just http://localhost:82/phpwsdl23/demo.php to see the description.
4. You can acces it using soapui, or .net service reference, or using php http://localhost:82/phpwsdl23/demo.php?PHPSOAPCLIENT.
Snap 2014-05-12 at 14.24.52

How to pg_dump

e:\Program\PostgreSQL\9.2\bin>pg_dump –file=your-path-file-to-dump-data -s -U <user-name> <database-name>

Follow

Get every new post delivered to your Inbox.

Join 27 other followers