======Install EgoWeb 2.0====== ======Installation Overview====== EgoWeb 2.0 has been optimized for running on a web server and providing access to authoring and administering social network data collection interviews over the web, but it can also be installed on stand-alone machines and run locally through web browsers without use of the internet. Below are instructions for the various types of installations. //NOTE:// The Linux instructions below assume a web server and the Windows and Mac instructions assume local installation, but the Linux instructions apply to a local installation and EgoWeb 2.0 can also be run on a Windows or Mac based web server. ======Desktop and Laptop Installations====== Although EgoWeb 2.0 was designed to be installed and run on a web server broadcasting over the internet, it can also be installed onto a single machine and run as a local server only. Stand-alone Linux machines can run the instructions above. Windows and Mac machine installation instructions are below. This installation will not allow use of some of the features that require the internet, such as sending links to respondents to fill out EgoWeb 2.0 surveys or for using EgoWeb 2.0 mobile. ----- ====Install EgoWeb 2.0 on a Windows machine==== UPDATE FROM DAVE K 9 NOV 18: Newer versions of WAMP are no longer working with EgoWeb so we are switching to AMPPS. There are some beneifts to this. The instructions are easier for AMPPS and they are nearly identical for Macs and Windows machines. Before starting to install the programs that need to run to use EgoWeb, go to www.github.com and download the latest zip file from the EgoWeb 2.0 Github repository [[https://github.com/qualintitative/egoweb/tree/dev|located here]] and extract its contents onto the desktop. Unzip the file somewhere you can access it later. The link is to the "dev" branch of EgoWeb 2.0. There is a "Master" branch as well as a "dev" branch. Currently "dev" has much more updated code and is close to being made the master branch, but testing for a few new features and bug fixes is in progress. There are known bugs in the master branch that will be fixed once we update from dev, so we recommend using dev for now. The master branch cannot be installed with newer versions of PHP because we had to change the encryption library which was no longer supported. **1) Install AMPPS** * Download AMPPS. You can get different versions at the [[https://www.ampps.com/downloads|AMPPS download page]]). Install by running the .exe installer file and accepting the defaults. When testing this, we also ran the C++ Redistributable Visual Studio installation that was an option by clicking "Yes" when the dialog box came up during installation. If you have a firewall program running, you may also be prompted to grant permission to MySQL, which you should allow. **2) Configure AMPPS** * If it is not already running after installation, start the AMPPS app. It will be located somewhere on your local hard drive where program files are stored (e.g. C:\Program Files\Ampps or C:\Program Files (x86)\Ampps). AMPPS will start the Apache and mySQL servers as the application boots up, and you should see both of them marked as "running" in the AMPPS app. ****NOTE****: If Apache is not running when you start AMPPS and if it does not start when you click "ON", you may have Apache already running with some other program. It is typically turned off by default but if you have installed some other program that runs Apache, it might be running and needs to be shut down in order to run it through AMPPS. **3) Create default Egoweb database** * Open a browser and go to "http://localhost/phpmyadmin. * In the PHPMyAdmin browser window, click on "Databases". Under "Create database", put in "egoweb" for the database name (all lowercase) and select "utf8mb4_unicode_ci" for the collation. (We have previously recommended utf8_general_ci for fast performance, but that may have issues with special characters). * Click create. A new database named "egoweb" should appear in the left sidebar. ** 4) Import database structure from SQL file** * In the phpMyAdmin browser window, click on the new database "egoweb" that you just created on the left hand side of the page. When the egoweb database structure appears in the middle of the page, select "Import" from the top navigation bar. * Under "File to Import:" you will browse your computer to find a file to import. Click on the "Choose File" button in the section under "File to import". Navigate to the egoweb folder you extracted from the .zip file downloaded from github. Find the "sql" folder, open it, you will see "egoweb_db.sql". Select this file and click OK. * After the file is selected (you will see "egoweb_db.sql" next to the "Choose File" button), click on "Go" at the bottom of the page. The EgoWeb database will now be populated with all of the tables needed to run EgoWeb on your Windows machine. **5) Add user privileges to egoweb database** * At the top menu of the phpMyAdmin page, click on the "Privileges" menu option. Click on the "Add User" link. The default username is "egowebuser" and the default password is "egowebpass". * //NOTE:// If setting up a production server that is not broadcasting / facing externally (if you are not just using your Mac to run EgoWeb -- e.g. if you are running it over a network and others will have access to the installation on a server) please replace egowebpass with a password of your choice. If you change this value you will need to change the corresponding value in the "main.php" config file. * Select "Local" for the host field. * Click on "Go" at the bottom of the page. **6) Install the EgoWeb PHP files into the AMPPS www directory** Go to the folder "/Program Files/AMPPS/www". It is located inside the same folder where the AMPPS.exe file is located. * Open the folder created when you extracted the egoweb .zip file from github in another Finder Window. Open the folder "app" within that folder. * Copy all of the contents of the "app" folder (not the folder itself) into the "www" folder. * There should now be a file named "index.php" in the folder "/Applications/AMPPS/www". **7) Configure egoweb** * In the www folder ("/Applications/AMPPS/www/"), create a new folder called "assets". * Open the folder "protected" within "www" (“/Applications/AMPPS/www/protected/"). Create a new folder named "runtime". * In the folder "config" within the "protected" folder (“/Applications/AMPPS/www/protected/config/"), rename the file "main.php.example" to "main.php". You will be asked if you really want to change the extension in a dialog box. Confirm that you do want to change from .example to .php. * //NOTE:// If you changed the default database password (in step 5 above), you will need to edit "main.php" and change the corresponding values under the "db" section. **8) Start EgoWeb 2.0** Open a browser and go to "http://localhost" to start using EgoWeb 2.0. You will be prompted to create an admin user. After creating the user, you can log in to EgoWeb 2.0 with the user’s email and password. ----- ===Update an EgoWeb 2.0 installation on a Windows Machine=== 1) Repeat steps from the main installation instructions starting with 6 (copy files from the .zip file app folder into the www folder). 2) Type the following into a browser address and hit enter: > localhost/admin/migrate If there are database changes, these will be migrated into the existing data base and EgoWeb 2.0 will be fully updated. If there are no changes that need to be migrated, running this will confirm that your system is up to date. ----- ====Install EgoWeb 2.0 on a Mac OS machine==== ****** NOTE FROM DAVE K: 04/04/20 AMPPS was updated for 64 bit, so it now works for Mac OS Catalina. I tested the installation and nothing changed as far as I could tell from the previous instructions. I updated them to make them more clear. ****** Before you begin installation, get the latest EgoWeb 2.0 files from github. As of 4/4/20 the dev branch is the best branch because it has all the latest files for newer versions of PHP. [[https://github.com/qualintitative/egoweb/tree/dev]]. Download the latest zip file and extract its contents somewhere on your desktop where yo will be able to find them in the next steps. **1) Install AMPPS** * Download AMPPS. You can get different versions at the AMPPS download page [[https://ampps.com/download]]). Install by opening the DMG file and dragging AMPPS to the Applications folder. You should be given a graphical prompt to do this after downloading. **2) Configure AMPPS** * Launch the AMPPS app from Applications. Find the AMPPS folder you created when you dragged the .dmg into the Applications folder and click on the AMPPS application file to launch it. AMPPS will start the Apache and mySQL servers as the application boots up, and you should see both of them marked as "running" in the AMPPS app. * See NOTE 1 below **3) Create default egoweb database** * Open a browser and enter "http://localhost/phpmyadmin" into the location bar (or just "localhost/phpmyadmin" will work). * In the PHPMyAdmin browser window, click on "Databases". Under "Create database", put in "egoweb" for the database name (all lowercase) and scroll almost all the way down the list to select "utf8mb4_unicode_ci" for the collation. (We have previously recommended utf8_general_ci for fast performance, but that may have issues with special characters). * Click create. A new database named "egoweb" should appear in the left sidebar. ** 4) Import database structure from SQL file** * In the phpMyAdmin browser window, click on the new database "egoweb" that you just created on the left hand side of the page. When the egoweb database structure appears in the middle of the page, select "Import" from the top navigation bar. * Under "File to Import:" you will browse your computer to the folder where you saved the EgoWeb 2.0 files from github. Click on the "Choose File" button in the section under "File to import". Navigate to the egoweb folder you extracted from the .zip file downloaded from github. Find the "sql" folder, open it, you will see "egoweb_db.sql". Select this file and click OK. * After the file is selected (you will see "egoweb_db.sql" next to the "Choose File" button), click on "Go" at the bottom of the page. The EgoWeb database will now be populated with all of the tables needed to run EgoWeb on your Mac. **5) Add user privileges to egoweb database** * At the top menu of the phpMyAdmin page, click on the "Privileges" menu option. Click on the "Add User" link. * Enter the default username: "egowebuser". * Select "Local" for the host field. * Enter the default password: "egowebpass". * (See Note 2 below for setting up a localhost with something other than the default username and password.) * Click on "Go" at the bottom of the page. **6) Turn on Show Hidden Files for Finder** This step is necessary to copy the hidden file .htaccess, which is necessary for Apache to set the configurations for EgoWeb 2.0. * Open up a terminal by going into the Application Launcher and typing in "Terminal". If you are running OS X Mavericks/Yosemite/or later, run the following command (you can copy and paste the text into a terminal session and hit "enter": > defaults write com.apple.finder AppleShowAllFiles -boolean true ; killall Finder (Note 3 below has alternative terminal command) **7) Install the EgoWeb PHP files into the AMPPS www directory** Go to the folder "/Applications/AMPPS/www". It is located inside the AMPPS app in the application folder. * Open the folder created when you extracted the egoweb .zip file from github in another Finder Window. Open the folder "app" within that folder. * Copy all of the contents of the "app" folder (not the folder itself) into the "www" folder. * There should now be a file named "index.php" in the folder "/Applications/AMPPS/www". **8) Configure egoweb** * In the www folder ("/Applications/AMPPS/www/"), create a new folder called "assets". * Open the folder "protected" within "www" (“/Applications/AMPPS/www/protected/"). Create a new folder named "runtime". * In the folder "config" within the "protected" folder (“/Applications/AMPPS/www/protected/config/"), rename the file "main.php.example" to "main.php". You will be asked if you really want to change the extension in a dialog box. Confirm that you do want to change from .example to .php. **9) Start EgoWeb 2.0** Open a browser and go to "http://localhost" to start using EgoWeb 2.0. You will be prompted to create an admin user. After creating the user, you can log in to EgoWeb 2.0 with the user’s email and password. ****NOTE1****: If Apache is not running when you start AMPPS and if it does not start when you click "ON", you may have Apache already running. It is typically turned off by default but if you have installed MAMP or some other program that runs Apache, it might be running and needs to be shut down in order to run it through AMPPS. In order to turn Apache off, you will need to run some commands in the "terminal" app on your Mac. Open up a terminal by going into the Application Launcher and typing in "Terminal". If you enter a password to access your Mac, you will need to enter the same password to use Terminal. Copy and paste the lines below and hit "enter" after each line. (I found these commands [[https://www.softaculous.com/board/index.php?tid=13586&title=AMPPS_3.8_Apache_not_starting_on_MAC_OS_High_Sierra|on a Q&A message board]]): * sudo apachectl -k stop * sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist After running these you should be able to click Apache "On" in the AMPPS application. ****NOTE2****: If setting up a production server that is not broadcasting / facing externally (if you are not just using your Mac to run EgoWeb -- e.g. if you are running it over a network and others will have access to the installation on a server) please replace egowebpass with a password of your choice. If you change this value you will need to change the corresponding value in the "main.php" config file under the "db" section. ****NOTE3****: * If you're running OS X 10.8 or below, run the following command instead: > defaults write com.apple.finder AppleShowAllFiles TRUE ; killall Finder ----- ===Update an EgoWeb 2.0 installation on a Mac OS Machine=== 1) Repeat steps from the main installation instructions starting with 7 (copy files from the .zip file app folder into the www folder). 2) Type the following into a browser address and hit enter: > localhost/admin/migrate If there are database changes, these will be migrated into the existing data base and EgoWeb 2.0 will be fully updated. If there are no changes that need to be migrated, running this will confirm that your system is up to date. ----- ====Install EgoWeb 2.0 on an existing Linux server==== These are instructions for a machine running Ubuntu 14.10 with the latest Ubuntu / Debian repositories. Open up a terminal on your server and execute the commands listed below.\\ **1) Install LAMP Server** > sudo apt-get update > sudo apt-get install lamp-server^ git php-gd php-mbstring php-xml When prompted whether or not to install, hit 'y' and press enter. Remember the root password you enter when installing the MySQL server. You will need this password later. **2) Configure Apache** > sudo nano /etc/apache2/apache2.conf Under , change AllowOverride None to AllowOverride All Ctrl + X and type Y to save. **3) Enable the Apache rewrite and PHP Mcrypt modules** > a2enmod rewrite > php5enmod mcrypt > service apache2 restart **4) Install the EgoWeb PHP files into the Apache www directory** > git clone [[https://github.com/qualintitative/egoweb]] > rm -rf /var/www/* > cp -r egoweb/app/. /var/www/html/ **5) Configure MySQL Database** > mysql -p > CREATE DATABASE egoweb DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_unicode_ci; > USE egoweb > SOURCE ~/egoweb/sql/egoweb_db.sql **For production servers, please replace //egowebpass// in the command below with a password of your choice. If egoweb is the only database you're setting up in MySQL, you may re-use the root password from Step 1. Otherwise, please use a different password.** > CREATE USER 'egowebuser'@'localhost' IDENTIFIED BY 'egowebpass'; > GRANT ALL PRIVILEGES ON egoweb.* TO 'egowebuser'@'localhost'; > quit **6) Configure Yii by running initialize.sh** > cd /var/www/html >./initialize.sh **For production servers, you will need to edit /var/www/html/protected/config/main.php. Replace //egowebpass// in the database connection string with the password you used in Step 4. For additional security, you may change the encryption key near the bottom of the configuration file.** **7) Start EgoWeb 2.0** Open a browser and go to "http://localhost" (Or replace localhost with your IP) to start using EgoWeb 2.0. You will be prompted to create an admin user with a name, email (which will be used as a username for logging in), and password. **Please note that this is different from the database username and password which allows EgoWeb 2.0 to connect to the MySQL database. You may want to use a different password than the one used in Step 4.** After creating the user, you can log in to EgoWeb 2.0 with the user’s email and password. ----- ===Update an EgoWeb 2.0 installation on a Linux server=== This set of instructions assumes you followed the Linux setup instructions on this wiki to install EgoWeb 2.0 initially, and that there is a copy of egoweb in the ~/ folder. (You may need to install rsync if not installed already with the following command: > apt-get install rsync) After logging in, type these following commands: > cd egoweb > git pull > cd .. > rsync -avz egoweb/app/ /var/www/html/ After these commands are successfully run, open a browser and log in to the version of EgoWeb 2.0 just updated. Go to the following URL extension of the EgoWeb 2.0 URL that is being updated: > ~admin/migrate If there are database changes, these will be migrated into the existing data base and EgoWeb 2.0 will be fully updated. ----- ===Update a Linux server to a different EgoWeb 2.0 branch=== Run this set of commands if you want to switch your webpage to a different EgoWeb 2.0 branch. The final 5 lines are the same as the final 5 lines above. (You may need to install rsync if not already installed with the following command: > apt-get install rsync) > cd - > cd egoweb > git checkout {branch name} > git pull > cd .. > rsync -avz egoweb/app/ /var/www/html/ And then run the same migrate command to update the data base if necessary: > ~/admin/migrate ----- ====Update an EgoWeb 2.0 to the new framework, version 2.0.10==== EgoWeb 2.0.10 is a major update with improved security and UX features. These include the following updated libraries: Yii Framework 2.0 Bootstrap 4.0 jQuery 3.4 The Authoring section was also updating using VueJS to streamline editing and administrating studies. Before updating: **1) Make sure your database migrations are up to date. You can trigger this by going to https://[your-server-domain]/admin/migrate in your browser.** **2) Make a backup of your database. This can be done by exporting the entire database in PhpMyAdmin.** **3) Make a copy of protected/config/main.php on your current server. Rename "main.php" to "main.php.backup"** Updating process: **1) Download the latest version from the new_framework branch of the EgoWeb github located [[https://github.com/qualintitative/egoweb/tree/new_framework|here]]. ** **2) On linux, run the command "rsync -avz app/ /var/www/html/" from the github repo folder. OR, copy the contents of the app folder to the root folder of your current server.** **3) Run the script ./initialize.sh, OR manually make a copy of main.php.example and name it main.php.** **4) Update config files** In main.php.backup, find the securityManager section, and copy the value for "encryptionKey". 'securityManager' => array( 'cryptAlgorithm' => 'rijndael-128', 'encryptionKey' => 'oldencryptionkey', ) Open the new main.php and look for the params section towards the end of the file. replace the value 'old_key1old_key1' with the encryptionKey value from your old config, like so: 'params' => [ 'version'=>'2.0.10.0', // this is used in contact page 'adminEmail' => 'admin@egoweb.com', // The max login attempt before showing captcha 'maxLoginAttempts' => 3, 'maxUploadFileSize' => 1024 * 1024 * 3, // 3MB // file path for study export 'exportFilePath' => '', // Enabling audio upload may make your server less secure 'enableAudioUpload' => false, 'surveyURL' => 'http://'.$_SERVER['HTTP_HOST'].'/survey', 'APIPassword' => 'yourpasswordhere', 'encryptionKey' => 'oldencryptionkey', 'user.passwordResetTokenExpire' => 3600, 'user.passwordMinLength' => 8, ], on some servers this might be 'old_key1old_key1', in which case it doesn't need to be changed. However, it is strongly recommend that you create a unique encryption key for your server. if you wish to change the encryption key, you will need to export yall our studies, along with interview data, in the Import / Export section prior to updating Egoweb, change the encryption key, then re-import your study files. This will re-encrypt your data using the new key. 2. Update the database username and password. Look for the following section in main.php.backup 'db' => array( 'connectionString' => 'mysql:host=localhost;dbname=egoweb', 'username' => 'new_egowebuser', 'password' => "new_egowebpass", //'enableProfiling'=>true, 'emulatePrepare' => true, 'charset' => 'utf8', ), use the values above to replace the username and password values tin the "db" section in the new main.php: 'db' => [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname=egoweb', 'username' => 'new_egowebuser', 'password' => 'new_egowebuser', 'charset' => 'utf8', ], On some servers use the default password egowebuser and egowebpass. we recommend creating a unique username and password for the egoweb database in your mysql server. this can be done by creating a new user and granting them access to the egoweb database, then editing the database username and password in the main.php config file. this may or may not be required depending on your organization's security policy, though not necessary for servers on personal computers. **5) Create new user accounts** Passwords are encrypted differently in EgoWeb 2.0.10. You will need to reset your password in order to be able to login. There are two ways to address this issue: 1. Use the new password reset feature. This will only work if you have a mail service such as sendmail or postfix installed on your server, as it will attempt to send a password reset email to the user email. 2. Delete all the users in the user table in the database. Afterwards, going to the EgoWeb homepage will bring up a Create New Admin User form. If there were multiple users who are not Super Admins who have authored studies, those studies will no longer be accessible by non-Super Admins unless the study table is updated with the user ids of newly created users. ===Update a server running the new framework== This set of instructions assumes you are running EgoWeb 2.0 to the new framework, version 2.0.10, and that there is a copy of egoweb in the ~/ folder. (You may need to install rsync if not installed already with the following command: > apt-get install rsync) After logging in, type these following commands: > cd egoweb > git pull > rsync -avz app/ /var/www/html/ After these commands are successfully run, open a browser and log in to the version of EgoWeb 2.0 just updated. Go to the following URL extension of the EgoWeb 2.0 URL that is being updated: > ~admin/migrate If there are database changes, these will be migrated into the existing data base and EgoWeb 2.0 will be fully updated. ----- ====Creating a new Linux server with www.linode.com==== The script below is available in the [[http://www.linode.com|www.linode.com]] stack script library. This [[https://www.linode.com/docs/platform/stackscripts|StackScript]] installs EgoWeb 2.0 and all software required to run on Linode. Most of the code should work on other systems. It was run in April 2020 by Scot Hickey (I have not run it myself) and he sent me the script and I pasted it here and created the stack script in Linode. I have not run it there. Here are some notes provided by a project coordinator who set up an EgoWeb VM in 3/2020. The notes are based on reading the old instructions, so some of the stack script might have addressed what he noticed that was outdated. 1. Ubuntu 14.10 is very old, and most are using later distros (18.04, 20.04). Because of this some of the commands are out of date (sudo apt-get is now sudo apt). While apt-get still works, it’s outdated. 2. PHP latest release is 8.0.3, and therefore using phpenmod rather than php5enmod. 3. Mcrypt is not supported by default in PHP anymore (as of 7.1), so there were some extra steps I had to go through. Here is a good guide that should work: https://php.tutorials24x7.com/blog/how-to-install-mcrypt-for-php-7-on-ubuntu-20-04-lts 4. For those who aren’t super technically skilled, I would suggest that the step to replace the egowebpass in the config file should be it’s own step. 5. It might be helpful to your users to include a section on configuring apache for a custom domain / SSL. Below is the stack script: #!/bin/bash -e exec > >(tee -i /var/log/stackscript.log) # DB_NAME="egoweb" DB_USER="egowebuser" DB_USER_PASSWORD="egowebpass" echo "db_password is $DB_PASSWORD" echo "db_name is $DB_NAME" echo "db_user is $DB_USER" echo "db_user_password is $DB_USER_PASSWORD" ############################################## # FUNCTIONS (SOMETIMES) USED DURING SETUP ############################################## function system_update() { sudo apt-get update sudo dpkg --configure -a sudo apt-get -y install # aptitude -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" full-upgrade } function system_primary_ip() { # returns the primary IP assigned to eth0 echo $(ifconfig eth0 | awk -F: '/inet addr:/ {print $2}' | awk '{ print $1 }') } function get_rdns() { # calls host on an IP address and returns its reverse dns if [ ! -e /usr/bin/host ]; then aptitude -y install dnsutils > /dev/null fi echo $(host $1 | awk '/pointer/ {print $5}' | sed 's/\.$//') } function get_rdns_primary_ip() { # returns the reverse dns of the primary IP assigned to this system echo $(get_rdns $(system_primary_ip)) } function system_set_hostname() { # $1 - The hostname to define HOSTNAME="$1" if [ ! -n "$HOSTNAME" ]; then echo "Hostname undefined" return 1; fi echo "$HOSTNAME" > /etc/hostname hostname -F /etc/hostname } function system_add_host_entry() { # $1 - The IP address to set a hosts entry for # $2 - The FQDN to set to the IP IPADDR="$1" FQDN="$2" if [ -z "$IPADDR" -o -z "$FQDN" ]; then echo "IP address and/or FQDN Undefined" return 1; fi echo $IPADDR $FQDN >> /etc/hosts } ########################################################### # Users and Authentication ########################################################### function user_add_sudo() { # Installs sudo if needed and creates a user in the sudo group. # # $1 - Required - username # $2 - Required - password USERNAME="$1" USERPASS="$2" if [ ! -n "$USERNAME" ] || [ ! -n "$USERPASS" ]; then echo "No new username and/or password entered" return 1; fi aptitude -y install sudo adduser $USERNAME --disabled-password --gecos "" echo "$USERNAME:$USERPASS" | chpasswd usermod -aG sudo $USERNAME } function user_add_pubkey() { # Adds the users public key to authorized_keys for the specified user. Make sure you wrap your input variables in double quotes, or the key may not load properly. # # # $1 - Required - username # $2 - Required - public key USERNAME="$1" USERPUBKEY="$2" if [ ! -n "$USERNAME" ] || [ ! -n "$USERPUBKEY" ]; then echo "Must provide a username and the location of a pubkey" return 1; fi if [ "$USERNAME" == "root" ]; then mkdir /root/.ssh echo "$USERPUBKEY" >> /root/.ssh/authorized_keys return 1; fi mkdir -p /home/$USERNAME/.ssh echo "$USERPUBKEY" >> /home/$USERNAME/.ssh/authorized_keys chown -R "$USERNAME":"$USERNAME" /home/$USERNAME/.ssh } function ssh_disable_root() { # Disables root SSH access. sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config touch /tmp/restart-ssh } ########################################################### # Postfix ########################################################### function postfix_install_loopback_only() { # Installs postfix and configure to listen only on the local interface. Also # allows for local mail delivery echo "postfix postfix/main_mailer_type select Internet Site" | debconf-set-selections echo "postfix postfix/mailname string localhost" | debconf-set-selections echo "postfix postfix/destinations string localhost.localdomain, localhost" | debconf-set-selections aptitude -y install postfix /usr/sbin/postconf -e "inet_interfaces = loopback-only" #/usr/sbin/postconf -e "local_transport = error:local delivery is disabled" touch /tmp/restart-postfix } ########################################################### # Apache ########################################################### function apache_install() { # installs the system default apache2 MPM aptitude -y install apache2 a2dissite default # disable the interfering default virtualhost # clean up, or add the NameVirtualHost line to ports.conf sed -i -e 's/^NameVirtualHost \*$/NameVirtualHost *:80/' /etc/apache2/ports.conf if ! grep -q NameVirtualHost /etc/apache2/ports.conf; then echo 'NameVirtualHost *:80' > /etc/apache2/ports.conf.tmp cat /etc/apache2/ports.conf >> /etc/apache2/ports.conf.tmp mv -f /etc/apache2/ports.conf.tmp /etc/apache2/ports.conf fi } function apache_tune() { # Tunes Apache's memory to use the percentage of RAM you specify, defaulting to 40% # $1 - the percent of system memory to allocate towards Apache if [ ! -n "$1" ]; then PERCENT=40 else PERCENT="$1" fi # aptitude -y install apache2-mpm-prefork PERPROCMEM=10 # the amount of memory in MB each apache process is likely to utilize MEM=$(grep MemTotal /proc/meminfo | awk '{ print int($2/1024) }') # how much memory in MB this system has MAXCLIENTS=$((MEM*PERCENT/100/PERPROCMEM)) # calculate MaxClients MAXCLIENTS=${MAXCLIENTS/.*} # cast to an integer sed -i -e "s/\(^[ \t]*MaxClients[ \t]*\)[0-9]*/\1$MAXCLIENTS/" /etc/apache2/apache2.conf touch /tmp/restart-apache2 } function apache_virtualhost() { # Configures a VirtualHost # $1 - required - the hostname of the virtualhost to create if [ ! -n "$1" ]; then echo "apache_virtualhost() requires the hostname as the first argument" return 1; fi if [ -e "/etc/apache2/sites-available/$1" ]; then echo /etc/apache2/sites-available/$1 already exists return; fi mkdir -p /srv/www/$1/public_html /srv/www/$1/logs echo "" > /etc/apache2/sites-available/$1 echo " ServerName $1" >> /etc/apache2/sites-available/$1 echo " DocumentRoot /srv/www/$1/public_html/" >> /etc/apache2/sites-available/$1 echo " ErrorLog /srv/www/$1/logs/error.log" >> /etc/apache2/sites-available/$1 echo " CustomLog /srv/www/$1/logs/access.log combined" >> /etc/apache2/sites-available/$1 echo "" >> /etc/apache2/sites-available/$1 a2ensite $1 touch /tmp/restart-apache2 } function apache_virtualhost_from_rdns() { # Configures a VirtualHost using the rdns of the first IP as the ServerName apache_virtualhost $(get_rdns_primary_ip) } function apache_virtualhost_get_docroot() { if [ ! -n "$1" ]; then echo "apache_virtualhost_get_docroot() requires the hostname as the first argument" return 1; fi if [ -e /etc/apache2/sites-available/$1 ]; then echo $(awk '/DocumentRoot/ {print $2}' /etc/apache2/sites-available/$1 ) fi } ########################################################### # mysql-server ########################################################### function mysql_install() { # $1 - the mysql root password echo "mysql root pass is $1" if [ ! -n "$1" ]; then echo "mysql_install() requires the root pass as its first argument" return 1; fi echo "mysql-server mysql-server/root_password password $1" | debconf-set-selections echo "mysql-server mysql-server/root_password_again password $1" | debconf-set-selections apt-get -y install mysql-server mysql-client echo "Sleeping while MySQL starts up for the first time..." sleep 5 } function mysql_tune() { # Tunes MySQL's memory usage to utilize the percentage of memory you specify, defaulting to 40% # $1 - the percent of system memory to allocate towards MySQL if [ ! -n "$1" ]; then PERCENT=40 else PERCENT="$1" fi sed -i -e 's/^#skip-innodb/skip-innodb/' /etc/mysql/my.cnf # disable innodb - saves about 100M MEM=$(awk '/MemTotal/ {print int($2/1024)}' /proc/meminfo) # how much memory in MB this system has MYMEM=$((MEM*PERCENT/100)) # how much memory we'd like to tune mysql with MYMEMCHUNKS=$((MYMEM/4)) # how many 4MB chunks we have to play with # mysql config options we want to set to the percentages in the second list, respectively OPTLIST=(key_buffer sort_buffer_size read_buffer_size read_rnd_buffer_size myisam_sort_buffer_size query_cache_size) DISTLIST=(75 1 1 1 5 15) for opt in ${OPTLIST[@]}; do sed -i -e "/\[mysqld\]/,/\[.*\]/s/^$opt/#$opt/" /etc/mysql/my.cnf done for i in ${!OPTLIST[*]}; do val=$(echo | awk "{print int((${DISTLIST[$i]} * $MYMEMCHUNKS/100))*4}") if [ $val -lt 4 ] then val=4 fi config="${config}\n${OPTLIST[$i]} = ${val}M" done sed -i -e "s/\(\[mysqld\]\)/\1\n$config\n/" /etc/mysql/my.cnf touch /tmp/restart-mysql } function mysql_create_database() { # $1 - the mysql root password # $2 - the db name to create if [ ! -n "$1" ]; then echo "mysql_create_database() requires the root pass as its first argument" return 1; fi if [ ! -n "$2" ]; then echo "mysql_create_database() requires the name of the database as the second argument" return 1; fi echo "CREATE DATABASE $2;" | mysql -u root -p$1 } function mysql_create_user() { # $1 - the mysql root password # $2 - the user to create # $3 - their password if [ ! -n "$1" ]; then echo "mysql_create_user() requires the root pass as its first argument" return 1; fi if [ ! -n "$2" ]; then echo "mysql_create_user() requires username as the second argument" return 1; fi if [ ! -n "$3" ]; then echo "mysql_create_user() requires a password as the third argument" return 1; fi echo "CREATE USER '$2'@'localhost' IDENTIFIED BY '$3';" | mysql -u root -p$1 } function mysql_grant_user() { # $1 - the mysql root password # $2 - the user to bestow privileges # $3 - the database if [ ! -n "$1" ]; then echo "mysql_create_user() requires the root pass as its first argument" return 1; fi if [ ! -n "$2" ]; then echo "mysql_create_user() requires username as the second argument" return 1; fi if [ ! -n "$3" ]; then echo "mysql_create_user() requires a database as the third argument" return 1; fi echo "GRANT ALL PRIVILEGES ON $3.* TO '$2'@'localhost';" | mysql -u root -p$1 echo "FLUSH PRIVILEGES;" | mysql -u root -p$1 } ########################################################### # PHP functions ########################################################### function php_install_with_apache() { aptitude -y install php php-mysql libapache2-mod-php touch /tmp/restart-apache2 } function php_tune() { # Tunes PHP to utilize up to 32M per process iniloc=$(php --ini | grep Loaded | cut -d" " -f12) # echo "iniloc is $iniloc" sed -i'-orig' 's/memory_limit = [0-9]\+M/memory_limit = 32M/' $iniloc touch /tmp/restart-apache2 } function php_fixtimeout() { iniloc=$(php --ini | grep Loaded | cut -d" " -f12) echo "iniloc is $iniloc" sed -i 's/max_input_vars = [0-9]/max_input_vars = 10000/' $iniloc sed -i 's/max_execution_time = [0-9]/max_execution_time = 5000/' $iniloc sed -i 's/post_max_size = [0-9]\+M/post_max_size = 1900M/' $iniloc sed -i 's/upload_max_filesize = [0-9]\+M/upload_max_filesize = 2000M/' $iniloc sed -i 's/memory_limit = [0-9]\+M/memory_limit = 3072M/' $iniloc sed -i 's/max_file_uploads = [0-9]/max_file_uploads = 5000/' $iniloc touch /tmp/restart-apache2 } function php_fixtimeouta() { iniloc=$(sudo find /etc/ -name php.ini | grep 'apache2') echo "iniloc is $iniloc" sed -i 's/max_input_vars = [0-9]/max_input_vars = 10000/' $iniloc sed -i 's/max_execution_time = [0-9]/max_execution_time = 5000/' $iniloc sed -i 's/post_max_size = [0-9]\+M/post_max_size = 1900M/' $iniloc sed -i 's/upload_max_filesize = [0-9]\+M/upload_max_filesize = 2000M/' $iniloc sed -i 's/memory_limit = [0-9]\+M/memory_limit = 3072M/' $iniloc sed -i 's/max_file_uploads = [0-9]/max_file_uploads = 5000/' $iniloc touch /tmp/restart-apache2 } ########################################################### # Other niceties! ########################################################### function goodstuff() { # Installs the REAL vim, wget, less, and enables color root prompt and the "ll" list long alias aptitude -y install wget vim less sed -i -e 's/^#PS1=/PS1=/' /root/.bashrc # enable the colorful root bash prompt sed -i -e "s/^#alias ll='ls -l'/alias ll='ls -al'/" /root/.bashrc # enable ll list long alias <3 } ########################################################### # utility functions ########################################################### function restartServices() { # restarts services that have a file in /tmp/needs-restart/ for service in $(ls /tmp/restart-* | cut -d- -f2-10); do /etc/init.d/$service restart rm -f /tmp/restart-$service done } function randomString { if [ ! -n "$1" ]; then LEN=20 else LEN="$1" fi echo $( Service -> Install Service, then start it by going to Apache -> Service -> Start Service. | {{ :5_startwampserver.png |}} | **5) Edit httpd.conf** From the WAMP Menu, go to Apache -> httpd.conf. In Notepad, search for the phrase "AllowOverride all" and remove the hash tag character (“#”) immediately preceding it. Save the file. | {{ :6_apachehttpconfig.png |}} | | {{ :7_allowoverride.png |}} | **6) Enable the rewrite module** From the WAMP menu, make sure Apache -> Apache Modules -> rewrite_module is checked. Clicking on an unchecked module will enable it. | {{ :8_apachemodules.png |}} | | {{ :9_rewritemodule.png |}} | After clicking on rewrite_module, WAMP will reboot. Follow the same steps as above to confirm that the rewrite_module has been checked. **7) Launch PHPMyAdmin** Click on the WAMP menu in the system tray, and visit PHPMyAdmin, a PHP Application that allows you to manage the MySQL server in WAMP. A browser should open with PHPMyAdmin loaded. If you are prompted for a password, leave it blank and log in. **8) Create default egoweb database** In the PHPMyAdmin browser window, click on "databases." Under "Create database", put in "egoweb" for the database name (all lowercase) and select "utf8mb4_unicode_ci" for the collation. (We have previously recommended utf8_general_ci for fast performance, but that may have issues with special characters). Click create. A new database named "egoweb" should appear in the left sidebar. **9) Import database structure from SQL file** In the PHPMyAdmin browser window, click on "egoweb", then select "Import" from the top navigation bar. Click on the file input under "File to import". Find "egoweb_db.sql" in the “sql” folder among the extracted files on the desktop. After the file is selected, click on "Go" at the bottom of the page. The egoweb database should now be populated with tables. **10) Add user privileges to egoweb database** In the PHPMyAdmin browser window, click on "privileges" in the navigation menu, then click on the "Add User" link. The default username is "egowebuser" and the default password is "egowebpass". **For production servers, please replace //egowebpass// with a password of your choice. if you change this value you will need to change the corresponding value in the "main.php" config file**. Select "Local" for the host field. Click on "Go" at the bottom of the page. **11) Install the EgoWeb 2.0 PHP files into the WAMP www directory** * Open the folder "C:\wamp\www" and delete all of the existing files inside the folder. * You can either directly open it up using Windows Explorer by pointing it to "C:\wamp\www" or you can open this window using WAMP menu by selecting "www directory". * After deleting these files, locate the the egoweb files that you extracted from the github .zip file you downloaded. * Locate the folder "app" among the extracted files on the desktop and copy its contents into "C:\wamp\www". Do not copy the folder itself, copy the files within the folder. * There should now be a new "index.php" file in the folder "C:\wamp\www". **12) Configure EgoWeb 2.0** * In the folder "C\wamp\www", create a new folder called "assets". * In the folder “C:\wamp\www\protected", create a new folder named "runtime". * In the folder “C:\wamp\www\protected\config", rename the file "main.php.example" to "main.php". * If you changed the default database password in step 8, you will need to edit this file and change the corresponding values under the "db" section. **13) Start EgoWeb 2.0** Open a browser and go to "http://localhost" to start using EgoWeb 2.0. You will be prompted to create an admin user. After creating the user, you can log in to EgoWeb 2.0 with the user’s email and password. Enjoy! //NOTE:// The initial installation was conducted with an administrator account. A non-admin account could not run wampserver. We attempted to set up wampserver to automatically load at startup without administrative rights but have not figured that out yet. We will update the documentation when we identify reliable procedures. ----- ===Update an EgoWeb 2.0 installation on a Windows machine=== 1) Repeat steps from the main installation instructions starting with Step 11 (copy files from the .zip file webapp folder into the www folder). 2) Type the following into a browser address and hit enter: > localhost/admin/migrate If there are database changes, these will be migrated into the existing data base and EgoWeb 2.0 will be fully updated. If there are no changes that need to be migrated, running this will confirm that your system is up to date. ----- ~~DISCUSSION~~