Skip to content

Latest commit

 

History

History
177 lines (130 loc) · 5.25 KB

Website on localhost guide.md

File metadata and controls

177 lines (130 loc) · 5.25 KB

Website on localhost guide

The goal of this document is to describe the installation of all needed services to run the database on an Arch Linux workstation. It tries to follow standards as '#' indicating command to be run as root, '$' can be run as user.

Installation and first time setup

Install and enable apache, mysql (mariadb), PHP and phpMyAdmin

  1. Install

    # pacman -S apache mariadb php php-fpm phpmyadmin
  2. Set up mariadb

    # mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
    • Note: The default database credentials are root without password
  3. Edit the PHP configuration file php.ini:

    The following lines might already exist and you need to make sure the options are set only once by searching for the options and comment/uncomment where needed.

    /etc/php/php.ini

    ...
    date.timezone = Europe/Mariehamn
    ...
    display_errors = On
    ...
    extension=bz2
    extension=mysqli
    extension=pdo_mysql
    ...

    If you want to upload big files (like the whole database as SQL in plaintext in phpMyAdmin) you also need to make sure the upload limits are large enough

    /etc/php/php.ini

    ...
    upload_max_filesize = 200M
    ...
    post_max_size = 200M
    ...
    
  4. Create the httpd configuration file php-fpm.conf

    /etc/httpd/conf/extra/php-fpm.conf

    DirectoryIndex index.php index.html
    <FilesMatch \.php$>
        SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/"
    </FilesMatch>
  5. Create the httpd config file phpmyadmin.conf

    /etc/httpd/conf/extra/phpmyadmin.conf

    Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
    <Directory "/usr/share/webapps/phpMyAdmin">
        DirectoryIndex index.php
        AllowOverride All
        Options FollowSymlinks
        Require all granted
    </Directory>
  6. Permit empty passwords in phpMyAdmin by editing the file config.inc.php

    /etc/webapps/phpmyadmin/config.inc.php

    ...
    $cfg['Servers'][$i]['AllowNoPassword'] = true;
    ...
  7. Edit the webserver configuration httpd.conf

    /etc/httpd/conf/httpd.conf

    ...
    ServerName localhost
    ...
    # Load modules for proxy
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
    
    # php-fpm configuration
    Include conf/extra/php-fpm.conf
    
    # phpMyAdmin configuration
    Include conf/extra/phpmyadmin.conf
    ...

Starting all services on local machine

Start everything up (it might be overkill to enable all services at startup but the downside is that this step needs to be done every time you need the services locally)

# systemctl start httpd mariadb php-fpm

Note: If you really want to enable automatic startup on boot for the above services: systemctl start httpd mariadb php-fpm

Download the project database

  1. Log in at HostGator

  2. Go to Databases and click phpMyAdmin

    HostGator DB panel

  3. Export database

  • Export -> Custom
  • Deselect all database named ithaax_wrdp*
  • Optional: Select gzip as Compression under Output for quicker download
  • Under object creation options check:
    • Add CREATE DATABASE / USE statement
    • Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT / TRIGGER statement
  • Press Go and save the SQL-file on your computer

Import downloaded database to local server

  1. Import the database using mysql as database user root on the commmandline. You need to be in the same directory or give the full path the SQL-file you downloaded in the previous step.

    $ cd ~/Downloads # where you saved localhost.sql.gz
    $ zcat localhost.sql.gz | mysql -v -u root

Note: The mysql -v option produces lots of verbose output in your terminal. If you want it to stay quiet omit the option.

(if you downloaded as raw text without compression do mysql -v -u root < localhost.sql instead)

Clone website repository and configure it as webserver root

The following assumes you download to your home directory on the workstation. In this case this is /home/sailbot and cloning the repo will create /home/sailbot/SailingRobotsWebsite. We also need to change home directory permission so that the webserver have permissions to access the folder.

  1. Clone repository and alter home directory permissions

    $ cd /home/sailbot
    $ git clone https://github.com/AlandSailingRobots/SailingRobotsWebsite.git
    $ chmod og+x /home/sailbot
  2. Configure server to use repo directory as web rootdir in httpd.conf by changing the following lines:

    /etc/httpd/conf/httpd.conf

    ...
    DocumentRoot "/home/sailbot/SailingRobotsWebsite"
    <Directory "/home/sailbot/SailingRobotsWebsite">
    ...
    
    
  3. Restart the webserver

    # systemctl restart httpd

References: