Tahsin Abrar's WebLog

Think different.. Be Passionate!

Install LAMP Stack on Ubuntu

The acronym of LAMP stands for Linux, Apache, MySQL, and PHP. It’s straight forward to install LAMP on Ubuntu.

To install apache:

sudo apt-get update
sudo apt-get install apache2

To install MySQL:

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

During the installation, MySQL will ask you to set a root password. If you miss the chance to set the password while the program is installing, it is very easy to set the password later from within the MySQL shell.

Once you have installed MySQL, we should activate it with this command:

 sudo mysql_install_db 

Finish up by running the MySQL set up script:

 sudo /usr/bin/mysql_secure_installation 

The prompt will ask you for your current root password. Then the prompt will ask you if you want to change the root password. Go ahead and choose N and move on to the next steps.

It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.

 

Now, to install PHP:

 sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt 

Then restart Apache.

 sudo service apache2 restart 

Install PHPMyAdmin

 sudo apt-get install phpmyadmin apache2-utils 

Restart Apache.

 sudo service apache2 restart 

 

Install PHP and curl

sudo apt-get -y install php5-cli curl

Install mcrypt and php5-mcrypt

sudo apt-get -y install mcrypt php5-mcrypt

Enable php5-mcrypt

sudo php5enmod mcrypt

Install SQLite

sudo apt-get install php5-sqlite

Enable htaccess in Apache

First enable rewrite using this command:

 sudo a2enmod rewrite 

Then restart apache2:

 sudo service apache2 restart 

Then go into the sites-available folder:

 cd /etc/apache2/sites-available 

Edit the file named default.conf and change AllowOverride none to AllowOverride All. Or, if the Directory part is missing, then put this after DocumentRoot line :

<Directory "/var/www/html">
AllowOverride All
</Directory>

This will make .htaccess work in your server VPS.

This worked on an Ubuntu 14.04.3.

Using MySQL database via command line

If you’re a Unix user, and also a developer, then you’re surely love to do stuff with command line interface. It’s fun to work in a command line interface environment.

Don’t be afraid. It’s easy to use MySQL database for basic operation via command line interface.
To start mysql console:

mysql -u username -p

Then write your password when prompt. It will open the mysql console. After that, in mysql console, you can try these to use basic mysql operations:

  1.   To show all databases: show databases;
  2. To select a database from the database list, write: use <database-name>;
  3. To show tables from the selected database, write: show tables;
  4. To create a new table in the selected database, write:
    CREATE TABLE <table-name> (<field-name> <field-type> (length) );
    

    ex.

    CREATE TABLE customers ( id INT (11), name VARCHAR(100), age INT(11), birthday DATE );
  5. To view the table structure, write:
    DESCRIBE <table-name>;
    

    ex.

    DESCRIBE customers;
  6. To close the mysql console, write: exit; or \q;


These are the basic operations. By the way, you can use all others database queries with the command line.

Now, if you want to backup one of your database with command line, you can mysqldump. Write:

mysqldump -u username -p db_name > new_file_path_with_name

ex.

mysqldump -u username -p testdb > ~/Desktop/testdb.sql

And, if you want to import a file to the database, try:

mysql -u username -p db_name < backup_file.sql

That’s it! Happy coding!

Setting up my Ubuntu for Web Development

Update apt cache

sudo apt-get update

Install Guake Terminal

If you love to work in terminal, then you’ll must love Guake terminal. By pressing F12, you can easily turn on/off the terminal. To install it, run:

sudo apt-get -y install guake

Add Guake to StartUp Applications

After installing Guake terminal, it’ll not start automatically. To start Guake terminal when the machine boot:

Goto System -> Preferences -> Startup Applications.

or

Dash -> Type: Startup Applications

The Startup Application Preferences window opens. Then, click in Add, give a Name for the Application in the Name field (“Guake” it’s enough), and then type “guake” without quotes in the command field and click Add. Then close the Startup Application Preferences window and restat the machine, now Guake should start automatically on login.

Or, if you want to do it with command prompt, then:

sudo cp /usr/share/applications/guake.desktop /etc/xdg/autostart/

 

Install dotfiles

If you want to personalize your system, then you can use any of the dotfiles available in github. I’m a fan of mathiasbynens/dotfiles. To use it:

git clone https://github.com/mathiasbynens/dotfiles.git &amp;amp;lt;span class="pl-k"&amp;amp;gt;&amp;amp;amp;amp;&amp;amp;amp;amp;&amp;amp;lt;/span&amp;amp;gt; &amp;amp;lt;span class="pl-c1"&amp;amp;gt;cd&amp;amp;lt;/span&amp;amp;gt; dotfiles &amp;amp;lt;span class="pl-k"&amp;amp;gt;&amp;amp;amp;amp;&amp;amp;amp;amp;&amp;amp;lt;/span&amp;amp;gt; &amp;amp;lt;span class="pl-c1"&amp;amp;gt;source&amp;amp;lt;/span&amp;amp;gt; bootstrap.sh

Install Remarkable (Markdown Editor)

To directly download the Remarkable Editor, go to here.

Or, if you want to download it with terminal, then open the terminal:

 wget https://remarkableapp.github.io/files/remarkable_1.62_all.deb 

 

Then install the .deb file on your system.

Install Nautilus-open-terminal

sudo apt-get -y install nautilus-open-terminal

Install Unity Tweak Tool

sudo apt-get -y install unity-tweak-tool

Install Unrar

sudo apt-get -y install unrar

Laravel Installation: The easiest way

First time installing Laravel on Windows seems difficult for someone like me. That’s why, I’m writing step by step procedure on how to install laravel on Windows.

  •  Step-01: Download Composer

    At first, we need to setup the composer. For this, Go to composer’s website and download the Composer-setup.exe file from the Windows installer Section.

  •  Step-02: Install Composer

    Install the composer into your computer. When installing composer, Remember the following:
    — Select “Do not install Shell Menus”
    — Locate the PATH of php.exe , if you’re using XAMP that is installed into your C drive, then the Path is similar to like this: C:\xampp\php\php.exe
    Read More

Using Emmet plugin in Sublime Text & Notepad++

যারা ওয়েব ডেভেলপমেন্টের সাথে জড়িত, তাদের প্রায় সবসময়ই HTML, CSS এর কোডগুলো নিয়ে কাজ করতে হয়। HTML, CSS এর কোডগুলো এমন যে, এগুলো আসলে একই লেখা বারে বারে লিখতে হয়। পুরো কোড টাইপ করে লিখাটা আসলেই অনেক সময় নষ্ট করে ফেলে। এর জন্য ভালো একটা Text Editor থাকলে কাজগুলো অনেক সহজ হয়ে যায়। এরকম একটা Text Editor হচ্ছে Sublime Text Editor.  যদিও প্রথম দিকে কাজ শেখার জন্য পুরো কোড টাইপ করে লিখাটাই শ্রেয়। এবং সেজন্য Notepadd++ Editor ব্যবহার করলে ভালো হয়।

Text Editor এর সাথে আরও কিছু প্লাগইন আছে, যেগুলো ব্যবহার করলে আপনি খুব কম সময়েই অনেক বেশি কোড লিখতে পারবেন। এরকম একটা প্লাগইন হচ্ছে  Emmet । যখন Emmet Plugin ব্যবহার করা শুরু করবেন, তখন মনে হবে আপনি কোড নিয়ে জাদু করছেন। ;) যারা নিয়মিত HTML ফাইল নিয়ে কাজ করেন, তাদের জন্য এটা খুবই কাজের এবং উপকারী। শুধুমাত্র অল্প কিছু কোড লিখে দিলেই পুরো Snippet টা এই প্লাগইনের মাধ্যমে জেনারেট হয়ে যায়।

আমি এখানে Sublime Text Editor এবং Notepad++ Editor এ কিভাবে Emmet Plugin install করতে হয়, সেটা নিয়ে লিখছি।

Read More