2
0
mirror of https://github.com/frappe/bench.git synced 2024-09-22 20:19:01 +00:00
bench/README.md

240 lines
7.3 KiB
Markdown
Raw Normal View History

2014-07-15 09:17:32 +00:00
Bench
=====
2014-07-25 06:00:47 +00:00
The bench allows you to setup Frappe / ERPNext apps on your local Linux (CentOS 6, Debian 7 or Ubuntu) machine or a production server. You can use the bench to serve multiple frappe sites.
To do this install, you must have basic information on how Linux works and should be able to use the command-line. If you are looking easier ways to get started and evaluate ERPNext, [download the Virtual Machine or take a free trial at FrappeCloud.com](https://erpnext.com/use).
For questions, please join the [developer forum](https://groups.google.com/group/erpnext-developer-forum).
2014-07-15 09:17:32 +00:00
2014-07-15 05:48:04 +00:00
Installation
============
Easy way
--------
2014-10-14 05:45:40 +00:00
Supported for CentOS 6, CentOS 7, Debian 7 and Ubuntu 12.04+
2014-07-15 05:48:04 +00:00
2014-07-25 06:00:47 +00:00
Open your Terminal and enter:
2014-07-31 04:34:01 +00:00
```
wget https://raw.githubusercontent.com/frappe/bench/master/install_scripts/setup_frappe.sh
sudo bash setup_frappe.sh
```
2014-07-15 05:48:04 +00:00
This script should install the pre-requisites and add a bench command.
2014-07-31 20:09:57 +00:00
Manual Install
--------------
2014-07-15 05:48:04 +00:00
Install pre-requisites,
2014-07-15 07:10:45 +00:00
* Python 2.7
* MariaDB
* Redis
2014-08-18 07:05:44 +00:00
* [wkhtmltopdf](http://wkhtmltopdf.org/downloads.html) (optional, required for pdf generation)
2014-07-31 10:10:21 +00:00
* Memcached
2014-07-15 05:48:04 +00:00
2014-07-31 20:09:57 +00:00
Install bench as a *non root* user,
2014-07-15 05:48:04 +00:00
2014-07-22 08:49:22 +00:00
git clone https://github.com/frappe/bench bench-repo
2014-07-21 16:55:50 +00:00
sudo pip install -e bench-repo
2014-07-15 09:17:32 +00:00
Note: Please do not remove the bench directory the above commands will create
2014-07-15 05:48:04 +00:00
2014-07-25 06:00:47 +00:00
Installing ERPNext
------------------
2014-07-23 12:55:02 +00:00
If you're here to setup ERPNext, continue with [ERPNext setup](https://github.com/frappe/bench#setting-up-erpnext)
2014-07-25 06:00:47 +00:00
2014-07-25 06:34:21 +00:00
Migrating from existing installation
------------------------------------
2014-07-25 06:34:21 +00:00
If want to migrate from ERPNext version 3, follow the instructions here, https://github.com/frappe/bench/wiki/Migrating-from-ERPNext-version-3
2014-07-25 06:29:42 +00:00
2014-07-25 06:34:21 +00:00
If want to migrate from the old bench, follow the instructions here, https://github.com/frappe/bench/wiki/Migrating-from-old-bench
2014-07-15 05:48:04 +00:00
2014-07-15 07:10:45 +00:00
Basic Usage
===========
2014-07-15 05:48:04 +00:00
* Create a new bench
2014-07-15 07:10:45 +00:00
2014-07-16 09:58:13 +00:00
The init command will create a bench directory with frappe framework
2014-07-15 09:17:32 +00:00
installed. It will be setup for periodic backups and auto updates once
a day.
2014-07-23 12:51:31 +00:00
bench init frappe-bench && cd frappe-bench
2014-07-15 05:48:04 +00:00
* Add apps
2014-07-15 07:10:45 +00:00
2014-07-15 09:17:32 +00:00
The get-app command gets and installs frappe apps. Examples include
2014-07-23 12:55:02 +00:00
[erpnext](https://github.com/frappe/erpnext) and
[shopping-cart](https://github.com/frappe/shopping-cart)
2014-07-15 09:17:32 +00:00
bench get-app erpnext https://github.com/frappe/erpnext
2014-07-15 05:48:04 +00:00
* Add site
2014-07-15 07:10:45 +00:00
2014-07-15 09:17:32 +00:00
Frappe apps are run by frappe sites and you will have to create at least one
site. The new-site command allows you to do that.
2014-07-15 07:10:45 +00:00
bench new-site site1.local
2014-07-15 05:48:04 +00:00
2014-07-15 09:17:32 +00:00
* Start bench
To start using the bench, use the `bench start` command
2014-07-15 07:10:45 +00:00
2014-07-15 09:17:32 +00:00
bench start
2014-07-15 07:10:45 +00:00
2014-10-21 09:03:54 +00:00
To login to Frappe / ERPNext, open your browser and go to `localhost:8000`
The default user name is "Administrator" and password is what you set when you created the new site.
2014-07-15 07:10:45 +00:00
2014-07-24 09:24:00 +00:00
Setting Up ERPNext
==================
To setup a bench that runs ERPNext, run the following commands
```
cd ~
bench init frappe-bench
cd frappe-bench
bench get-app erpnext https://github.com/frappe/erpnext # Add ERPNext to your bench apps
bench get-app shopping_cart https://github.com/frappe/shopping-cart # Add Shopping cart to your bench apps
bench new-site site1.local # Create a new site
bench frappe --install_app erpnext site1.local # Install ERPNext for the site
bench frappe --install_app shopping_cart site1.local # Install Shopping cart for the site
```
You can now either use `bench start` or setup the bench for production use.
2014-07-16 08:39:16 +00:00
Updating
========
2014-07-16 09:58:13 +00:00
On initializing a new bench, a cronjob is added to automatically update the bench
2014-07-16 08:39:16 +00:00
at 1000hrs (as per the time on your machine). You can disable this by running
`bench config auto_update off` and run `bench config auto_update on` to switch
it on again. To change the time of update, you will have to edit the cronjob
manually using `crontab -e`.
To manually update the bench, run `bench update` to update all the apps, run
patches, build JS and CSS files and restart supervisor (if configured to).
You can also run the parts of the bench selectively.
`bench update --pull` will only pull changes in the apps
2014-07-16 08:41:50 +00:00
2014-07-16 08:39:16 +00:00
`bench update --patch` will only run database migrations in the apps
2014-07-16 08:41:50 +00:00
2014-07-16 08:39:16 +00:00
`bench update --build` will only build JS and CSS files for the bench
2014-07-16 08:41:50 +00:00
2014-07-16 08:39:16 +00:00
`bench update --bench` will only update the bench utility (this project)
Running the bench
==================
To run the bench,
*For development*: `bench start`
2014-07-16 08:41:50 +00:00
2014-07-16 08:39:16 +00:00
*For production*: Configure supervisor and nginx
To run the bench, a few services need to be running apart from the processes.
External services
-----------------
* MariaDB (Datastore for frappe)
* Redis (Broker for frappe background workers)
* nginx (for production deployment)
* supervisor (for production deployment)
Frappe Processes
----------------
* WSGI Server
* The WSGI server is responsible for responding to the HTTP requests to
frappe. In development scenario (`frappe --serve` or `bench start`), the
Werkzeug WSGI server is used and in production, gunicorn (automatically
2014-07-16 09:58:13 +00:00
configured in supervisor) is used.
2014-07-16 08:39:16 +00:00
* Celery Worker Processes
2014-07-16 09:58:13 +00:00
* The Celery worker processes execute background jobs in the Frappe system.
2014-07-16 08:39:16 +00:00
These processes are automatically started when `bench start` is run and
2014-07-16 09:58:13 +00:00
for production are configured in supervisor configuration.
2014-07-16 08:39:16 +00:00
* Celery Worker Beat Process
2014-07-16 09:58:13 +00:00
* The Celery worker beat process schedules enqeueing of scheduled jobs in the
2014-07-16 08:39:16 +00:00
Frappe system. This process is automatically started when `bench start` is
2014-07-16 09:58:13 +00:00
run and for production are configured in supervisor configuration.
2014-07-16 08:39:16 +00:00
2014-07-15 07:10:45 +00:00
Production Deployment
=====================
You can setup the bench for production use by configuring two programs,
Supervisor and nginx.
Supervisor
----------
Supervisor makes sure that the process that power the Frappe system keep running
and it restarts them if they happen to crash. You can generate the required
configuration for supervisor using the command `bench setup supervisor`. The
configuration will be available in `config/supervisor.conf` directory. You can
then copy/link this file to the supervisor config directory and reload it for it to
take effect.
eg,
```
bench setup supervisor
sudo ln -s `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe.conf
```
2014-10-13 14:34:31 +00:00
Note: For CentOS 7, the extension should be `ini`, thus the command becomes
```
bench setup supervisor
sudo ln -s `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe.ini #for CentOS 7 only
```
2014-07-15 07:10:45 +00:00
The bench will also need to restart the processes managed by supervisor when you
update the apps. To automate this, you will have to setup sudoers using the
2014-09-03 06:36:31 +00:00
command, `sudo bench setup sudoers $(whoami)`.
2014-07-15 07:10:45 +00:00
Nginx
-----
Nginx is a web server and we use it to serve static files and proxy rest of the
requests to frappe. You can generate the required configuration for nginx using
the command `bench setup nginx`. The configuration will be available in
`config/nginx.conf` file. You can then copy/link this file to the nginx config
directory and reload it for it to take effect.
eg,
```
2014-08-07 09:55:10 +00:00
bench setup nginx
2014-07-15 07:10:45 +00:00
sudo ln -s `pwd`/config/nginx.conf /etc/nginx/conf.d/frappe.conf
```
2014-07-16 08:39:16 +00:00
Note: When you restart nginx after the configuration change, it might fail if
you have another configuration with server block as default for port 80 (in most
2014-07-16 09:58:13 +00:00
cases for the nginx welcome page). You will have to disable this config. Most
2014-07-16 08:39:16 +00:00
probable places for it to exist are `/etc/nginx/conf.d/default.conf` and
`/etc/nginx/conf.d/default`.
2014-07-21 11:18:41 +00:00
Multitenant setup
=================
Follow https://github.com/frappe/bench/wiki/Multitenant-Setup