View file vkclone-0.0.1/docs/install-vkclone.md

File size: 4.04Kb
This file describes how to make clean installation of **vkclone script**.

---
## Enviroment
**This section requires you work under root user!** You can check currently logged in user's name by calling `whoami`.

#####1. Install web server, mysql server and client, php with modules, gearman with supervisor and its module for php, memcached
```
apt-get install nginx
apt-get install mysql-server mysql-client
apt-get install php5 php5-gd php5-json php5-memcached php5-mysql php-apc
apt-get install gearman-job-server libgearman-dev supervisor php-pear php5-dev sqlite3
pecl install gearman
echo "extension=gearman.so" > /etc/php5/conf.d/gearman.ini
apt-get install memcached
```

#####2. Create `vkclone` OS user and dir for vkclone script
```
useradd vkclone
mkdir -p /var/www/vkclone
chown vkclone:vkclone /var/www/vkclone
```

#####3. Clone `vkclone` script
```
su vkclone
cd /var/www/vkclone
git clone https://github.com/vkclone/vkclone.git ./
./setup.sh
exit
```

#####4. Copy standart config files.
Available config files:

- `docs/configuration/gearman-job-server/gearman-job-server` - gearman job server configuration. Default dir: **/etc/default/**.
- `docs/configuration/nginx/vkclone` - nginx server configuration. Default dir: **/etc/nginx/sites-enabled/**.
- `docs/configuration/supervisor/vkclone.conf` - supervisor task configuration. Supervisor is used to keep gearman workers online. Default dir: **/etc/supervisor/conf.d/**.

```
cp docs/configuration/gearman-job-server/gearman-job-server /etc/default/
cp docs/configuration/supervisor/vkclone.conf /etc/supervisor/conf.d/
cp docs/configuration/nginx/vkclone /etc/nginx/conf.d/
```

#####5. Open **/etc/php5/fpm/php.ini**, uncomment (delete leading `;`) and change following directives
- `mbstring.internal_encoding` to **UTF-8**
- `date.timezone` to **your timezone**. In my case, it is *Europe/Moscow*.

#####6. Open **/etc/nginx/sites-enabled/vkclone** and change `www.vkclone.ru` and `vkclone.ru` with url of your site.

#####7. Open **/etc/mysql/my.cnf** and set `log-bin-trust-function-creators` in `mysqld` section to **1** for using triggers
```ini
[mysqld]
log-bin-trust-function-creators=1
```

#####8. Restart services
```
supervisorctl update
service gearman-job-server restart
service mysql restart
service nginx restart
```

#####9. libxdiff and xdiff
* Read [docs/install-xdiff](install-xdiff.md)

## Database
#####1. Log under root in mysql
```
mysql -u root -p
```
type root's password and press enter.

#####2. Create `vkclone` and `gearman` database users
Replace `[password]` with any password you want.
```sql
mysql> CREATE DATABASE `vkclone` DEFAULT CHARACTER SET = 'utf8';
mysql> CREATE USER 'vkclone'@'localhost' IDENTIFIED BY '[password]';
mysql> GRANT ALL PRIVILEGES ON `vkclone`.* TO 'vkclone'@'localhost';
mysql> CREATE USER 'gearman'@'localhost' IDENTIFIED BY 'gearman';
mysql> GRANT ALL PRIVILEGES ON `vkclone`.`gearman_queue` TO 'gearman'@'localhost';
mysql> FLUSH PRIVILEGES;
```

#####3. Close mysql console
```sql
mysql> \q
```

#####4. Import timezone data
```
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
```

## vkclone
#####1. Log in under `vkclone` user and go to the vkclone directory
```
su vkclone
cd /var/www/vkclone
```

#####2. Clone vkclone submodules. It cat take a few minutes depending on download speed of your internet provider.
```
git submodule init
git submodule update
```

#####3. Open **protected/config/local/params.php** and set `adminEmail` to your email.

#####4. Open **protected/config/local/database.php** and change database connection params:
- `[database]` - database name. Replace it with `vkclone`.
- `[username]` - database username. Replace it with `vkclone`.
- `[password]` - user password. Replace it with password you used in step **Database. 2. Create `vkclone` and `gearman` database users**.

#####5. Init database. Init rbac information. Create **admin account**.
```
cat protected/database/*.sql | mysql -u vkclone -p vkclone # then type [password] and press Enter.
./protected/yiic users initRbac
./protected/yiic users initAdmin
```

---
**Installation is done!**