我一直在使用Ubuntu 16.04。最近我对 PHP 安装做了一些实验,恐怕我已经严重破坏了东西。我试过
sudo apt install php7.0
Run Code Online (Sandbox Code Playgroud)
但它显示了依赖性和损坏的包错误
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php7.0 : Depends: libapache2-mod-php7.0 but it …Run Code Online (Sandbox Code Playgroud) 所以,这就是我正在尝试做的事情。我使用 docker 创建了一个 MongoDB 服务,并尝试使用 mongoose 将我的 NodeJs 项目连接到数据库服务。这是我的docker-compose.yaml
version: '3'
services:
mongodb:
container_name: mongo_database
image: mongo
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=password
networks:
- mongo-compose-network
ports:
- '27017:27017'
mongo-express:
container_name: mongo_express
image: mongo-express
restart: unless-stopped
depends_on:
mongodb:
condition: service_started
networks:
- mongo-compose-network
environment:
- ME_CONFIG_MONGODB_ADMINUSERNAME=admin
- ME_CONFIG_MONGODB_ADMINPASSWORD=password
- ME_CONFIG_MONGODB_SERVER=mongodb
ports:
- '8081:8081'
networks:
mongo-compose-network:
driver: bridge
Run Code Online (Sandbox Code Playgroud)
我已经打开 mongo-express 面板,一切正常。现在,这是我的 NodeJs 应用程序,用于MongoClient连接到数据库并插入虚拟记录。
require('dotenv').config();
// required modules
const mongoose = require("mongoose")
const MongoClient = require('mongodb').MongoClient;
// database config
const …Run Code Online (Sandbox Code Playgroud)