Skip to content

Instantly share code, notes, and snippets.

@vool
Last active June 19, 2020 15:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vool/0400278cd161437fef06 to your computer and use it in GitHub Desktop.
Save vool/0400278cd161437fef06 to your computer and use it in GitHub Desktop.
Debain standard setup

Debain setup

Default set up for git deploy web-server on debian box [for a laravel site but also pretty generic]

There a good guide (for ubuntu) here

Update and install

apt-get update && apt-get upgrade

apt-get install apache2 curl mysql-server php5 php-pear php5-mysql php5-mcrypt phpmyadmin git

mysql_secure_installation

Set vim as default editor

update-alternatives --config editor

install sudo ?

apt-get install sudo

Add new user

adduser < userName >

####      Allow ssh access ####

vi /etc/ssh/sshd_config

      add

AllowUsers <userName>

####      Add newuser to sudoers ####

visudo

       add the user

<userName> ALL=(ALL:ALL) ALL

       add the user to web server [www-data] group

usermod -a -G www-data <userName>

Setup site

make dir

mkdir /var/www/<domain.tld>

Set ownership to apache [www-data]

sudo chown -R www-data:www-data /var/www/<domain.tld>

Set group write access

sudo chmod -R 770 /var/www/<domain.tld>

might need after push ???

sudo chmod -R g+w /var/www/<domain.tld>/app/storage/

edit site config

vi /etc/apache2/sites-available/default

or might be

vi /etc/apache2/sites-available/000-default

set document an server root

DocumentRoot /var/www/<domain.tld>/public/

<Directory /var/www/<domain.tld>/public/>

the '/public/' is for laravel, ommit if not a laravel project

set AllowOverride for .htaccess

AllowOverride All

Enable mod rewrite

sudo a2enmod rewrite

service apache2 restart

Set up composer

Download it

curl -sS https://getcomposer.org/installer | php

install it globally

sudo mv composer.phar /usr/local/bin/composer

Setup Bower ?

Bower depends on node.js and npm...

Install node.js

This is a bit fiddly on debian, might be good to check that this have changed or debian package is available

Update March '15 https://nodesource.com/blog/nodejs-v012-iojs-and-the-nodesource-linux-repositories

[ might need to su here ]

node.js is available in wheezy-backports add to source.list

echo "deb http://mirror.ovh.net/ftp.debian.org/debian wheezy-backports main" >> /etc/apt/sources.list

Update and upgrade apt

apt-get update && apt-get upgrade

install node.js

sudo apt-get install nodejs

check

nodejs -v

Install npm

This expects node to be node but this install seems to be at nodejs if this is the case we can alias with a symlink

sudo ln -s /usr/bin/nodejs /usr/bin/node

Install npm

curl -L http://npmjs.org/install.sh | sudo sh

Note the -L , getting a 301 error otherwise

check

npm -v

Install Bower

sudo npm install -g bower

check

bower -v

NOTE - Environments

[Laravel] Before pushing make sure that the environments are set up, eg :

database settings in app/config/production/database.php

.env.php strings set and uploaded to remote

Setup Git repo

create and enter dir

mkdir -p ~/git/<domain.tld>.git && cd ~/git/<domain.tld>.git

init bare git repo

git init --bare

create post receive hook

vi hooks/post-receive

Sample post receive hook here

make executable

chmod +x ~/git/<domain.tld>.git/hooks/post-receive

Add remote ref to LOCAL repo

git remote add production ssh://<userName>@<ip|domain>/~/git/<domain.tld>.git

check it

git ls-remote production

Push the repo

git push -f production master

Fix permissions

If there is an issue with writing to storage ? Laravel need to be able to write to app/storage so either change the permissions, or make the web server [www-data] the owner.

sudo chown -r www-data:www-data /var/www/<domain.tld>/app/storage/

chgrp -R www-data /var/www/<domain.tld>

chmod -R 775 /var/www/<domain.tld>/storage

TODO

database

laravel cache permissions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment