-
Notifications
You must be signed in to change notification settings - Fork 6
Culturize & Crontab
- GitHub account
- Git
- A GitHub repository containing .htaccess-files (Apache) or redirect.conf-files (Nginx)
- A Linux server with Apache or Nginx installed
- Clone the git repository to the home folder on the webserver with the following command:
git clone -b https:github.com/username/htaccess
- Go into your local repository folder with
cd ~/$repofolder
- Make a connection with the remote (online) repository by typing
git fetch --force origin
Before you start you will need enable http_proxy mod and restart your webserver by typing following commands in your terminal. (More information)
sudo a2enmod proxy sudo a2enmod proxy_http sudo systemctl restart apache2.service
- Create a working tree so that your files on GitHub automatically be placed in the
www
-folder of your webserver. Typegit --work-tree=/var/www/html checkout -f
- Create a crontab rule.
- Open the crontab editor by executing
sudo crontab -e
in the terminal - Next, add the line
0 */1 * * * cd $repofolder/$repofolder.git/ && /usr/bin/git fetch --force origin master:master && /usr/bin/git --work-tree=/var/www/html checkout -f && /usr/bin/git --work-tree=/var/www/html clean -fd
to hourly pull the GitHub repository where your PIDs are stored. This will pull possible changes every hour from the remote repository and put the files in/var/www/
. -
Git fetch
will get the changes from the server,git checkout
will apply the changes to the .htaccess files.git clean
is optional, we use it to remove the unchecked changes
- Open the crontab editor by executing
-
Create a working tree so that your files on GitHub automatically be placed in the folder of your choosing. In this case the folder needs to be in
/etc/nginx
. Type the following commandgit --work-tree=/etc/nginx/culturize/ checkout -f
. -
We need to add this location to the exsisting nginx configuration. Open the configuration of the website you want the redirect to happen from
/etc/nginx/sites-enabled/domain.conf
and add this line to in server blockinclude /etc/nginx/culturize/nginx_redirect.conf;
. If a sub directory was selected in CultURIze during the nginx configuration generation this should also be configured here e.g.include /etc/nginx/culturize/<subdir>/nginx_redirect.conf;
server { listen 80; server_name example.com; root /var/www/example.com; index index.html; include /etc/nginx/culturize/nginx_redirect.conf; location / { try_files $uri $uri/ =404; } }
-
Create a crontab rule.
- open the crontab editor executing
sudo crontab -e
in the terminal. - next, add the line t
0 */1 * * * cd $repofolder/$repofolder.git/ && /usr/bin/git fetch --force origin master:master && /usr/bin/git --work-tree=/etc/nginx/culturize checkout -f && /usr/bin/git --work-tree=/etc/nginx/culturize clean -fd && nginx -s reload
in the file in the terminal to hourly pull the GitHub repository where your PIDs are stored. This will pull possible changes every hour from the remote repository and put the files in/etc/nginx/culturize/
.-
git fetch
will download the changes from the server. -
git checkout -f
This is used to throw away local changes. -
git clean
is optional, we use it to remove the unchecked changes. ([more informatoin]https://git-scm.com/docs/git-clean) -
&& nginx -s reload
will reload the nginx webserver, without interrupting already running services. This is to load in the new configuration files.
-
- open the crontab editor executing
PACKED vzw (c) 2019 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.