Skip to content

Instantly share code, notes, and snippets.

@haljeshi
haljeshi / Create new apache website locally
Created July 21, 2020 07:48
usage `sudo makewebsite mynewwebsite` and then you will be able to navigate to mynewwebsite.test. To work, it will need the template vhost to be in place (https://gist.github.com/haljeshi/b1247624518a2f23b4a75820bb20c4d0)
#!/bin/sh
WEBSITE="$1"
Green='\033[0;32m'
Color_Off='\033[0m'
echo -e $Green
echo "Creating $WEBSITE.test.conf..."
cp /etc/apache2/sites-available/template /etc/apache2/sites-available/$WEBSITE.test.conf
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
#!/bin/sh
FROMVERSION=$(php -v|grep --only-matching --perl-regexp "(PHP )\d+\.\\d+\.\\d+"|cut -c 5-7);
TOVERSION="$1"
update-alternatives --set php /usr/bin/php$TOVERSION
a2dismod php$FROMVERSION
a2enmod php$TOVERSION
service apache2 restart
echo "done"
@haljeshi
haljeshi / Refresh Magento 2 Commands
Last active July 21, 2020 06:48
I use this shell script whenever Magento 2 is behaving strangely. It takes a long time to execute (mainly due to deploying static content), but it's a good last resort which usually solve my problem.
#!/bin/sh
RED='\033[0;31m'
NC='\033[0m'
echo "${RED}Deleting pub/static ${NC}"
rm -r pub/static/*
echo "${RED}Deleting var/cache ${NC}"