-
Notifications
You must be signed in to change notification settings - Fork 512
Running Greasy Fork locally
Greasy Fork is a Ruby on Rails site running on Passenger/nginx. This method will first describe how to only deploy the Rails portion of the code using the built-in Rails web server. To run with PHP (for the forum), you will need to install Passenger/nginx, which is more difficult.
The regular GitHub way.
From the Greasy Fork directory:
- Install bundler -
gem install bundler - Install required gems -
bundle install
Start MySQL, log in as root, and run:
CREATE USER 'yourmysqlusername'@'localhost' IDENTIFIED BY 'yourmysqluserpassword';
CREATE SCHEMA greasyfork;
GRANT ALL ON greasyfork.* TO 'yourmysqlusername'@'localhost';
CREATE SCHEMA greasyforktest;
GRANT ALL ON greasyforktest.* TO 'yourmysqlusername'@'localhost';Now run mysql -uyourmysqlusername -p greasyfork < db/structure.sql. This gives you a blank site.
To get some real data in there, download the public data dump, then import it: gunzip -c db.sql.gz | mysql -uyourmysqlusername -p greasyfork.
Files with passwords and such.
config/database.yml
development:
adapter: mysql2
database: greasyfork
username: yourmysqlusername
password: yourmysqlpassword
host: 127.0.0.1
port: '3306'
encoding: utf8mb4
collation: utf8mb4_unicode_ci
test:
adapter: mysql2
database: greasyforktest
username: yourmysqlusername
password: yourmysqlpassword
host: 127.0.0.1
port: '3306'
encoding: utf8mb4
collation: utf8mb4_unicode_ciconfig/secrets.yml
development:
secret_key_base: # run rake secret
devise_secret_key: # also rake secret, but different value than above
detect_language_api_key: # optional, for language detection on script update. get a free API key at http://detectlanguage.com/
# values here can be the same as above
test:
secret_key_base:
devise_secret_key:
detect_language_api_key:-
rake ts:configure- configure Sphinx -
indexer -c config/development.sphinx.conf --all- build sphinx index -
rake ts:start- start Sphinx -
bin/delayed_job start- start delayed_job -
rails server- start the web server - Go to
http://localhost:3000/
To enable the forum, you need a web server that supports PHP. Greasy Fork uses Passenger, which comes with nginx, which supports PHP. Fair warning, this gets a lot more involved than the stuff above, and there's probably some steps missing.
- Install passenger -
gem install passenger - Run
passenger-install-nginx-moduleand do what it says - Download Vanilla.
- Install php-fpm
- Configure nginx. Put this in the
serverblock:
# Add trailing slash to paths like /forum and /en/forum
rewrite ^(/[a-z][a-z](\-[A-Z][A-Z])?)?/forum$ $request_uri/ permanent;
# Rewrite locale path segment to be a request parameter
location ~ ^(?:/([a-z][a-z](?:\-[A-Z][A-Z])?))/forum/ {
set $args $args&locale=$1;
rewrite ^(?:/[a-z][a-z](?:\-[A-Z][A-Z])?)/forum/(.*) /forum/$1 last;
}
location /forum/ {
index index.php;
try_files $uri $uri/ @forum;
passenger_enabled off;
# Stop things from executing in the uploads directory
location ~* ^/uploads/.*.(html|htm|shtml|php)$ {
types { }
default_type text/plain;
}
location ~ /forum/\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
location ^~ /forum/conf/ { internal; }
location ~ /forum/.*\.php {
include fastcgi.conf;
try_files $uri =404; # This is not needed if you have cgi.fix_pathinfo = 0$
# include locale as path segment
fastcgi_param PHP_VALUE "auto_prepend_file=$document_root/forum/plugins/LanguageByPath/prepend.php";
fastcgi_pass 127.0.0.1:9000;
}
}
location @forum {
autoindex off;
passenger_enabled off;
rewrite ^/forum(.+)$ /forum/index.php?p=$1 last;
}
location ~ /forum/.*\.php {
include fastcgi.conf;
passenger_enabled off;
try_files $uri =404; # This is not needed if you have cgi.fix_pathinfo = 0$
fastcgi_pass 127.0.0.1:9000;
}
- Create a symlinks:
- From public/forum in the Rails app to the root directory of the Vanilla install.
- From plugins/greasyfork in the Vanilla install to misc/greasyfork-plugin in the Vanilla install.
- From themes/greasyfork in the Vanilla install to misc/greasyfork-theme in the Vanilla install.
- Apply some patches to the forum.
- Install the following plugins from Vanilla:
- All Viewed
- Choose Your Own Format
- DiscussionAbout
- Extra Discussion Data
- FileUpload
- Flagging
- Language By Path
- Quotes
- Recent Discussion Filter
- Syntax Prettifier
- User Agent
- Vanilla jsConnect
-
sudo /opt/nginx/sbin/nginx- start nginx - Go to
http://localhost/forum
This was written from memory and likely has errors and omissions. Please file a ticket or ask in the forum for help.