Kategori arşivi: OS

git workflow ubuntu www

on ubuntu:

install git

create repo (home git repos)

make .git repo and sub files’ group and owner -> git

in repo hook folder, create “post-receive” and paste this:

#!/bin/sh
git –work-tree=/var/www/[cloned-git-folder] –git-dir=/home/git/repos/[repo-name].git checkout -f

(above work-tree and git-dir commands starts with two – sign)

clone git in var/www

make cloned www folder group -> www-data, owner -> git

connect ssh repo with git user because remote git repo post-receive file’s owner and group is git user


in usr/local/bin create command file like “pull-reponame”

paste this:

#!/bin/sh
cd /var/www/[cloned-repo-folder]
git stash && git pull

you can make owner any user and group git

add execute permission to git group

add any user to git group to allow running this command shortcut

ubuntu 14 apache ssl activate, create self signed certificate, configure virtual host

sudo a2enmod ssl
sudo service apache2 restart
sudo mkdir /etc/apache2/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/your_domain.key -out /etc/apache2/ssl/your_domain.crt
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:New York
Locality Name (eg, city) []:New York City
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Your Company
Organizational Unit Name (eg, section) []:Department of Kittens
Common Name (e.g. server FQDN or YOUR name) []:your_domain.com
Email Address []:your_email@domain.com
sudo nano /etc/apache2/sites-available/default-ssl.conf
<IfModule mod_ssl.c>
  <VirtualHost _default_:443>
       		....
  </VirtualHost>

  <VirtualHost _default_:443>
	ServerName www.your_domain.com
	ServerAlias your_domain.com
	DocumentRoot /var/www/your_domain.com
		
	ErrorLog ${APACHE_LOG_DIR}/error_your_domain_com_ssl.log
	CustomLog ${APACHE_LOG_DIR}/access_your_domain_ssl.log common	
			
	SSLEngine on
	SSLCertificateFile /etc/apache2/ssl/apache.crt
        SSLCertificateKeyFile /etc/apache2/ssl/apache.key
  </VirtualHost>
</IfModule>
sudo a2ensite default-ssl.conf
sudo service apache2 restart
RewriteEngine on

RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{HTTPS} !on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
https://your_domain.com

windows cmd bat file pass parameter sample

CopyFile.bat –>

@echo off
set param=%2
set argv1=%~dpnx1
set argv2=%~dpnx3
if %param% EQU -copy (
    if "%argv1%" NEQ "" if "%argv2%" NEQ "" (
        for %%a in ("%argv1%") do (
            if not exist "%argv2%" mkdir "%argv2%"
            copy /y %%a "%argv2%">Nul
        )
    echo( Finish Copy [%argv1%] to [%argv2%]
    ) else echo( You need 3 argument!
) else echo( Wrong argument : %param%
pause>Nul
exit

And run it with command:

CopyFile.bat "nameoffile" -copy "C:\Example"