savage-lands/share/readmes/gandi.md
2025-04-17 00:41:48 +03:00

233 lines
5.7 KiB
Markdown

## links
#### gandi
[connecting to gandi server](https://wiki.gandi.net/en/hosting/using-linux/how_to_connect_ai)
[accessing the server via ssh](https://wiki.gandi.net/en/hosting/using-linux/server-access)
[first steps with gandi server](https://wiki.gandi.net/en/hosting/gandi-expert/setup)
#### visudo
[configuring visudo](http://askubuntu.com/questions/539243/how-to-change-visudo-editor-from-nano-to-vim)
#### users
[tecmint.com complete guide to users](http://www.tecmint.com/add-users-in-linux/)
[How To Configure SSH Key-Based Authentication on a Linux Server](https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server)
#### postgres
[ubuntu community postgres docs](https://help.ubuntu.com/community/PostgreSQL)
## adding/deleting users
#### adding a user:
*("www-data" is the group name for website stuff on gandi)*
> *sudo useradd -G* ***www-data*** *-d /home/****username*** *-m -s /bin/bash* ***username***
***-G group*** adds the groups in a comma separated
***-d /home/username*** specifies the home directory to be created (necessary on ubuntu)
***-m*** flag to create scripts (necessary)
***-s /bin/bash*** what shell is to be used (default is none)
#### deleting a user
userdel -r {username}
## IMPORTANT
### set users primary group
**this is critical**
sudo usermod <username> -g www-data
### setting up ssh authentication
cat ~/.ssh/id\_rsa.pub | ssh **username@remote\_host** "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized\_keys"
## apt-get commands
**to see the package version:**
dpkg -s postgresql | grep Version
# setting up gandi server
## creating the server instance
after logging in, go to the virtual machine setup tab under *services* -> *servers*
[virtual machine](https://www.gandi.net/admin/iaas/vm)
under "servers" click "create a server". At the setup page you will have the option of either using an public ssh key, a password, or both. Pick both.
1. generate a password
2. go to ~/.ssh and look for something like *id_rsa.pub*
3. to put in on the clipboard, on OSX type *cat ~/.ssh/id_rsa.pub | pbcopy*
4. paste what's in the clipboard into the ssh input section
5. copy all this information down and start it up
## first steps with server
next follow the links under "gandi"
while you are doing the commands link *"first steps with gandi server"* you may want to do this command:
su -c 'apt-get install sudo'
su -c 'apt-get install vim'
after setting up "first steps with gandi server" above, you will want to configure visudo to use vim
### setup visudo
su -c 'update-alternatives --config editor'
su -c 'visudo'
find this line:
USERNAME ALL=(ALL) NOPASSWD: ALL
replace it with:
admin ALL=(ALL) ALL
(or whatever user name you are mainly using)
## add new user
1. *sudo useradd -G* ***www-data*** *-d /home/****username*** *-m -s /bin/bash* ***username***
2. *mkdir projectdir*
### set users primary group
**this is critical**
sudo usermod <username> -g www-data
### set password
sudo passwd <username>
### setting up ssh authentication
cat ~/.ssh/id\_rsa.pub | ssh **username@remote\_host** "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized\_keys"
### apt-get setup
sudo apt-get update
sudo apt-get install aptitude
## postgres
#### links fix locale error with postgres
[could not connect to server solution](http://askubuntu.com/questions/50621/cannot-connect-to-postgresql-on-port-5432)
[locale solution](http://ubuntuforums.org/showthread.php?t=1346581)
[remote connecting](http://www.railszilla.com/postgresql-tcpip-connections-port-5432/coffee-break)
sudo apt-get install postgresql
sudo apt-get install postgresql-contrib
sudo locale-gen en_US en_US.UTF-8 hu_HU hu_HU.UTF-8
sudo dpkg-reconfigure locales
sudo service postgresql restart
sudo -u postgres psql postgres
sudo -u postgres createdb **website_dbname**
sudo apt-get install postgresql-server-dev-X.Y
sudo apt-get install postgresql-server-dev-9.3
#### change password for db user "postgres"
sudo -u postgres psql postgres
ALTER USER Postgres WITH PASSWORD '<newpassword>';
#### set up postgresql to remote access
######(see "remote connecting" link above)
#####Note: be careful with this, because **anyone** will be able to mess around with it
1. sudo vim /etc/postgresql/9.3/main/postgresql.conf
2. find **listen\_addresses** and change it to **listen\_addresses = '\*'**
3. sudo vim /etc/postgresql/9.3/main/pg_hba.conf
4. find **host all all 127.0.0.1/32 trust** and change **127.0.0.1/32** to **0.0.0.0/0**
5. sudo service postgresql restart
6. test it by running: *psql -h* ***ip\_address*** *-U* ***username*** *-d* ***database***
7. e.g. psql -h 173.246.107.96 -U postgres postgres
### setup the /var/www directory
cd /var
sudo mkdir www
sudo chgrp www-data www -R
sudo chmod g+w www -R
### install python packages
sudo apt-get install python-dev
sudo apt-get install libjpeg-dev
## install and set up supervisor
sudo apt-get install supervisor
make sure www-data is a group for the main user
vim /etc/supervisor/supervisord.conf
add the following:
[unix_http_server]
file=/var/run//supervisor.sock
chmod=0770
chown=nobody:www-data
[supervisorctl]
serverurl=unix:///var/run//supervisor.sock
chmod=0770
chown=nobody:www-data
#### run the following commands:
sudo service supervisor stop
sudo service supervisor start
### install pip and virtualenv
[virtualenv install](http://roundhere.net/journal/virtualenv-ubuntu-12-10/)
sudo apt-get install python-pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper
### install nginx
sudo apt-get install nginx
# bootstrap server
fab (prod|rel) deploy.bootstrap