Project

General

Profile

Support #718

Updated by Daniel Curtis over 7 years ago

This is a guide on how I installed the Firefox Auth and Content components to form the Firefox Accounts Server on FreeBSD. 

 h2. Prepare the Environment 

 * Make sure the system is up to date: 
 <pre> 
 pkg update && pkg upgrade -y 
 </pre> 

 * Install a few dependencies: 
 <pre> 
 pkg install portmaster bash git gmp graphicsmagick redis gmake python2 py27-virtualenv sqlite py27-sqlite3 gcc48 scrypt 
 </pre> 

 * Install node4 and npm2 from ports: 
 <pre> 
 portmaster www/node4 www/npm2 
 </pre> 

 * Add the Firefox Accounts user: 
 <pre> 
 pw add user -n ff-accounts -m -s /bin/sh -c "Firefox Accounts" 
 </pre>  
 * Create a symlink for bash in order for the fxa-local-dev package to install correctly: 
 <pre> 
 ln -s /usr/local/bin/bash /bin/bash 
 </pre>  

 h2. Install Accounts Server 

 * Switch to the Firfox accounts user: 
 <pre> 
 su - ff-accounts 
 </pre> 

 * Then set the CC, CXX, and CPP environment variables to use GCC instead of Clang: 
 <pre> 
 export CC=gcc48 
 export CXX=g++48 
 export CPP=cpp48 
 </pre> 

 * Download the local development setup scripts from GitHub: 
 <pre> 
 git clone https://github.com/mozilla/fxa-local-dev 
 </pre> 

 * Edit the @install_all.sh@ setup script: 
 <pre> 
 cd fxa-local-dev 
 vi _scripts/install_all.sh 
 </pre> 
 #* On line 45, change the make build to gmake build: 
 <pre> 
 cd syncserver; gmake build; cd .. 
 </pre> 

 * Install the local development scripts: 
 <pre> 
 npm install 
 </pre> 

 * When the install finishes the scripts will automatically start all of the Firefox Accounts components. When the components finish loading open a web browser and go to http://localhost:3030 

 * To stop the Firefox Accounts server use pm2: 
 <pre> 
 ./pm2 kill 
 exit 
 </pre> 
 #* *NOTE*: By default, account information is stored in memory and +will not be saved+ if the server reboots. 

 h3. MySQL Database 

 * Install MariaDB: 
 <pre> 
 pkg install mariadb100-server 
 </pre> 

 * Start and enable MariaDB at boot: 
 <pre> 
 echo 'mysql_enable="YES"' >> /etc/rc.conf 
 service mysql-server start 
 </pre> 

 * Secure the mysql installation: 
 <pre> 
 mysql_secure_installation 
 </pre> 

 * Log into the MySQL console: 
 <pre> 
 mysql -u root -p 
 </pre> 
 #* Create the fxauser user with the SuperSecretPassword password and the fxadb database: 
 <pre> 
 CREATE USER 'fxauser'@'localhost' IDENTIFIED BY 'SuperSecretPassword';    
 CREATE DATABASE IF NOT EXISTS    `fxadb` CHARACTER SET utf8 COLLATE utf8_general_ci; 
 GRANT ALL PRIVILEGES ON `fxadb`.* TO 'fxauser'@'localhost'; 
 </pre> 
 #* Create the fxasyncuser user with the SuperDuperPassword password and the fxasyncdb database: 
 <pre> 
 CREATE USER 'fxasyncuser'@'localhost' IDENTIFIED BY 'SuperDuperPassword';    
 CREATE DATABASE IF NOT EXISTS    `fxasyncdb` CHARACTER SET utf8 COLLATE utf8_general_ci; 
 GRANT ALL PRIVILEGES ON `fxasyncdb`.* TO 'fxasyncuser'@'localhost'; 
 </pre> 
 #* Exit the mysql console: 
 <pre> 
 

 flush privileges; 
 exit 
 </pre> 

 h2. Install Accounts Server 

 * Switch to the Firfox accounts Firefox Accounts user: 
 <pre> 
 su - ff-accounts 
 </pre> 

 * Download the firefox auth server from GitHub: 
 <pre> 
 git clone https://github.com/mozilla/fxa-auth-server.git 
 cd fxa-auth-server 
 </pre> 

 * Install the auth server: 
 <pre> 
 npm install 
 </pre> 
 #* And test the auth server: 
 <pre> 
 npm start 
 </pre> 
 *NOTE*: Press Ctrl+C Switch to stop the test server. 

 * Download the firefox content server from GitHub: fxa-local-dev directory: 
 <pre> 
 cd .. fxa-local-dev 
 git clone https://github.com/mozilla/fxa-content-server.git 
 cd fxa-content-server 
 </pre> 

 * Install Stop the content server: Firefox Account Servers: 
 <pre> 
 npm install ./pm2 kill 
 </pre> 
 #* And test the content server: 
 <pre> 
 npm run start-remote 
 </pre> 
 *NOTE*: Press Ctrl+C to stop the test server.  

 * Create a dev Edit the servers.json config file: 
 <pre> 
 vi ~/fxa-auth-server/config/dev.js servers.json 
 </pre> 
 #* And modify the "oauth-server PORT 9010" and "oauth-server-internal PORT 9011" objects and add the following: MySQL environment variables: 
 <pre> 
 
     { 
   "master": 
       "name": "oauth-server PORT 9010", 
       "script": "bin/server.js", 
       "cwd": "fxa-oauth-server", 
       "env": { 
     "user": 
         "NODE_ENV": "prod", 
         "DB": "mysql", 
         "MYSQL_USERNAME": "fxauser", 
     "password": 
         "MYSQL_PASSWORD": "SuperSecretPassword", 
     "database": 
         "MYSQL_DATABASE": "fxadb", 
         "MYSQL_HOST": "127.0.0.1" 
       }, 
       "max_restarts": "1", 
       "min_uptime": "2m" 
     "host": "db.example.com", 
     "port": "3306" 
   }, 
   "slave": 
      { 
     "user": 
       "name": "oauth-server-internal PORT 9011", 
       "script": "bin/internal.js", 
       "cwd": "fxa-oauth-server", 
       "env": { 
         "NODE_ENV": "prod", 
         "DB": "mysql", 
         "MYSQL_USERNAME": "fxauser", 
     "password": "SuperSecretPassword" 
     "database": 
         "MYSQL_PASSWORD": "SuperSecretPassword", 
         "MYSQL_DATABASE": "fxadb", 
         "MYSQL_HOST": "127.0.0.1" 
       }, 
       "max_restarts": "1", 
       "min_uptime": "2m" 
     "host": "db.example.com", 
     "port": "3306" 
   } }, 
 } </pre> 
 </pre> 

 * Start the server *NOTE*: Additional environment variables are stored in dev MySQL store mode: 
 <pre> 
 npm run start-mysql 
 </pre> fxa-oauth-server/lib/config.js 

 h2. Firefox Sync Server 

 * Get the latest version of the syncserver: 
 <pre> 
 cd ~ 
 git clone https://github.com/mozilla-services/syncserver.git 
 cd syncserver 
 </pre> 

 * Build the Sync Server: 
 <pre> 
 gmake build 
 </pre> 

 * Edit the syncserver config file: 
 <pre> 
 vi syncserver.ini 
 </pre> 
 #* And modify restart the following values: Firefox Accounts Servers: 
 <pre> 
 [syncserver] ./pm2 start servers.json 
 public_url = http://ff-sync.example.com:5000/ 
 sqluri = pymysql://fxasyncuser:SuperDuperPassword@db.example.com/fxasyncdb 
 </pre> 

 * Test run the syncserver: 
 <pre> 
 gmake serve 
 </pre> 

 h2. Connect Firefox 

 h2. Resources 

 * https://docs.services.mozilla.com/howtos/run-fxa.html 
 * https://docs.services.mozilla.com/howtos/run-sync-1.5.html 
 * https://github.com/mozilla/fxa-auth-server/ 
 * https://github.com/mozilla/fxa-content-server/

Back