docker 安装
使用官方提供的安装脚本,安装最新版的Docker
curl -sSL https://get.docker.com/ | sh
安装完成后,通过如下命令启动Docker的守护进程,并让它随系统启动自动加载
sudo service docker start
sudo chkconfig docker on
## 或者
sudo systemctl start docker
sudo systemctl enable docker
添加用户(jerry)到Docker组
sudo usermod -aG docker jerry
命令笔记(centos),基于docker镜像2233466866/lnmp
下载镜像
docker pull 2233466866/lnmp
创建基本目录
mkdir -p /app/lnmp/default /docker/lnmp/data/mysql /docker/lnmp/conf/vhost /docker/lnmp/logs /docker/lnmp/temp /docker/lnmp/backup
下载容器配置文件到本地相应目录
docker run -itd -v /sys/fs/cgroup:/sys/fs/cgroup:ro --privileged=true --name=lnmp 2233466866/lnmp
docker exec -it lnmp /bin/bash
docker cp lnmp:/etc/my.cnf /docker/lnmp/conf/my.cnf
docker cp lnmp:/usr/local/nginx/conf/nginx.conf /docker/lnmp/conf/nginx.conf
cp /docker/lnmp/conf/my.cnf /docker/lnmp/backup/my.cnf
cp /docker/lnmp/conf/nginx.conf /docker/lnmp/backup/nginx.conf
查看或修改基本配置(代码目录,日志保存目录及vhost目录配置添加)
my.cnf
[mysqld]
datadir=/data/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
nginx.conf
user www; worker_processes auto; worker_cpu_affinity auto; worker_cpu_affinity auto; pid logs/nginx.pid; events { worker_connections 102400; } http { charset utf-8; server_tokens off; log_format main '$remote_addr - $remote_user [$time_iso8601] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; include mime.types; default_type application/octet-stream; client_max_body_size 20M; sendfile on; keepalive_timeout 20; gzip on; gzip_vary on; gzip_comp_level 1; gzip_types text/css application/javascript application/json image/png image/webp image/apng image/jpeg image/x-icon; autoindex_localtime on error_log /logs/z_error.log; access_log /logs/z_$host.log main; server { listen 80 default; root /www/default; return 500; } include vhost/*.conf; }
停止并删除测试容器
docker stop lnmp
docker rm lnmp
重新创建容器
docker run -dit \
-p 80:80 \
-p 443:443 \
-p 3306:3306 \
-p 9000:9000 \
-e TC="Asia/Shanghai" \
-v /sys/fs/cgroup:/sys/fs/cgroup:ro \
-v /app/lnmp:/www \
-v /docker/lnmp/data/mysql:/data/mysql \
-v /docker/lnmp/conf/my.cnf:/etc/my.cnf \
-v /docker/lnmp/conf/nginx.conf:/usr/local/nginx/conf/nginx.conf \
-v /docker/lnmp/conf/vhost:/usr/local/nginx/conf/vhost \
-v /docker/lnmp/logs:/logs \
--privileged=true \
--name=lnmp \
2233466866/lnmp
mysql 数据库配置(/etc/my.cnf)
/bin/mysql_secure_installation
cat /var/log/mysqld.log|grep 'A temporary password'
SET PASSWORD = PASSWORD('123456');
php.ini 配置(/usr/local/php7/lib/php.ini)
mysqli.default_socket = /var/lib/mysql/mysql.sock
linux 相关设置修改
添加不能登陆的用户www
groupadd www
useradd -M -g www -s /usr/sbin/nologin www
修改时区(/etc/profile)
TZ='Asia/Shanghai'; export TZ
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
多站点配置
www.test.test.conf
server { listen 80; server_name test.test; rewrite ^(.*)$ $scheme://www.test.test$1 permanent; } server { listen 80; server_name www.test.test; if ($time_iso8601 ~ "^(\d{4}-\d{2}-\d{2})") { set $ttt $1; } access_log /logs/$host-$ttt-access.log main; root /www/test; location / { index index.php index.html index.htm; } location ~* \.php { include fastcgi_params; fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
更新日志
- ZWEI《迟暮的花 (Explicit)》[FLAC/分轨][137.51MB]
- 八戒《Gimme Gimme Love》[320K/MP3][39.21MB]
- 宝丽金群星1991《宝丽金超白金精选特辑Ⅱ》2CD[WAV+CUE][1.1G]
- 姚斯婷《但愿人长久》头版限量编号24K金碟[低速原抓WAV+CUE][1G]
- 孙露《试机孙露AMCD》WAV+CUE
- 张雨生《GreatestHits-XRCD2+HMCD》[WAV+CUE]
- FIM-无可挑剔的声音(SuperSound声霸1)[FLAC+CUE]
- 萧亚轩《3面夏娃/三面夏娃》[WAV+CUE][1G]
- 佛音《大悲咒》新加坡金碟珍藏版[WAV+CUE][994M]
- 刘德丽《赤的疑惑HQCD》头版限量编号MQA[WAV+CUE][1G]
- 谢采妘《古典情·现代心精选辑》[南方唱片]2CD[WAV整轨]
- [好时代珍藏系列]山口百惠《赤之传说》[WAV+CUE]
- RonaldBrautigam,PeterMasseursandConcertgebouwOrchestraAmsterdam-ShostakovichTheJazz
- 筷子兄弟《老男孩》[WAV+CUE][899M]
- 陈曦《寂寞在唱歌HQCD》2023头版限量编号[WAV+CUE][1G]