Synchronize wordpress with limesurvey

In my previous post, I wrote how to use wordpress functions outside.

Suppose we want to add wordpress header and footer design in limesurvey template. Following are the steps.

1. Create copy of default template in limesurvey.
2. Activate it through survey settings.
3. Now you want to upload that php file which I defined in my previous post. But when you try to upload, it gives message of not supported file system.
4. So, we need to manually upload file in template folder which is currently created.i.e limesurvey/uploads/template/copy_of_template_directory.
5. As, limesurvey template file is .pstpl format which does not support direct inclusion of php files.
6. So, the method is to call php file through AJAX function.

<div id="demo"></div>
<script type="text/javascript" charset="utf-8">
$.ajax({
url: "{TEMPLATEURL}demo.php",
type: "POST",
success: function(result){
// Load the remote file contents into the script parent element
$("#demo").append(result);
}
});
</script>

Above code helps to append the php code in your demo division. you can define this division where ever you want to embed the php code.

Cheers!

Use WordPress theme functions externally.

If you want to call any wordpress function outside , you need to have access of its wp-load.php file which load all wordpress functions.

Suppose, you want to display header and footer of wordpress website in your web browser.

1. Create index.php

2. Copy, this code to index.php file which fetch its parts.

<?php
define('WP_USE_THEMES', false);
require('blog/wp-load.php');
get_header();
get_footer();
?>

You can call any part of wordpress like sidebar but you just need to find out its function name and call it in the required file.

Cheers!

Install Laravel in your Ubuntu 14.04

Below given are the server requirements to install laravel.

LAMP should be Installed
PHP >= 5.6.4
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension

To upgrade php version, follow this link.

You can find out if this PHP module is installed or not by looking at the list that is produced by this command.

$ php -m

Those are not installed, install it by applying below given command.

$ sudo apt-get install php-mbstring

You can check it though phpinfo(); function

Laravel use composer to install dependencies. So, we need to install composer first.

$ sudo apt-get update
$ sudo apt-get install curl php5-cli git
$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

To test installation of composer, run composer.

$ composer

However, if you want to install it in your local project directory.

$ cd /var/www/html/
$ curl -sS https://getcomposer.org/installer | php

After installation of composer, follow below given steps to install laravel.

$ cd /var/www/html
$ git clone https://github.com/laravel/laravel.git
$ cd /var/www/html/laravel
$ sudo composer install

If above given command, produce error like this.

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
– phpunit/phpunit 4.8.9 requires ext-dom * -> the requested PHP extension dom is missing from your system.

Perform below given steps.

$ sudo apt-get install php-xml
$ sudo apt-get install php7.0-xml

Now set the 32 bit long random number encryption key, which used by the Illuminate encrypter service.

$ php artisan key:generate

Application key [cdfnvjfnvjkenfnkjnekjcnjkdnvknf] set successfully.

Edit config/app.php configuration file and update above generated application key as followings. Also make sure cipher is set properly.

'key' => env('APP_KEY', 'uOHTNu3Au1Kt7Uloyr2Py9blU0J5XQ75'),

‘cipher’ => ‘AES-256-CBC’,

Don’t forget to give permissions.

$ chown -R www-data.www-data /var/www/html/laravel
$ chmod -R 755 /var/www/html/laravel
$ chmod -R 777 /var/www/html/laravel/app/storage

You are done with laravel installation, to run the website, ping your browser with below given URL.

http://localhost/laravel/public

To Create apache virtual host.

Add Virtual Host in your Apache configuration file to access Laravel framework from web browser.

vim /etc/apache2/sites-available/laravel.example.com.conf

<VirtualHost *:80>

ServerName laravel.com
DocumentRoot /var/www/html/laravel/public

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/laravel>
AllowOverride All
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Run the command to enable laravel website and restart apache.

$ a2ensite laravel.example.com
$ sudo service apache2 reload

Now you can browse your laravel from this URL(http://laravel.example.com)

Cheers!

Upgrade PHP version in Ubuntu 14.04 LTS

To run new applications, like laravel, we need to upgrade our system. so, to update php version, follow below given steps.

  • sudo apt-get dist-upgrade
  • sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
  • sudo apt-get update
  • sudo apt-get install php7.0 #for php 7
  • sudo apt-get install php5.6 #for php 5.6
  • sudo apt-get install php-xdebug php-apcu
  • php -v (to see the new version installed in your system)

Thanks.

How To Live Your Presence On Web

If you want to live your website on web, you need few tools which is defined as below.

1. Server: Basically, Server is a computer which has assigned a static IP to access while sitting anywhere in the world. Various companies which provide server hosting like Bluehost, digital ocean and many more. These companies provide you space according to your requirement and charge you for that.

2. Domain Name: It is word which defines or identifies your website from entire world. Well, domain name is also used because its difficult to memorize IP addresses. Companies like dynadot from where you can buy your own domain like navdeepbagga.com, facebook.com.

Now when you have domain name and server, you can make your website up witin few minutes.

I assume you got services from Digital Ocean and Dynadot and I explain further according to that. I hope you enjoy this lesson and excited for your web presence. Let’s start.

1. If you have register with Digital Ocean(hosting service provider), just login with your given credentials, now you able to see the droplet(your space dashboard). From the very first screen, IP address has been written. Just copy that IP address.

2. Login to your dynadot account. From the main menu DOMAINS go to MANAGE. Click on given name server it is like(Dynadot DNS: 012.345.678.900). After clicking, you reach to domain record page where you need to set your record type and IP address.

3. Now remember, the IP address which you have copied in first step that is need to be copied under IP address or target host.
Just choose record type A and put IP address on the same side. Click on Save DNS.

4. Now you just mapped your DNS with IP address. It takes few hours to mapping but when it is done, you can access your server with its domain name.

5. I assume that you have basic knowledge about server login, some hosting companies provide cpanel to access your server data like bluehost. But if not you must have knowledge about ssh client.

6. Login your server with your given credentials. Place your files there and you are ready to access that files from your web browser.

So, It is just a basic lesson. For advance learning like handle NGINX Server, create subdomains, keep reading upcoming blogs.

Thanks!