Sunday, September 10, 2017

How to install XAMPP in Linux and make WordPress update work perfectly!

Installing XAMPP properly so that Wordpress runs smoothly on Linux
We have all been there... when we try to update something in Wordpress in Linux and it does not update. Even debug.log does not create. It is most of the time a permission issue. But Windows does not suffer from it. So, why should Linux have this issue? Fear not, we have a solution!

Step 1: Install XAMPP (LAMPP)

If you have not installed XAMPP yet on your linux machine, then first do so. I have written a tutorial here.

Step 2: Create Group for XAMPP Users and put yourself in!

* Replace "username" with your username.

sudo groupadd xamppusers
sudo usermod -a -G xamppusers username
groups username

The last command will show you the groups that your username is in. If you have xamppusers group in the list, then you are good.

Step 3: Own the files!

Run this:

cd /opt/lampp
sudo chown -R username.xamppusers htdocs
sudo chmod -R 775 htdocs

This will relax the file permissions of your htdocs folder, so you have less trouble. And also change the owners to the username you chose. You will taste great feedoms when editing files and modifying files with php after this.

Step 4: Edit the httpd.conf

httpd.conf is the configuration file for Apache.

First backup the conf file:
sudo cp /opt/lampp/etc/httpd.conf /opt/lampp/etc/httpd.conf.bak

Edit the file:
sudo nano /opt/lampp/etc/httpd.conf

You will find two lines saying something like this:
Tip: You can press Ctrl+W, type user daemon and press enter to find it quickly.
User daemon
Group daemon

Editing the httpd.conf with nano in linux cli

Replace it with your values, something like this:
User username
Group xamppusers

Step 5: Restart XAMPP

This step is very important. If you do not do this the changes you made in httd.conf file will not be taken.
sudo /opt/lampp/lampp restart
or, use the GUI Control Panel if you have it.

Bonus Tip: Accessing htdocs from home directory

ln -s /opt/lampp/htdocs/ ~/htdocs

You will then be able to see a link to the "htdocs" folder in your home folder. This is so convenient for accessing files on htdocs.

Conclusion

After doing all this hard work you will be able to install Wordpress without any permission issues whatsoever. Also update Wordpress without any problem.

Plugin update also works!

Wordpress Plugin updates without any issue


Tuesday, August 22, 2017

NGROK - A nifty little program to share your localhost with everyone

We have live sites for running client sites, we have staging sites for testing. But what about localhost sites. We sometimes have some test code running in local that we want the world to see!
NGROK is a tiny program that let's you temporarily create an url for your localhost! And anybody with the URL can visit this and enjoy the goodness within!
Moreover it does not need install, runs on Windows, Linux, Mac, BSD or ARM, plus its open source. How cool can it get?!

Basics (for geeks)

To run NGROK is easy. Just download from https://ngrok.com/download, cd to that directory and run: ngrok http
And this will give you an url to access the localhost on your machine. Please keep in mind that the url will work only if the command line window is running, so you cannot close it while you want others to see it.
Also, make sure that you have entered the correct port number in the command that the apache running in. In a typical Windows installation with XAMPP installed, it runs in port 80. If not sure you can check in the XAMPP Control panel to see its port or check on httpd.conf.

Detailed Instructions (for beginners)

  1. Run apache + mysql + whatever you have!
  2. Determine the port in which apache is running. Usually it is 80. But to make sure you can:
  • In Windows: Check the XAMPP Control Panel GUI. It should have the port number under Port(s).
  • In Linux/LAMPP: Check /opt/lampp/etc/httpd.conf This should have the port number listed there somewhere. You can search for port and a line like Listen 80 will be there. 80 is the port number here in this example.
  • In other cases, run httpd -V and this will show the path of the httpd.conf. Check that file for the port in a Listen line.
Take a note of this port number.
  1. Download NGROK: https://ngrok.com/download
  2. Extract it. You will then have the ngrok executable file ready for your testing.
  3. cd to that directory.
  • In Windows: Go to the directory where the executable (exe) file is. Keep pressing shift and right click on empty space, then choose Open command window here.
  • In Linux: Visit the file in your File Manager, right click on empty space, then choose Open in terminal. This option maybe also available in the Tools menu. You can also type cd and then a space, then drag and drop the folder in a terminal window and press enter.
  1. Run ngrok in Command prompt/Terminal: ngrok http 80 (replace 80 with your port number, if your port number is different)
This will eventually connect and show you an url, something like this: https://65f6sc3b.ngrok.io
Take note of this url.
Keep this window open up to the time that you want the url to work.
  1. Open the URL in your browser to test if this can be accessed correctly.
  2. For Wordpress sites, you may see that the URL changing to "localhost" sometimes. If this is the case, then you would need to install this plugin: https://wordpress.org/plugins/root-relative-urls/ (This plugin is intended for use in development environment only, not for live or production use.)

Ref: