A simple Content Management System.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
cms/protected/README.MD

4.4 KiB

cms - Content Management System

Original Author: Matt Doyle https://www.elated.com/cms-in-an-afternoon-php-mysql/

Updates: Robert S.

Note: I use the hash sign # to note a comment, do not run it in the terminal.
Note: I use the dollar sign $ for the Linux prompt commands to run.
Note: I use the greater-than sign > for the MySQL prompt commands.

Pull Git repo

# AS a normal user NOT Root, we will sudo or doas for that from time to time:
$ mkdir -p /var/www
$ sudo groupadd www-data
$ chgrp www-data /var/www
$ cd /var/www
$ git clone https://git.mysnippetsofcode.com/bobs/cms
$ cd cms

SETUP MySQL as Root, run:

# Install the server:
$ sudo apt-get install mysql-server
$ sudo systemctl start mysql
$ sudo systemctl enable mysql
# The following script will prompt you to perform various security-related actions. Follow the prompts to set a root password, remove anonymous users, disallow root login remotely, remove the test database, and reload the privilege tables.
$ sudo mysql_secure_installation

# Change this password SJ6G*WyaV7PvvEts@vxjm used below in a couple of places!

# Enter your password assigned during setup, create a new user for the app to use.
$ mysql -u root -p
> CREATE USER 'zoombox'@'localhost' IDENTIFIED BY 'SJ6G*WyaV7PvvEts@vxjm';
> GRANT ALL ON cms.* TO 'zoombox'@'localhost';
> create database cms;

Import the tables.sql file:

$ pushd protected/src
$ pwd
# You should be in /var/www/cms/protected/src
# Do not use the root user for cms app!
$ mysql -u cms -p cms < tables.sql
    enter this password when prompted: SJ6G*WyaV7PvvEts@vxjm
$ popd

You may want to edit the config.php file which is in the protected/src folder.

define( "BLOG_NAME", "Widgetz Newz" ); // Display Name for Titles

Create the .env file in root of Project to configure your secrets!

$ pwd
# You should be in /var/www/cms
# DO NOT use the root user for cms app!
$ nano .env
DB_TYPE=mysql
DB_HOST=127.0.0.1
DB_NAME=cms
DB_USERNAME=zoombox
DB_PASSWORD=SJ6G*WyaV7PvvEts@vxjm
ADMIN_USERS=zug:SunSet@XQWET,zig:546Poker@xzyWhy

Note: the admin username is: zug

Admin password is: SunSet@XQWET

Install Composer

$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer

Install Composer deps

$ cd protected
$ pwd
# You should be in /var/www/cms/protected
$ composer install

Install web server apache2 or nginx

Pick just one

# for Apache2
$ sudo apt-get install apache2
$ sudo apt-get install libapache2-mod-php8.3
# edit default site:
$ sudo nano /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/cms/public

    <Directory /var/www/cms/public>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
$ sudo a2ensite 000-default.conf
$ sudo a2enmod rewrite
# after php deps are installed come back and run this:
$ sudo a2enmod php8.3
# Install Certbot to get SSL certs for Apache2
$ sudo apt-get update
$ sudo apt-get install certbot
$ sudo certbot --apache
$ sudo systemctl restart apache2

---------------------------OR--------------------------------

# for nginx
$ sudo apt-get install nginx
$ sudo apt-get install php8.3-fpm
# Configure nginx for cms
$ sudo nano /etc/nginx/sites-available/cms
# Replace your_domain.com with your actual domain or IP address:
server {
    listen 80;
    server_name your_domain.com;
    root /var/www/cms/public;

    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;  # Adjust the PHP version if necessary
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

$ sudo ln -s /etc/nginx/sites-available/cms /etc/nginx/sites-enabled/
$ sudo nginx -t
# if test is ok, then run:
$ sudo systemctl reload nginx
# Install Certbot to get SSL certs for nginx
$ sudo apt-get update
$ sudo apt-get install certbot
$ sudo certbot --nginx
$ sudo systemctl reload nginx

PHP deps

PHP gd and mysql must be installed:
$ sudo apt-get install php8.3 php8.3-gd php8.3-mysql