Ghost is a popular open source blogging platform that allows users to write content using Markdown and provides a beautiful, easy-to-use interface to display this content. The PHP file system is a file-based database that can be used to store and manage user data. This article will introduce in detail how to install the PHP file system on the Ghost platform.
Preparation
Before starting the installation, you need to ensure that the following environments have been installed and configured:
Ghost is a Node.js-based application, so Node.js needs to be installed before installing Ghost. You can download the installer from the Node.js official website and install it according to the official instructions. When Node.js is installed, npm (Node.js package manager) will also be installed.
The PHP file system requires a database to store data. MySQL is a commonly used relational database. You can download the installation program from the MySQL official website.
Installing Ghost
Once the above preparations are completed, we can start installing Ghost.
You can download the latest Ghost compressed package from the Ghost official website. After unzipping, you will get a folder containing all Ghost files.
Use the terminal to enter the decompressed folder and run the following command:
npm install --production
This command will install all the requirements for Ghost dependence.
Before installation, we need to configure Ghost to connect to the MySQL database. In the unzipped folder, open the config.js
file and find the following section:
database: { client: 'sqlite3', connection: { filename: path.join(__dirname, '/content/data/ghost.db') }, debug: false },
Replace it with the following:
database: { client: 'mysql', connection: { host: 'localhost', user: 'your-mysql-username', password: 'your-mysql-password', database: 'your-mysql-database-name', charset: 'utf8mb4' }, debug: false },
## here #your-mysql-username,
your-mysql-password and
your-mysql-database-name should be replaced with the username, password and database name of your MySQL database .
npm start
http ://localhost:2368 to view Ghost’s welcome page.
config.php file in the directory where the PHP file system is located, and then replace the following parts with those of the MySQL database Related information:
$dbhost = 'localhost'; $dbname = 'your-mysql-database-name'; $dbuser = 'your-mysql-username'; $dbpassword = 'your-mysql-password';
install.php file in the directory where the PHP file system is located, and then run the file to create Required datasheet.
phpfs. Then, copy the
index.php file of the PHP file system into that directory.
content/adapters/storage. Create a new folder named
phpfs in this folder. js file, and copy the following code into the file:
var fs = require('fs-extra'); var path = require('path'); var PHPFS = require('../../../../phpfs/index.php'); function PHPFSStorage(options) { this.phpfs = new PHPFS(options); } PHPFSStorage.prototype.save = function(image) { var targetDir = path.join(this.phpfs.directory, 'images'); return this.phpfs.save(image, targetDir).then(function(data) { return data.url; }); }; PHPFSStorage.prototype.exists = function(filename) { var filePath = path.join(this.phpfs.directory, 'images', filename); return new Promise(function(resolve, reject) { fs.access(filePath, fs.constants.F_OK, function(err) { if (err) { resolve(false); } else { resolve(true); } }); }); }; PHPFSStorage.prototype.delete = function() { return Promise.resolve(); }; module.exports = PHPFSStorage;
config.js file under the Ghost installation directory, find the following part:
storage: { active: 'local-file-store', 'local-file-store': {} },
storage: { active: 'phpfs-store', 'phpfs-store': { directory: __dirname + '/phpfs/data', serveUrl: 'http://localhost:2368/phpfs/data' } },
The above is the detailed content of How to install PHP file system on Ghost platform. For more information, please follow other related articles on the PHP Chinese website!