lunedì 9 novembre 2015

Elementary Os - Enlarge the Virtual Machine’s Partition


http://elementaryos.org/

sudo apt-get install virtualbox-guest-utils virtualbox-guest-x11 virtualbox-guest-dkms

Enlarge disk 

VBoxManage modifyhd “C:\Users\Chris\VirtualBox VMs\Windows 7\Windows 7.vdi” –resize 81920

ESEMPIO:

VBoxManage modifyhd Elementary.vdi --resize 15360


Enlarge the Virtual Machine’s Partition

You now have a larger virtual hard disk. However, the operating system’s partition on your virtual hard disk is the same size, so you won’t be able to access any of this space yet.
image
You’ll now need to extend the guest operating system’s partition as if you were enlarging a partition on a real hard disk in a physical computer. You can’t enlarge the partition while the guest operating system is running, just as you can’t enlarge your C:\ partition while Windows is running on your computer.
You can use a GParted live CD to resize your virtual machine’s partition – simply boot the GParted ISO image in your virtual machine and you’ll be taken to the GParted partition editor in a live Linux environment. GParted will be able to enlarge the partition on the virtual hard disk.
Load the ISO file into your virtual machine by going into the virtual machine’s settings window, selecting your virtual CD drive, and browsing to the ISO file on your computer.
image
Boot (or restart) your virtual machine after inserting the ISO image and the virtual machine will boot from the ISO image. GParted’s live CD will ask you several questions while booting – you can press Enter to skip them for the default options.
Once GParted is booted, right-click the partition you want to enlarge and select Resize/Move.
image
Specify a new size for the partition – for example, drag the slider all the way to the right to use all the available space for the partition. Click the Resize/Move button after you’ve specified the space you want to use.
image
Finally, click the Apply button to apply your changes and enlarge the partition.
image
After the resize operation completes, restart your virtual machine and remove the GParted ISO file. Windows will check the file system in your virtual machine to ensure it’s working properly — don’t interrupt this check.
image
The virtual machine’s partition will now take up the entire virtual hard disk, so you’ll have access to the additional space.

venerdì 22 maggio 2015

Transferring large binary data with web services


Basic Question :

What is the best way to transfer large files with web services ? Presently we are using the straight forward option to transfer the binary data by converting the binary data into base 64 format and embeding the base 64 encoding into soap envelop itself.
But it slows down the application performance considerably.
Please suggest something for performance improvement.

Quick answer :

Check out MTOM, a W3C standard designed to transfer binary files through SOAP.
From Wikipedia:
MTOM provides a way to send the binary data in its original binary form, avoiding any increase in size due to encoding it in text.
Related resources:




Introduction

Web service has been evolved from simple request-response mechanism to object oriented style support and now large data transfer. 

Large data may be of various types like binary, images, database record export in XML or other format etc. 

Normally, the large data transfer is avoided with the web service however in unavoidable circumstances, if it is required to do; 

you have few options which will be discussed later in the article.
There is couple of big challenges during the large data transfer through web service  

1) How do you make sure that you meet the performance of the application and it should not deteriorate?

2) Memory constraint. Huge files should not be hold in the memory completely.

We’ll discuss these challenges later in the article. Now, let’s discuss the various data transfer strategies/options to transfer the binary data.

Binary data transfer strategies
In the following sections I’ll discuss the various data transfer strategies with their advantages and disadvantages.

1) Embedding the binary data in the SOAP envelop

The straight forward option to transfer the binary data is to convert the binary data into base 64 format and embed the base 64 encoding into soap envelop itself

This approach is also called as “by value” approach as the binary data is embedded in the XML document itself
This approach has following advantages and disadvantages.

Advantages:


  • Simple to use
  • This approach gives applications the ability to process and describe data, based only on the XML component of the data
  • It can be positively considered for small binary data transfer.
Drawbacks of embedding binary large data into soap envelop

1) As binary data is part of soap envelop, it requires large memory to hold it.

2) Base64 encoding increases the size of the binary data by a factor of 1.33x of the original size

3) It slows down the application performance.

Here is the API which can be referred/used for implementation
Implementation API:

Following sections in the article discuss other approaches also called as “by reference approaches” to overcome these issues. Sending binary data by reference is achieved by attaching pure binary data as external unparsed general entities outside the XML document and then embedding reference URIs to those entities as elements or attribute values. This prevents the unnecessary bloating of data and wasting of processing power.

2) FTP or Network files system

One of the good solutions to transfer the large data via web service is to move out the binary large data from the soap envelop and keep only the reference to binary data as a part of soap response.

To implement this approach, the data can be placed either on FTP server or somewhere on shared location on network and the path to data (file) can be given in the web service request or response.
Following section discuss the advantages and disadvantages of this approach.

Advantages

1) Data is not part of the soap envelop so it does not require huge memory to hold it.

2) Since there is no encoding and decoding requires as in case of base 64, it improves the application performance.

3) You can have separate network line dedicated for FTP which can free up normal application network line resulting in performance improvement.

Disadvantages

1) It requires FTP server.
2) Additional maintenance of FTP server
3) Sometime, may not be best suited for small applications.

Here is the API which can be referred/used for implementation
·        


3) Message Transmission Optimization Mechanism (MTOM)

MTOM (SOAP Message Transmission Optimization Mechanism) is another specification that focuses on solving the "Attachments" problem. 

MTOM is actually a "by reference" method. 

The wire format of a MTOM optimized message is the same as the SOAP with Attachments message. The most noticeable feature of MTOM is the use of the XOP:Include element, to reference the binary attachments (external unparsed general entities) of the message. 

With the use of this exclusive element, the attached binary content logically becomes inline (by value) with the SOAP document even though it is actually attached separately. This merges the two realms by making it possible to work only with one data model. On a lighter note, MTOM has standardized the referencing mechanism of SwA. 

The following is an extract from the XOP specification.
At the conceptual level, this binary data can be thought of as being base64-encoded in the XML Document. As this conceptual form might be needed during some processing of the XML document (e.g., for signing the XML document), it is necessary to have a one-to-one correspondence between XML Infosets and XOP Packages. Therefore, the conceptual representation of such binary data is as if it were base64-encoded, using the canonical lexical form of the XML Schema base64Binary datatype. In the reverse direction, XOP is capable of optimizing only base64-encoded Infoset data that is in the canonical lexical form.


The client application sends SOAP Message that contains complex data in Base64Binary encoded format. Base64Binary data type represents arbitrary data (e.g., Images, PDF files, Word Docs) in 65 textual. A sample SOAP Body with Base64Binary encoded element is as follows:

 < mtom:ByteEcho>
 < mtom:data>AVBERi0xLjYNJeLjz9MNCjE+DQpzdGFyNCjEx0YNCg== mtom:data>
mtom:ByteEcho>

An MTOM-aware web services engine detects the presence of Base64Binary data, < mtom:data>in the example, and makes a decision  to convert the Base64Binary data to MIME data withan XML-binary Optimization Package (xop) content type. The data conversion, results inreplacing the Base64Binary data with an element that references the original raw bytes of the document being transmitted. The raw bytes are appended to the SOAP Message and are separated by a MIME boundary as shown below:



  < mtom:ByteEcho>
  < mtom:data> mtom:data>
   mtom:ByteEcho> 
 

--MIMEBoundary000000
content-id: <1.633335845875937500@java.net>
content-type: application/octet-stream
content-transfer-encoding: binary
The raw binary data along with the SOAP Message and the MIME Boundary is send over the wire to the Producer. The Producer then transforms the raw binary data back to Base64Binaryencoding for other processing. This approach has couple of advantages:
Advantages
  1. Effective Transmission: Base64Binary encoded data is ~33% greater than raw bytetransmission using MIME. Therefore MTOM reduces data size by converting Base64Binaryencoding to raw bytes for transmission.
  2. Data is transferred using streaming approach.
Disadvantages/Constraints
  1. HTTP-specific (although it could easily be adapted to other > MIME-based or MIME-like transports)
  2. Detecting MTOM messages for dispatch is additional overhead.
  3. You may not be able use MTOM if all the parties involved in data transfer do not support MTOM specification.
Here is the API which can be referred/used for implementation
Implementation API:
Plain HTTP
One of the big genuine question is why just don’t use the http to post and stream the data. It doesn’t require any soap envelop etc. And the answer is yes this can be done provided you are not looking for any web service related benefits.
Conclusion:
I’ve seen different methods of transferring the binary large data through web service however each method has its own advantages and disadvantages. Now, the question is raised which one is better and answer is: depending upon your application environment, you will have to choose one of the options.
However in my opinion, here is the order of precedence of selection.

1) Use base64 encoding if binary data is very small and it does not substantially impact the performance.
2) Use FTP or network share if binary data is large.
3) Prefer MTOM if all the involved parties in data transfer support the MTOM as it is one of the best way to stream the content.
4) Use plain HTTP if it is just upload/download of the file.


giovedì 14 maggio 2015

How To Install Wordpress on Ubuntu 12.04

About Wordpress

Wordpress is a free and open source website and blogging tool that uses php and MySQL. 

It was created in 2003 and has since then expanded to manage 22% of all the new websites created and has over 20,000 plugins to customize its functionality.

Setup

The steps in this tutorial require the user to have root privileges. You can see how to set that up in the Initial Server Setup.

Before working with wordpress, you need to have LAMP installed on your virtual private server. If you don't have the Linux, Apache, MySQL, PHP stack on your VPS, you can find the tutorial for setting it up in the Ubuntu LAMP tutorial.

Once you have the user and required software, you can start installing wordpress!

Step One—Download WordPress
We can download Wordpress straight from their website:


  • wget http://wordpress.org/latest.tar.gz


This command will download the zipped wordpress package straight to your user's home directory. 

ou can unzip it the the next line:


  • tar -xzvf latest.tar.gz 


Step Two—Create the WordPress Database and User

After we unzip the wordpress files, they will be in a directory called wordpress in the home directory.

Now we need to switch gears for a moment and create a new MySQL directory for wordpress.

Go ahead and log into the MySQL Shell:


  • mysql -u root -p


Login using your MySQL root password, and then we need to create a wordpress database, a user in that database, and give that user a new password. Keep in mind that all MySQL commands must end with semi-colon.

First, let's make the database (I'm calling mine wordpress for simplicity's sake; feel free to give it whatever name you choose):


  • CREATE DATABASE wordpress;

Query OK, 1 row affected (0.00 sec)
Then we need to create the new user. You can replace the database, name, and password, with whatever you prefer:


  • CREATE USER wordpressuser@localhost;

Query OK, 0 rows affected (0.00 sec)
Set the password for your new user:


  • SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password");

Query OK, 0 rows affected (0.00 sec)
Finish up by granting all privileges to the new user. Without this command, the wordpress installer will not be able to start up:

  • GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';

Query OK, 0 rows affected (0.00 sec)
Then refresh MySQL:


  • FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)
Exit out of the MySQL shell:


  • exit

Step Three—Setup the WordPress Configuration

The first step to is to copy the sample wordpress configuration file, located in the wordpress directory, into a new file which we will edit, creating a new usable wordpress config:


  • cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php


Then open the wordpress config:


  • sudo nano ~/wordpress/wp-config.php

Find the section that contains the field below and substitute in the correct name for your database, username, and password:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpressuser');

/** MySQL database password */
define('DB_PASSWORD', 'password');

Save and Exit.

Step Four—Copy the Files

We are almost done uploading Wordpress to the virtual private server. The final move that remains is to transfer the unzipped WordPress files to the website's root directory.


  • sudo rsync -avP ~/wordpress/ /var/www/


Finally we need to set the permissions on the installation. First, switch in to the web directory:


  • cd /var/www/

Give ownership of the directory to the apache user.


  • sudo chown username:www-data /var/www -R 
  • sudo chmod g+w /var/www -R 

From here, WordPress has its own easy to follow installation form online.

However, the form does require a specific php module to run. If it is not yet installed on your server, download php-gd:


  • sudo apt-get install php5-gd

Step Five—RESULTS: Access the WordPress Installation
Once that is all done, the wordpress online installation page is up and waiting for you:

Access the page by adding /wp-admin/install.php to your site's domain or IP address (eg. example.com/wp-admin/install.php) and fill out the short online form (it should look like this).


Install XAMPP in Ubuntu using command line

You can install XAMPP in Ubuntu using ppa(Personal Package Archives). This is a simple process. Open terminal and type following command.
sudo add-apt-repository ppa:upubuntu-com/web
sudo apt-get update
sudo apt-get install xampp

XAMPP is installed now type following command  to start XAMPP server
sudo /opt/lampp/lampp start

Now xampp is installed in your linux , just open web browser and type url in address bar : http://localhost/

Operate XAMPP in Ubuntu using command line

You can operate XAMPP server in ubuntu using following command. 
Syntax: sudo /opt/lampp/lampp <action>
For example:
to start XAMPP server write following command in terminal
sudo /opt/lampp/lampp start


start xampp in ubuntu
start xampp in ubuntu

to stop XAMPP server write following command in terminal
sudo /opt/lampp/lampp stop

Following list shows command list
ActionAction Detail
XAMPP Start Commands
startStart XAMPP (Apache, MySQL and eventually others)
startapacheStart only Apache
startsslStart only SSL support
startmysqlStart only MySQL
startftpStart only ProFTPD
XAMPP Stop Commands
stopStop XAMPP (Apache, MySQL and eventually others)
stopapacheStop only Apache
stopsslStop only SSL support
stopmysqlStop only MySQL
stopftpStop only ProFTPD
XAMPP Reload Commands
reloadReload XAMPP (Apache, MySQL and eventually others)
reloadapacheReload only Apache
reloadmysqlReload only MySQL
reloadftpReload only ProFTPD
Other Commands
restartStop and start XAMPP
securityCheck XAMPP’s security
php5Activate PHP5
phpstatusWhich version of PHP is active?
backupMake backup file of your XAMPP config, log and data files
panelStarts graphical XAMPP control panel