Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Instructions #9

Open
Physium opened this issue Apr 2, 2021 · 4 comments
Open

Setup Instructions #9

Physium opened this issue Apr 2, 2021 · 4 comments

Comments

@Physium
Copy link

Physium commented Apr 2, 2021

Is it possible to provide some setup instructions and what not on how to get this going?

@magotech
Copy link

Hello, am also having issues with how to run the program. Anyone who understands please share (video demo would be appreciated).

@poran200
Copy link

poran200 commented Sep 8, 2021

please provide some setup information

@Henrika2021
Copy link

Same situation

@younglondon
Copy link

younglondon commented Feb 23, 2022

Have got this working in a LAMP stack on macOS using brew to install these packages. Google "brew install package_name_here" etc to get install instructions. On linux the usual apt-get install would be fine. Unsure of windows. Using;

  • Apache/2.4.52
  • PHP 8.1.3 (v8+ should be fine)(after the brew installation, it will tell you to put LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so and <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> into the httpd.conf file. Just take note of where the libphp.so module is stored during installation.
  • mysql Ver 8.0.28 (v8+ should be fine)

Apache side of things

  1. Make a directory to contain the repo. cd into this directory and use git clone https://github.com/iamareebjamal/car-rental-php.git
  2. Next we need to tell apache to host this project using the httpd.conf file. httpd.conf by default (when installed by brew) is /usr/local/etc/httpd/httpd.conf.
  3. Edit httpd.conf and use this setup:
#Once we start the httpd server, we can access the site by default on 127.0.0.1:8080
Listen 8080

LoadModule authz_core_module lib/httpd/modules/mod_authz_core.so
LoadModule authz_host_module lib/httpd/modules/mod_authz_host.so
LoadModule auth_basic_module lib/httpd/modules/mod_auth_basic.so
LoadModule authn_file_module lib/httpd/modules/mod_authn_file.so
LoadModule dir_module lib/httpd/modules/mod_dir.so
LoadModule log_config_module lib/httpd/modules/mod_log_config.so
LoadModule mime_module lib/httpd/modules/mod_mime.so
LoadModule mpm_prefork_module lib/httpd/modules/mod_mpm_prefork.so

#Needed for a .htaccess file we will create.
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so

#Added because we need php functionality
LoadModule php_module /usr/local/opt/php/lib/httpd/modules/libphp.so
#And again.
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

ServerAdmin admintest@mainsite.com
ServerName mainsite.com

#Point both of these paths to your folder where you cloned the repo.
DocumentRoot "/your/path/car-rental-php/public"
<Directory "/your/path/car-rental-php/public">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>
ErrorLog "/usr/local/var/log/httpd/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "/usr/local/var/log/httpd/access_log" common
</IfModule>
  1. Test the config by using apachectl configtest and you should get a Syntax OK. If not you'll have to dig around and see where errors lead you.
  2. Now we can start the httpd server by running apachectl start. If you browse to 127.0.0.1:8080 and see "No database found! Please run the database server to proceed!" along with a fatal errors from PHP, we're on the right track!

MySQL side of things

First off in the base repo directory you'll see a migrate_00.sql and migrate_01.sql. We use these to create the tables that the app is expecting.
Also notice in car_repo/car-rental-php/classes/db/Database.php on line 19 to 21 we have login credentials. We will change these soon. For now we need create a database called 'carjack' which we can see php is expecting.

  1. Start the MySQL server by using brew services start mysql.
  2. If you installed MySQL using mysql_secure_installation, login to the server by using mysql -u root -p.
  3. Once MySQL is ready (showing you the prompt mysql > ) enter the following statement to create the 'carjack' db.
  4. mysql> CREATE DATABASE carjack;
  5. When we use SHOW DATABASES; we will see our newly created database in the list.
+--------------------+
| Database           |
+--------------------+
| carjack            |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| working            |
+--------------------+
  1. Now we need to use migrate_00.sql and migrate_01.sql in that order, to setup the db structure.
  2. Perform the statement USE carjack; to select the database we will alter.
  3. At the mysql> prompt use the statement SOURCE /path/to/migrate_00.sql. Make sure that's the full system path. No relative paths here just in case. You might get some errors, but it seems to have still all worked for me.
  4. Again at the prompt we can do a SHOW TABLES; to see the newly created tables we have migrated in.
  5. Repeat the SOURCE statement again for the second migration file. SOURCE /path/to/migrate_01.sql.
  6. Back in car_repo/car-rental-php/classes/db/Database.php on lines 19 to 21 we need to change the login user "carjack_admin" and the password "c@tg0ty4Tongue?" to that of our own MySQL db.
  7. When we refresh the page (clear cache before doing so) we will now see the fatal php error is gone and we are at our homepage. We run into another problem, clicking any of the nav links we get a Not Found The requested URL was not found on this server.. We fix this in the next step.

Using the rewrite module to fix the routing issue.

  1. In the public folder, the folder that apache is serving from, create a .htaccess file using touch or whatever you want.
  2. Paste in the following rules into .htaccess
DirectoryIndex index.php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA]

Done!

EDIT: The vehicle images won't resolve as they're no longer available at the URI defined in the database. Not an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants