ZSH on Arch Linux

Standard

ZSH is a unix shell and a powerful command line interpreter, ZSH is much easier to use and setup, ZSH also allows you to program the command-line completion that helps you customize you shell and offers options and arguments for most used commands, with out-of-the-box support for several hundred commands.

You can install ZSH using Pacman

“`
sudo pacman -S zsh
“`

Installing `grml-zsh-config`, `grml-zsh-config` zsh distribution is a similar to `oh-my-zsh`.

```
sudo pacman -S grml-zsh-config
```

If you prefer oh-my-zsh you can install that too.

```
curl -L http://install.ohmyz.sh | sh
```

Now we have ZSH installed. If you have any problem feel free to leave a comment below.

Enable Xdebug on XAMPP for Windows

Standard

XAMPP is a free and open-source cross-platform web server stack that offers Apache (Web Server), MySQL (Relational Database) and interpreters for PHP and Perl programming languages. XAMPP is one of the most feature-rich Web Server stack solutions.

XAMPP is great for developing a website or web application locally. XAMPP by default is set in PHP development mode, which means you don’t have to configure it if you are using it for development purpose. You have complete freedom right from the installation process to customize and tailor XAMPP to your preference.

XDebug is a PHP extension which provides debugging and profiling capabilities. It uses the DBGp debugging protocol. The debug information that XDebug can provide includes the following:

  • stack and function traces in error messages with:
    • full parameter display for user-defined functions
    • the function name, file name and line indications
    • support for member functions
  • memory allocation
  • protection for infinite recursions
  • profiling information for PHP scripts
  • code coverages analysis
  • capabilities to debug your scripts interactively with a debugger front-end

Setting up XDebug.

Open your XAMPP panel and click the Config button, a menu will appear.

Click the fourth option in the menu that says (php.ini) This should open the php.ini file in notepad or your default text editor. Now add the following code block at the end of your php.ini file.

 [XDebug] 
xdebug.remote_enable = on
xdebug.remote_host="127.0.0.1"
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.profiler_output_dir="\xampp\tmp"
 [PHP_XDEBUG]
zend_extension="C:\XAMPP\php\ext\php_xdebug.dll"

Now you can restart Apache After Apache restarts you will see Xdebug in action.

Enjoy. Happy Coding!

LEMP on Raspberry Pi

Standard

Raspberry Pi is a single board ARM based computer developed in the UK by the Raspberry Pi foundation.

Raspberry Pi can be a really good web server for development/production environment, setting up a LEMP (Linux NGINX MariaDB PHP) stack on a Raspberry Pi running Arch Linux ARM is a really easy.

Why Arch Linux ARM?

Arch Linux ARM comes with the latest stable packages and the most recent firmware available for the Raspberry Pi. Arch Linux ARM is also the least memory consuming OS for Raspberry Pi.

I am assuming you have your Raspberry Pi running Arch Linux ARM with access via SSH.

Installing

Updating your Raspberry Pi.

“`
sudo pacman -Syu
“`

Once the update is done we can now start installing NGINX Web Server.

“`
sudo pacman -S nginx
“`

Installing PHP and php extensions

This will install php-fpm and other PHP extensions. This will also install Composer.

“`
sudo pacman -S php-fpm php-mysql php-sqlite php-xsl php-tidy php-pspell php-mcrypt php-snmp php-mongo php-pear php-composer php-embed php-enchant php-gd php-intl php-ldap php-odbc xdebug
“`

Installing MariaDB (MariaDB 10).

“`
sudo pacman -S mariadb
“`

Now we need to edit our NGINX configuration to pass files through PHP-FPM, I will be using nano but you can use any editor of your choice.

“`
nano /etc/nginx/nginx.conf
“`

Once you have the file opened in nano or you prefered editor, replaces the content with the following code block.

“`
# nginx.conf for 1.6.x

worker_processes 1; # Number of nginx process

events {
worker_connections 5000;
}

http {

server {

    listen 80;
    server_name localhost;

    location / {
        root /srv/http;
        index index.php index.html;
    }


    location ~ \.php$ {
        root /srv/http;
        try_files      $uri = 404;
        fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.php;
        include        fastcgi.conf;
    }

}

}


</div>Enabling NGINX. PHP-FPM, MariaDB to run at the startup of the Raspberry Pi

<div class="highlighter-rouge">```
systemctl enable mysqld.service; systemctl enable nginx.service; systemctl enable php-fpm.service  

Now we can reboot your Raspberry Pi.

“`
reboot
“`

Your web-root or the place where your PHP files are stored is `/srv/http`.

Getting inside the web-root.

```
cd /srv/http
```

Now we can create an `index.php` file.

```
touch index.php
```

Add the following lines inside the `index.php` file.

```
??>```

Now visit your Raspberry Pi ip address. This should display a web page displaying LEMP stack information and list of PHP plugins and plugin configurations

Done, Happy Coding!

Ruby on Arch Linux

Standard

Ruby is a dynamic, open source general-purpose programming language with a simple and easy to understand syntax. Writing code in Ruby is very easy, Ruby based source code is easy to read to a non-programmer to. Ruby is widely used for creating web applications and offers really popular web frameworks like Sinatra, Ruby on Rails and many others, Ruby is also used to create command line tools, It can also be used for writing awesome desktop applications.

Ruby packages are called “gems“, these gems can be installed using Rubygems the package manager for Ruby.

Installing

Ruby can be installed using a simple command.

“`
sudo pacman -S ruby
“`

Exporting Ruby and gem binary path. You need to add these lines to your ‘.bashrc’ or .’bash_profile’, If you are using ZSH, you need to add this in your ‘.zshrc’, if you are using ‘grml-zsh-config’ from the Arch Linux repository you need to add this in ‘zshrc.pre’

“`
PATH=”$(ruby -e ‘puts Gem.user_dir’)/bin:$PATH”
export PATH
“`

You can reopen your Terminal and Ruby and gem should now be executable or.

“`
/bin/bash –logout
“`

You can update Rubygems to the latest stable version. At the time of writing this post Rubygems installed by default is ‘2.2.2’. You can upgrade it to ‘2.3.0’ by entering this command below.

“`
gem update –system
“`

Checking the version of Ruby your are running.

“`
ruby –version
“`

You can do the same to check the version of Rubygems installed.

“`
gem –version
“`

Now we have Ruby installed on our system. If you have any problem feel free to leave a comment below.