- PHP 8.1+ with the
pdo_mysql,json, andfileinfoextensions - MySQL 5.7+ or MariaDB 10.3+
- A web server with
.htaccess/mod_rewritesupport (Apache), or equivalent Nginx config - Writable
storage/books/directory
Clone or download the repository and upload all files to your web server's document root (or a subdirectory).
git clone https://github.com/Hexadecinull/AnyLibrary.gitLog into your hosting control panel (cPanel, DirectAdmin, etc.) and create a new MySQL database and user. Note the credentials.
Import the schema:
mysql -u YOUR_USER -p YOUR_DB < docs/schema.sqlOr use phpMyAdmin → Import → select docs/schema.sql.
Copy the example config:
cp includes/config.example.php includes/config.phpEdit includes/config.php:
define('DB_HOST', 'localhost');
define('DB_NAME', 'anylibrary');
define('DB_USER', 'your_db_user');
define('DB_PASS', 'your_db_password');
// Generate once: php -r "echo bin2hex(random_bytes(32));"
define('JWT_SECRET', 'REPLACE_WITH_A_LONG_RANDOM_STRING');
define('APP_URL', 'https://yourdomain.example.com');Create and set permissions on the book upload directory:
mkdir -p storage/books
chmod 755 storage/booksOn shared hosting, the web server user (e.g.
www-data) must be able to write here. If755doesn't work, try777only if your host requires it.
The included .htaccess handles clean URLs and sets PHP limits. Ensure mod_rewrite and AllowOverride All are enabled.
server {
listen 80;
server_name yourdomain.example.com;
root /var/www/anylibrary;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location /storage/books/ {
deny all;
}
}Important: The
storage/books/directory must not be publicly accessible. The Nginx config above denies it. On Apache, a.htaccessinstorage/withDeny from allis recommended as an extra precaution (theapi/import.phpendpoint serves files with access control).
Navigate to your domain. The homepage should load and immediately display trending books from Open Library.
If you see a blank page, check:
APP_ENVis set to'development'temporarily to see PHP errors- Database credentials are correct
storage/books/is writable
InfinityFree (free shared PHP hosting) works well with AnyLibrary:
- Create an account at infinityfree.com
- Create a hosting account → note the MySQL host (e.g.
sql123.infinityfree.com) - Database name and user both start with
epiz_XXXXXXX_ - Upload files via FTP (FileZilla) to
htdocs/ - Import
docs/schema.sqlvia Softaculous phpMyAdmin - Set
DB_HOSTto the value shown in your control panel
git pull origin mainRe-run any new migrations from docs/schema.sql if the schema has changed (check CHANGELOG.md).