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

corrected issues with band-sched vs. band_sched, created install scri… #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ These steps should be automated by a script soon!
```
CREATE DATABASE band_sched;
CREATE USER "foo" identified by "1337";
GRANT ALL on band-sched.* to "foo"@"localhost" identified by "1337";
GRANT ALL on band_sched.* to "foo"@"localhost" identified by "1337";

```
Next, import the schema, from the sched.sql
```
mysql -u foo -p band_sched < examples/sched.sql
mysql -u foo -p band_sched < sched.sql
```
Create an initial user:
```
Expand Down
8 changes: 4 additions & 4 deletions classes/db.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public function __construct(){
}

private function getDBConfig(){
$this->config = parse_ini_file('/var/db/fcc_worship.ini', false);
$this->config = parse_ini_file('/var/db/band_sched.ini', false);
}

private function connect(){
Expand All @@ -30,7 +30,7 @@ private function query($sql){
return 'error';
}
return $result;

}

public function remove($table,$condition){
Expand All @@ -56,7 +56,7 @@ public function select($sql){
if ($result != 'error'){
$row = $result->fetch_array(MYSQLI_ASSOC);
$result->free();
return $row;
return $row;
}
}

Expand All @@ -65,7 +65,7 @@ public function selectAll($sql){
if ($result != 'error'){
while ($row = $result->fetch_array(MYSQLI_ASSOC)){
$rows[] = $row;
}
}
$result->free();
return $rows;
}
Expand Down
35 changes: 35 additions & 0 deletions examples/main-nginx-example.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
worker_connections 1024;
}

http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile off; #change this if you're not in a VM
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;

}
7 changes: 3 additions & 4 deletions examples/nginx-example.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
server {
listen 80;
listen 443 ssl;
listen 80 default;
#listen 443 ssl;
#Obviously, change the server_name and add a cert for SSL.
server_name example.com;
#server_name example.com;
root /srv/www/band-schedule;
index index.php;

Expand All @@ -29,4 +29,3 @@ server {
}

}

37 changes: 37 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#/bin/bash

#installing the needed componets
echo "Installing basic LEMP stack"
sudo setenforce 0 #if you are planning on using SELinux, remove this line
sudo yum -y install epel-release
sudo yum -y install nginx php-fpm php-mysql mariadb mariadb-server

echo "Installing MariaDB"
sudo mysql_install_db --user=mysql
sudo mysqld_safe &
sleep 5
sudo mysql -u root < setup/db_setup.sql
sudo mysql -u foo --password=1337 band_sched < examples/sched.sql
sudo mysql -u foo --password=1337 band_sched < setup/inital_user.sql

echo "copying band_sched.ini"
sudo cp setup/band_sched.ini /var/db/

echo "copying nginx config"
sudo cp examples/nginx-example.conf /etc/nginx/conf.d/band_sched.conf
sudo cp examples/main-nginx-example.conf /etc/nginx/nginx.conf

sudo mkdir -p /srv/www/
sudo cp -R ../band-schedule /srv/www/
sudo chown -R nginx:nginx /srv/www/

#chaning nginx user form apache in php-fpm
sudo sed -i 's,apache,nginx,g' /etc/php-fpm.d/www.conf

#create the session folders
sudo mkdir -p /var/lib/php/session
sudo chown -R nginx:nginx /var/lib/php/session

echo "Starting nginx on port 80"
sudo systemctl start nginx
sudo systemctl start php-fpm
5 changes: 5 additions & 0 deletions setup/band_sched.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[band-sched]
dbhost="localhost"
db="band_sched"
dbuser="foo"
dbpasswd="1337"
3 changes: 3 additions & 0 deletions setup/db_setup.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE DATABASE band_sched;
CREATE USER "foo" identified by "1337";
GRANT ALL on band_sched.* to "foo"@"localhost" identified by "1337";
2 changes: 2 additions & 0 deletions setup/inital_user.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
USE band_sched
INSERT INTO users (username,password,user_level,status) VALUES ('admin',MD5('password'),1,1);