ZhoubaWiki:ConfigAutomatization

From ZhoubaWiki
Jump to navigation Jump to search

quick and dirty so far

Plugins

sudo apt-get install curl && \
mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
cd ~/.vim/bundle && \
git clone https://github.com/tpope/vim-fugitive.git && \
vim -u NONE -c "helptags vim-fugitive/doc" -c q
sudo apt-get install exuberant-ctags && \
cd ~/.vim/bundle && \
git clone git://github.com/majutsushi/tagbar
cd ~/.vim/bundle && \
git clone https://github.com/joeytwiddle/vim-diff-traffic-lights-colors
cd ~/.vim/bundle && \
git clone https://github.com/janiczek/vim-latte.git
cd ~/.vim/bundle && \
git clone https://github.com/groenewege/vim-less
echo "ALWAYS_SET_PATH yes" > /etc/default/su

Other

Install current PHP @ debian8+

https://packages.sury.org/php/README.txt

Prepare init samples for

  • makefile example

#!/usr/bin/make -f
include .env

main: deploy

dbrun:
	docker-compose --file ${LOCAL_DB_REPO_PATH}/docker-compose.yml --file ${LOCAL_DB_REPO_PATH}/docker-compose.override.yml up --build -d

ifeq (${LOCAL_DB}, 1)
run: dbrun
endif

run:
	docker-compose --file docker-compose-dev.yml up --build --force-recreate -d

drop:
	docker-compose --file docker-compose-dev.yml down

prune: drop
	docker container prune --force
	docker image prune --force

dcli:
	docker-compose --file ${LOCAL_DB_REPO_PATH}/docker-compose.yml exec postgres bash

pcli:
	docker-compose --file docker-compose-dev.yml exec php-fpm bash

wcli:
	docker-compose --file docker-compose-dev.yml exec web sh

ccli:
	docker-compose --file docker-compose-dev.yml exec composer bash

crcli:
	docker-compose --file docker-compose-dev.yml exec cron bash

update:
	git fetch
	git pull origin `git rev-parse --abbrev-ref HEAD`

deploy: update run clearcache linkgen

st:
	docker-compose --file ./docker-compose-dev.yml ps

clearcache:
	docker-compose --file docker-compose-dev.yml exec php-fpm bash -c \
		"mkdir -p /htdocs/temp/cache \
		&& chmod a+wrx /htdocs/temp \
		&& chmod a+wrx /htdocs/temp/cache \
		&& rm -rf /htdocs/temp/cache/* \
		&& rm -f /htdocs/temp/btfj.dat"

clearlogs:
	docker-compose --file docker-compose-dev.yml exec php-fpm bash -c \
		"mkdir -p /htdocs/log \
		&& chmod a+wrx /htdocs/log \
		&& rm -rf /htdocs/log/* "

buildTestEnv:
	docker run -it --volume=`pwd`:/formService --workdir="/formService" --entrypoint=/bin/bash smartapps/bitbucket-pipelines-php-mysql

testrun: composer
		docker-compose --file docker-compose-dev.yml exec php-fpm bash -c "cd /htdocs && ./composer testpcli"
testdebug: composer
	docker-compose --file docker-compose-dev.yml exec php-fpm bash -c "cd /htdocs && ./composer testdebug"
composer:
	docker-compose --file docker-compose-dev.yml exec php-fpm bash -c "curl https://getcomposer.org/download/1.7.2/composer.phar --output /htdocs/composer && chmod +x /htdocs/composer"

####################################################
# ctags for vim
CTAGS_COMMON_EXCLUDES = \
	--exclude=*.vim \
	--exclude=temp \
	--exclude=log \
	--exclude=*.js \
	--exclude=doc

# ctags
ctags::
	rm -f TAGS
	ctags --recurse \
		--totals=yes \
		$(CTAGS_COMMON_EXCLUDES) \
		.

install-dev: .env ./app/config/config.local.neon
	chmod a+wrx ./log
	mkdir -p ./www/webtemp
	chmod a+wrx ./www/webtemp

.env:
	cp ./.env.sample ./.env
./app/config/config.local.neon:
	cp ./app/config/config.local.neon.sample ./app/config/config.local.neon

.PHONY: linkgen
linkgen:
	@echo "\n Root URL ---> http://127.0.0.1:${LOCAL_PORT}/${LOCATION_ALIAS}"


  • default vhost templates
<VirtualHost 123.123.123.123:80>
    ServerName server.example.com
    ServerAlias cool-server.exaple.com
    ServerAdmin admin@example.com

    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

</VirtualHost>

<VirtualHost 123.123.123.123:443>
    ServerName server.example.com
    ServerAlias cool-server.exaple.com
    DocumentRoot /home/project/Project/public
    ServerAdmin admin@example.com
    ErrorLog /var/log/apache2/project/error_log
    CustomLog /var/log/apache2/project/access_log combined

    # Options
    Options -Indexes

    FileETag none
    SetEnv APPLICATION_ENV production

    # REWRITE RULES
    # Direct all requests to index.php except of existing
    # files or directories

    RewriteEngine on
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -s [OR]
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -l [OR]
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_URI} "/phppgadmin" [OR]
    RewriteCond %{REQUEST_URI} "/email"

    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ /index.php [NC,L]

    #   SSL Engine Switch:
    #   Enable/Disable SSL for this virtual host.
    SSLEngine on

    SSLCertificateFile    /etc/ssl/certs/project.crt
    SSLCertificateKeyFile /etc/ssl/private/project.key
    SSLCertificateChainFile /etc/ssl/certs/project.crt.pem

    # PHPMyAdmin
    Alias /phppgadmin /usr/share/phppgadmin

    # Roundcube
    Alias /email /usr/share/roundcube

    # AUTHENTICATION
    <LocationMatch "^(?!/api/)">
        AuthType Basic
        AuthName "server.example.com"
        AuthUserFile /home/project/Project/public/htpasswd/passwords
        Require valid-user

        Order deny,allow
        Deny from all
        # Office
        Allow from 234.234.234.234
        # Office 2
        Allow from 123.234.123.234 234.123.234.123
        Satisfy Any
    </LocationMatch>

</VirtualHost>