in Code name: Ant-man, Laravel, Software Development

There are quite a number of components needed to setup a proper Laravel development environment on Xubuntu. And, I am tired of Googling around for each and every components. Hence, the birth of this article for my own reference. Use it at your own risk although your computer won’t explode 🙂

First, install the fundamental components, such as git and curl

$ sudo apt install git curl

Then, install the mighty package management system for PHP – composer. Initially, I was planning to install PHP CLI manually then install composer as per the instructions from the website. But then this is not necessary anymore! Just simply type in the following commands will do:-

$ sudo apt install composer

* The above will install PHP CLI 7.2.7 automatically as well

Still need a few more items to complement PHP for composer.

$ sudo apt install php-mbstring php-xml php-zip php-intl php-soap php-mysql php-curl php-gd php-bcmath php-xdebug
$ sudo apt install php7.2-mbstring php7.2-xml php7.2-zip php7.2-intl php7.2-soap php7.2-mysql php7.2-curl php7.2-gd php7.2-bcmath php7.2-dev

Next, install XAMPP by going to https://www.apachefriends.org/download.html to download the latest XAMPP for Linux 7.2.7 (64-bit).

$ chmod 755 xampp-linux-x64-7.2.7-0-installer.run
$ sudo ./xampp-linux-x64-7.2.7-0-installer.run

And then, just click “Next” on the screens pop-up and your XAMPP will be installed into /opt/lampp.

There are 2 ways to start/stop the XAMPP services:-

  1. Via command line
    $ sudo /opt/lampp/lampp start
    $ sudo /opt/lampp/lampp stop
  2. Via graphical tool
    $ cd /opt/lampp/
    $ sudo ./manager-linux-x64.run

You should be able to see the following page by now when you launch your favorite browser.

Next, I will install PhpStorm because I need a full IDE

$ sudo snap install phpstorm --classic

Finally, we arrived at the Laravel portion.

But, we will face permission issue when we try to deploy Laravel projects into the /opt/lampp/htdocs folder/directory.

We need to change the ownership for /opt/lampp/htdocs folder/directory

$ sudo chown -R [Username]:[Group Name] /opt/lampp/htdocs

Replace the [Username] and [Group Name] with your own account.

Then, edit the Apache configuration file at /opt/lampp/etc/httpd.conf and look for the “User daemon” line

Again, replace the [Username] and [Group Name] with your own account.

Restart all XAMPP services and you are done!

    • Setup *.test for local development
    • Generate self-signed certificate
      • mkdir /opt/lampp/apache2/crt

      • openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /opt/lampp/apache2/crt/test.key -out /opt/lampp/apache2/crt/test.crt

      • Edit httpd-vhosts.conf

        <VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot “/opt/lampp/htdocs/yubin”
        ServerName yubin.test
        ErrorLog “logs/yubin.test-error_log”
        CustomLog “logs/yubin.test-access_log” common
        </VirtualHost>
        <VirtualHost *:443>
        ServerAdmin [email protected]
        DocumentRoot “/opt/lampp/htdocs/yubin”
        ServerName yubin.test
        ErrorLog “logs/yubin.test-error_log”
        CustomLog “logs/yubin.test-access_log” common
        SSLEngine on
        SSLCertificateFile “/opt/lampp/apache2/crt/test.crt”
        SSLCertificateKeyFile “/opt/lampp/apache2/crt/test.key”
        </VirtualHost>

    • Install XDebug for XAMPP
      • sudo pear channel-update pear.php.net
      • sudo pecl channel-update pecl.php.net
      • sudo pecl install xdebug
      • sudo vim /opt/lampp/etc/php.ini

        [xdebug]
        zend_extension=/opt/lampp/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so”
        xdebug.remote_enable=1
        xdebug.remote_autostart = 1

      • sudo /opt/lampp/lampp restart
    • Install multiple PHP (refence: https://www.tecmint.com/install-different-php-versions-in-ubuntu/)
      • sudo add-apt-repository ppa:ondrej/php
      • sudo apt-get update
      • sudo apt install php7.0-cli

 

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Write a Comment

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.