感谢“系甘”。
monica 是一款 Personal Relationship Management ,私人社交关系管家。
环境:Debian 9 64位
过程:
1.apt install ca-certificates apt-transport-https
# 让apt支持https源
2.wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add -
# 添加 sury.org 的验证匙
3.echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
# 添加 sury.org 的php7.1安装源
4.apt update
# 更新安装源
5.apt install apache2 mariadb-server php7.1 php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-mbstring php7.1-mcrypt php7.1-zip php7.1-fpm php7.1-bcmath php7.1-intl php7.1-xml php7.1-curl php7.1-gd git curl
# 安装 apache, mariadb, php7.1, git 等
![minica-1.png minica-1.png](https://liujia.anqun.org/usr/uploads/2018/10/09/76893601379649.png)
6.wget https://dl.laravel-china.org/composer.phar -O /usr/local/bin/composer
# 安装composer,用国内的镜像较快
![minica-2.png minica-2.png](https://liujia.anqun.org/usr/uploads/2018/10/09/768932356419132.png)
7.chmod a+x /usr/local/bin/composer
# 添加执行权限
8.git clone https://github.com/monicahq/monica.git /var/www/monica
# 下载monica到/var/www
![minica-3.png minica-3.png](https://liujia.anqun.org/usr/uploads/2018/10/09/76893218717557.png)
9.创建数据库,数据库用户,给monica使用
mysql
CREATE DATABASE monica;
CREATE USER 'monica'@'localhost' IDENTIFIED BY 'mimamima';
GRANT ALL ON monica.* TO 'monica'@'localhost';
exit
10.chown -R www-data. /var/www
# 设置文件权限
11.su www-data && cd /var/www/monica
# 切换到www-data用户,配置monica,如切换用户失败,请临时在/etc/password文件里,配置www-data使用/bin/bash
![minica-4.png minica-4.png](https://liujia.anqun.org/usr/uploads/2018/10/09/768934091169456.png)
12.cp .env.example .env
# 创建配置文件.env,修改里边的mysql数据库连接信息
![minica-8.jpg minica-8.jpg](https://liujia.anqun.org/usr/uploads/2018/10/09/768943532592026.jpg)
13.composer config -g repo.packagist composer https://packagist.laravel-china.org && composer install --no-interaction --no-suggest --no-dev --ignore-platform-reqs
# 安装依赖包
![minica-5.png minica-5.png](https://liujia.anqun.org/usr/uploads/2018/10/09/768933801661688.png)
14.php artisan key:generate
# 生成新的key
15.php artisan setup:production
# 初始化
![minica-6.png minica-6.png](https://liujia.anqun.org/usr/uploads/2018/10/09/768931505641413.png)
16.crontab -e
# 添加定时任务
* * * * * sudo -u www-data php /var/www/monica/artisan schedule:run
17./etc/apache2/sites-enabled/000-default.conf
# 更改默认站点的配置文件,文件路径设置为
DocumentRoot /var/www/monica/public
# 添加目录配置内容
<Directory /var/www/monica/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# 添加php文件处理
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.1-fpm.sock|fcgi://localhost/"
</FilesMatch>
![minica-9.png minica-9.png](https://liujia.anqun.org/usr/uploads/2018/10/09/76894721659635.png)
18.a2enmod rewrite proxy_fcgi
# 启用 apache 的 rewrite 和 fcgi 模块
19.systemctl restart apache2
# 重启 apache
20.在浏览器里测试访问monica,正常
![minica-10.png minica-10.png](https://liujia.anqun.org/usr/uploads/2018/10/09/770452891612092.png)
参考: