Running XAMPP on Ubuntu using Terminal

To start XAMPP run the following and the command will return a list of running services:

sudo /opt/lampp/lampp start

To stop XAMPP run the command below and it will return a list of the stopped services.

sudo /opt/lampp/lampp stop

You can also stop/start/restart individual services by appending “apache”, “mysql” or “ftp” to the end.

Starting

start – Start XAMPP (Apache, MySQL and eventually others)
startapache – Start only Apache
startmysql – Start only MySQL
startftp – Start only ProFTPD

Stopping

stop – Stop XAMPP (Apache, MySQL and eventually others)
stopapache – Stop only Apache
stopmysql – Stop only MySQL
stopftp – Stop only ProFTPD

Restart

reload – Reload XAMPP (Apache, MySQL and eventually others)
reloadapache – Reload only Apache
reloadmysql – Reload only MySQL
reloadftp – Reload only ProFTPD
restart – Stop and start XAMPP

SSL & Security

security – Check XAMPP’s security
enablessl – Enable SSL support for Apache
disablessl – Disable SSL support for Apache

Config

backup – Make backup file of your XAMPP config, log and data files
oci8 – Enable the oci8 extenssion

GUI Panel

panel – Starts graphical XAMPP control panel

Enable Magento2 Command-Line Interface (CLI) on Linux

For both development, ongoing management and scheduled tasks Magento’s Command Line Interface is able to do it all.

To enable CLI for Magento to you’ll need to make sure the file /bin/magento is executable by the system.

If you’re on the server SSH into the root of your Magneto install and run the command

chmod +x bin/magento

If you’re on desktop simply locate the file in your file explorer, right click and set the “Allow executing file as program” checkbox on the Permissions tab.

Running Ubuntu on Windows

One of my favourite aspects of Windows 10 has been the Linux subsystem for Windows.

I’ve been using it since launch partly because it sounded cool but also because a majority of my development projects are Linux based and when I’m interacting with a server I use Bash, a command line interface for Linux.

Day to day usefulness

As someone who daily has to interact with various servers it makes sense to use bash everywhere. On Windows with the Linux subsystem, you can Bash scripts, use command-line tools like sed, awk, grep, and you can even run Linux-first tools like Ruby, Git, Python, etc. directly on Windows.

You have complete access to your existing Windows filesystem from within Bash allowing you to work on the same set of files using both Windows applications and Linux command-line tools.

Desktop experiments

On the experimental side and with the addition of a window manager Xming X Server I have been able to run Linux applications such as Open Office, Firefox and Tor Browser from within the Linux subsystem on Windows.

 

Upgrading Magento 1 through command line

Alternative: Upgrade Magneto using the Magento Connect Downloader

Upgrading Magento is a must to keep your store in top-top condition, protect your customers and your business.

Upgrading Magento through command line is the easiest way to make sure you are running the latest version of the Magento Software

  • Load the root directory of your Magento store
  • Make sure the “mage” file has the right permissions: chmod 777 mage
  • Then launch Magento set-up: ./mage mage-setup
  • If all goes well you can then pull the latest version of the code source code:
    ./mage install http://connect20.magentocommerce.com/community Mage_All_Latest --force

If things didn’t go well with mage-setup you may need to run set som preferences….

  1. Make sure your prefered code is set: ./mage config-set preferred_state stable
  2. Then sync your changes: ./mage sync

You can then try the install command again.

That should do the trick.

 

How to update your hosts file.

Every computer has a file on it which allows the owner to specify where a website is loaded from. A hosts file is a simple combination of domain names and IP addresses.

Adding a record to your hosts file means your computer will load the domain using the IP address specified, rather than the one provided by DNS.

111.222.333.444 www.domain.com
111.222.333.444 domain.com
111.222.333.555 subdomain.domain.com
  1. Press the Windows key.
  2. Type Notepad in the search field.
  3. Right-click on the Notepad result
  4. Select Run as administrator.
  5. From Notepad, open: C:\Windows\System32\Drivers\etc\hosts
  6. Add the new lines to the file.
  7. Click File > Save to save your changes.
  8. Exit Notepad
  1. Open a terminal window.
  2. Open the hosts file in a text editor (you can use any text editor) by typing the following line:
    sudo nano /etc/hosts
  3. Enter your domain user password.
  4. Make the necessary changes to the file.
  5. Save the file
Good luck.

Mac OS X 10.0 through 10.1.5

  1. Open /Applications/Utilities/NetInfo Manager.
  2. To allow editing of the NetInfo database, click the padlock in the lower-left corner of the window.
  3. Enter your domain user password and click OK.
  4. In the second column of the browser view, select the node named machines.

    The third column contains entries for -DHCP-broadcasthost, and localhost.

  5. In the third column, select localhost.
  6. From the Edit menu, select Duplicate. (The quickest way to create a new entry is to duplicate an existing one.)

    A confirmation alert appears.

  7. Click Duplicate.

    A new entry called localhost copy appears, and its properties are shown below the browser view.

  8. Double-click the value of the ip_address property and enter the IP address of the other computer.
  9. Double-click the value of the name property and enter the hostname you want for the other computer.
  10. Click the serves property and select Delete from the Edit menu.
  11. From the File menu, select Save.

    A confirmation alert appears.

  12. Click Update this copy.
  13. Repeat steps 6 through 12 for each additional host entry that you want to add.
  14. From the NetInfo Manager menu, select Quit.

    You do not need to restart the computer.

Mac OS X 10.6 through 10.12

  1. Open Applications > Utilities > Terminal.
  2. Open the hosts file by typing the following line in the terminal window:
    sudo nano /private/etc/hosts
    
  3. Type your domain user password when prompted.
  4. Edit the hosts file.

    The file contains some comments (lines starting with the # symbol), and some default hostname mappings (for example, 127.0.0.1 – local host). Add your new mappings after the default mappings.

  5. Save the hosts file by pressing Control+x and answering y.
  6. Make your changes take effect by flushing the DNS cache with the following command:
    dscacheutil -flushcache

The new mappings should now take effect.

MySQL Database Backup and Restore via Command Line (Copy-and-pasteable)

Putting this together because I always end up checking online for the correct bash commands for Linux. These commands rely on your knowing for sure which database is which and you should always double check to be sure.

Export

First step is to go to use cd to change directory to the one in which you want the SQL Dump to appear. The dump will consist of a text file and all the database structure and content included.

cd var/www/example.com

If you want to double check the contents of the directory you are in then simply enter ls and a list of directories and files will be returned.

ls

When you’re happy you’re in the right directory, we can export the file. In this instance I have a user name (user123) after the -uand the database is database_live and the initial -p means bash will ask me for the password.

mysqldump -p -uuser123 database_live > mydumpfile.sql

Hit enter, enter the password and after some serious thinking (depending on the size of the database) you’ll be able to enter the next command. Again, entering ls will allow you to verify there is a file called mydumpfile.sql in the directory.

Import

The next step is then to import the database into your other database. It should be noted that importing the previous dump will with default configuration wipe any existing data during the import into the second database.

In the instance below I have a user name (uuser456 ) after the -uand the database is database_live and the initial -p means bash will ask me for the password.

mysql -p -uuser456 database_backup < mydumpfile.sql

Hit enter, enter the password for the user and again it will hang while the details are imported.

Magento: Clear all caches through command line

When making certain changes to Magento, such as modifying source files, installing extensions, reverting changes, it is necessary to clear the cache in order for the changes to become visible.

Oftentimes the Admin Panel > System -> Cache Management then “Flush Magento Cache” will not have the desired affect.

Command Line

Delete the contents of the var/cache/ folder using the following Linux SSH command. This command MUST be executed from your Magento base directory for it to work properly.

rm -rf var/cache/*

After the cache has been wiped, session values will also need to be cleared from the system. This command MUST be executed from your Magento base directory for it to work properly.

rm -rf var/session/*

Finally once the site has been cleared of old cached and logged data for best results a complete Reindex of the site is recommended.

php shell/indexer.php --reindexall

ka.lpe.sh Script

ka.lpe.sh have put together a really good script for programmatically clearing the cash from SSH. Create a file in your Magento root and name it clearCache.php with the below code: