mirror of
https://github.com/Neetpone/ponepaste.git
synced 2026-05-21 10:03:22 +02:00
Mirror of: https://github.com/Neetpone/ponepaste
- PHP 62.1%
- JavaScript 19.4%
- CSS 14.8%
- Hack 3.7%
| config | ||
| doc | ||
| includes | ||
| js | ||
| public | ||
| theme | ||
| util | ||
| vendor | ||
| .gitignore | ||
| babel.config.json | ||
| composer.json | ||
| composer.lock | ||
| LICENSE | ||
| package.json | ||
| phpcs.xml | ||
| psalm.xml | ||
| README.md | ||
| rollup.config.js | ||
| yarn-error.log | ||
| yarn.lock | ||
punishedponepaste
Requirements
- An HTTP server that can perform URL rewriting and execute PHP 8 code (eg: nginx with php8-fpm,) and the following PHP extensions: pdo, openssl, gd, mbstring, redis.
- A MySQL-compatible server (eg: MariaDB 10.)
- A Redis server.
Building the JS
When you change the JS, you need to rebuild it. assets/bundle.js is used in dev, assets/bundle.min.js is used in production.
You need Yarn (version 1, not version 2 - 2 may work, but I haven't tried it.) After that, whenever you change anything under js/, you need to run yarn rollup --config. Good luck!
Local Development
- Set up MySQL/MariaDB and Redis/Valkey and note the host+port and credentials for both.
- Set up an NGINX site using
doc/nginx.local.confas a template; change things for your environment as necessary.- Set up a
/etc/hostsfile entry forponepaste.localto127.0.0.1if you want to useponepaste.local.
- Set up a
- Copy
includes/config.sample.phptoincludes/config.php.- Recommend setting
PP_DEBUGtotruefor local development and testing. - Configure
PP_REDIS_*constant as needed. - Configure
$db_*variables as needed.
- Recommend setting
- Copy
config/site.example.phptoconfig/site.php. This does not need to be edited; it can be configured in the site's admin UI later. - Import
doc/schema.sqlinto the MySQL database you configured above. - Create the initial admin user by doing the following:
php -f util/ppadmin.php hashpw-> enter your desired password, and hit enter. Copy the hashed password to clipboard.- Open a MySQL console to the database you configured above, and run something like
INSERT INTO users (username, password, role, admin_password_hash, recovery_code_hash) VALUES ('admin', 'THE HASH FROM EARLIER', 2, 'THE SAME HASH FROM EARLIER', '');
- Go to
http://ponepaste.local(or whatever hostname you configured), log in, and explore the site!
Production Deployment
- Set up MySQL/MariaDB and Redis/Valkey and note the host+port and credentials for both.
- Ensure these are properly secured and firewalled from the public Internet.
- Set up an NGINX site using
doc/nginx.confas a template; change things for your environment as necessary.- On initial configuration, you may need to comment out the SSL
server { }block or change the cert to a dummy (but valid) one, just long enough to get one from Let's Encrypt. TLS is mostly left as an exercise to the reader. You can do it!
- On initial configuration, you may need to comment out the SSL
- Copy
includes/config.sample.phptoincludes/config.php.- Ensure
PP_DEBUGis set tofalsefor production deployment. - Configure the
PP_PASSWORD_PEPPERconstant to be a long and random string, such as generated byopenssl rand -hex 32. This key strengthens the password hashing significantly, and renders the password hashes from a database-only hack/leak effectively uncrackable. - Configure the
PP_ENCRYPTION_KEYconstant to be another, different, long and random string, such as generated byopenssl rand -hex 32. This key is used to encrypt all pastes before they are stored in the database. Its use renders the paste data from a database-only hack/leak unrecoverable. - Configure
PP_REDIS_*constant as needed. - Configure
$db_*variables as needed.
- Ensure
- Copy
config/site.example.phptoconfig/site.php. This does not need to be edited; it can be configured in the site's admin UI later. - Import
doc/schema.sqlinto the MySQL database you configured above. - Create the initial admin user by doing the following:
php -f util/ppadmin.php hashpw-> enter your desired password, and hit enter. Copy the hashed password to clipboard.- Do the same, but use a different password. This second password is the re-authentication password for administrative actions; this is essentially 2FA where both factors are different passwords.
- Open a MySQL console to the database you configured above, and run something like
INSERT INTO users (username, password, role, admin_password_hash, recovery_code_hash) VALUES ('admin', 'THE FIRST HASH FROM EARLIER', 2, 'THE SECOND HASH FROM EARLIER', '');
- Go to
http://{your-domain}, log in, and explore the site!