Posts in Category: snippets


Remove all files from a directory?

  • To remove the folder with all its contents(including all interior folders):
  • To remove all the contents of the folder(including all interior folders) but not the folder itself:
  • To remove all the “files” from inside a folder(not removing interior folders):

Where:

  • rm – stands for “remove
  • -f – stands for “force” which is helpful when you don’t want

Zip/unzip all files in a directory

Unix zip directory but excluded specific subdirectories (and everything within them)

or

 


How to make Apache run as current user

or

Edit the following file as root: /etc/apache2/envvars

using the command:

change the user and group to yourself if there is only one user and you will never have permissions problems again.

I.E., if you are only logging in and running the server as user ‘big_dog’:


Heck, for that matter

How To Set Up mod_rewrite for Apache on Ubuntu 18.04

Prerequisites:-

Make user Apache 2 installed on your server – How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 18.04.

Step 1 — Installing Apache

Step 2 — Enabling mod_rewrite

Step 3 — Setting Up .htaccess

In this section, we will setup a .htaccess file for simpler rewrite rule management. A .htaccess


Permissions

The /var/www folder needs to be readable by the www-data system account. Try this :

(1) Allow Apache access to the folders and the files.


This recursively sets the ‘group’ to be www-data for the folders and files. This then gives the web server permission to recurse and get access


INSTALL Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 18.04

sudo apache2ctl configtest
sudo ufw app list
sudo nano /etc/apache2/apache2.conf

Inside, at the bottom of the file, add a ServerName directive, pointing to your primary domain name. If you do not have a domain name associated with your server, you can use your server’s public IP address:


Example:-

Correct file permissions for WordPress

For Development


In production, I wouldn’t give access to users to modify the filesystem, I’ll only allow them to upload resources and give access to some plugins specific folders to do backups, etc. But managing projects under Git and using deploy keys on the server, it isn’t good update