Install LAMP in Ubuntu 18.04

Install LAMP Ubuntu 18.04

Using the tasksel command the procedure of installing LAMP on Ubuntu 18.04 Bionic Beaver is a rather trivial matter. First, make sure that you have the tasksel package installed:

$ sudo apt install tasksel

To install LAMP server using tasksel execute:

$ sudo tasksel install lamp-server

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

MySQL Secure Installation

It is recommended to secure your MySQL installation before using your LAMP stack server in production. To do so execute:

$ mysql_secure_installation

Firewall Configuration

The following firewall configuration allows incoming traffic on TCP ports 80 and 443:

$ sudo ufw allow in "Apache Full"

Change php 5.6 to 7.1 for command line or terminal on Hostgator

On my hostgator shared hosting, the php 5.6 executable is located at /opt/php56/bin/php

You can use ls /opt to see if the php version folders exist.

So if you want to update your php command with 7.1 you should edit your ~/.bash_profile and append the following line:

alias php=’/opt/php56/bin/php’

You might have to logout and log in again if you dont see a change.

Now, when you use php -v it should say 7.1.x if you have done it right.

Fatal error: Call to undefined function simplexml_load_string() in ubuntu 16 or ubuntu 18

Fatal error: Call to undefined function simplexml_load_string()

execute below command:  

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update
$ sudo apt-get install -y php5.6

then:

sudo apt-get install php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-url

and finally restart server:

sudo service apache2 restart

Convert quote to order in Magento 1

$quoteId = 6078;
$store = Mage::getSingleton(‘core/store’)->load(1);
$quote = Mage::getModel(‘sales/quote’)->setStore($store)->load($quoteId);

$payment = $quote->getPayment();
$items = $quote->getAllVisibleItems();

//$this->createOrder(6112, $payment);
$convertObj = Mage::getSingleton(‘sales/convert_quote’);
//$order = $convertObj->toOrder($quote);
$order = $convertObj->addressToOrder($quote->getShippingAddress());
$order->setPayment($convertObj->paymentToOrderPayment($payment));
$order->setBillingAddress($convertObj->addressToOrderAddress($quote->getBillingAddress()));
$order->setShippingAddress($convertObj->addressToOrderAddress($quote->getShippingAddress()));
// convert quote items
foreach ($items as $item) {
// @var $item Mage_Sales_Model_Quote_Item
$orderItem = $convertObj->itemToOrderItem($item);
$options = array();
if ($productOptions = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct())) {
$options = $productOptions;
}
if ($addOptions = $item->getOptionByCode(‘additional_options’)) {
$options[‘additional_options’] = unserialize($addOptions->getValue());
}
if ($options) {
$orderItem->setProductOptions($options);
}
if ($item->getParentItem()) {
$orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
}
$order->addItem($orderItem);
}
$order->setCanShipPartiallyItem(false);
$order->setStatus(‘Processing’);
$order->save();