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
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
update-alternatives --config editor
apt-get install sudo
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>
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
Download it
curl -sS https://getcomposer.org/installer | php
install it globally
sudo mv composer.phar /usr/local/bin/composer
Bower depends on node.js and npm...
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
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
sudo npm install -g bower
check
bower -v
[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
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
make executable
chmod +x ~/git/<domain.tld>.git/hooks/post-receive
git remote add production ssh://<userName>@<ip|domain>/~/git/<domain.tld>.git
check it
git ls-remote production
git push -f production master
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