MAC上搭建LNMP环境的文章收藏,开发工具推荐
https://blog.csdn.net/m_nanle_xiaobudiu/article/details/105649294
推荐使用的是docker方式,运营lnmp容器来实现快速搭建
镜像名称:haveyb/lnmp
主要命令摘要:
cd ~
cd .docker
vi daemon.json
#将文件内容替换为下面内容
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
docker pull haveyb/lnmp
docker run -itd --name lnmp --privileged -p 6379:6379 -p 80:80 -p 3307:3306 -v /Users/SH-Server:/data haveyb/lnmp /usr/sbin/init
docker exec -it lnmp bash
#exit回到MAC系统中,添加域名绑定到本机
sudo vi /etc/hosts
# 先从mac进入容器内部
docker exec -it lnmp bash
#然后到 /usr/local/nginx/cond.d 目录下创建一个名为 ttt.haveyb.com.conf 的文件,内容如下:
server {
listen 80;
server_name ttt.haveyb.com;
client_max_body_size 128M;
charset utf-8;
error_log /usr/local/nginx/logs/error/ttt.haveyb.com.log error;
access_log /usr/local/nginx/logs/access/ttt.haveyb.com.log main;
root /data/ttt;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ ^/assets/.*\.php$ {
deny all;
}
location /favicon.ico {
log_not_found off;
access_log off;
}
error_page 404 403 500 502 503 504 /404.html;
location = /404.html {
root /data/errorPage;
}
location ~ \.php$ {
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
#编写测试文件,到定义的网站目录下编写一个测试的PHP文件,这里就是上面指定的 /data/ttt 目录
cd /data
mkdir ttt
vi index.php
<?php
phpinfo();
程序管理(在docker 容器中操作)
systemctl status/start/stop/restart/reload nginx
# 站点的配置文件放在 /usr/local/nginx/conf.d 目录下
systemctl status/start/stop/restart/reload php-fpm
# php.ini 文件位于/usr/local/php/etc/php.ini
# phpize全局可用
systemctl status/start/stop/restart/reload mysql
# MySQL 数据文件、慢查询日志、错误日志位于 /usr/local/mysql/data 目录下
# 配置文件位于 /etc/my.cnf 可以通过设置mysql错误日志级别 log_error_verbosity 来减少mysql错误日志的记录,默认是都记录,建议添加 log_error_verbosity = 1,即只记录error
# 初始密码:123456
systemctl status/start/stop/restart/reload redis
# conf 配置文件位于 /etc/redis.conf,哨兵sentinel配置文件位于 /etc/redis-sentinel.conf
# 初始密码:haveyb
systemctl status/start/stop/restart/reload memcached
四、Docker 使用过程中可能遇到的问题及解决方案
1、Docker创建容器后并映射端口号后,navicat 远程连接mysql
2、Docker中使用git clone 报错 Could not resolve host: github.com; Unknown error
3、进入容器后,没有clear指令
yum install ncurses
使用 mac 开发过程中,建议使用的软件
1、开发idea 还是使用 PHPStorm
2、连接本地、远程SSH 使用 Termius
3、虚拟机:vmware fusion,只放一些MAC中无法被代替的,否则就没必要了吧
4、连接数据库:navicat Premium
5、接口测试 postman