forked from helloxz/Docker-LNMP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
wyx's linux
committed
Jan 11, 2019
1 parent
5300e3a
commit 75b7338
Showing
7 changed files
with
219 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
version: '3' | ||
|
||
services: | ||
cgi: | ||
container_name: cgi | ||
build: ./docker/files/cgi | ||
tty: true | ||
restart: always | ||
expose: | ||
- "9000" | ||
volumes: | ||
- ./www:/data/www | ||
- ./docker/log/cgi:/var/log/php-fpm | ||
depends_on: | ||
- mysql | ||
- redis | ||
links: | ||
- mysql:mysql | ||
- redis:redis | ||
proxy: | ||
container_name: proxy | ||
build: ./docker/files/proxy | ||
tty: true | ||
restart: always | ||
ports: | ||
- "80:80" | ||
- "443:443" | ||
volumes: | ||
- ./www:/data/www | ||
- ./docker/config/proxy/conf.d:/etc/nginx/conf.d | ||
- ./docker/log/proxy:/var/log/nginx | ||
depends_on: | ||
- cgi | ||
links: | ||
- cgi | ||
mysql: | ||
container_name: mysql | ||
image: daocloud.io/library/mysql:5.6 | ||
restart: always | ||
expose: | ||
- "3306" | ||
ports: | ||
- "3306:3306" | ||
volumes: | ||
- ./docker/data/mysql:/var/lib/mysql | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=root | ||
- MYSQL_DATABASE=yii2 | ||
redis: | ||
container_name: redis | ||
image: daocloud.io/library/redis | ||
restart: always | ||
expose: | ||
- "6379" | ||
ports: | ||
- "6379:6379" | ||
volumes: | ||
- ./docker/data/redis:/data | ||
command: redis-server --appendonly yes | ||
phpmyadmin: | ||
container_name: phpmyadmin | ||
image: daocloud.io/daocloud/phpmyadmin | ||
expose: | ||
- '80' | ||
ports: | ||
- "8080:80" | ||
environment: | ||
- PMA_ARBITRARY=0 | ||
- PMA_HOST=mysql | ||
# 如果取消下面两行注释, phpmyadmin就不用输入用户名和密码, 可以直接登录 | ||
# - PMA_USER=root | ||
# - PMA_PASSWORD=root | ||
depends_on: | ||
- mysql | ||
links: | ||
- mysql:mysql | ||
phpredisadmin: | ||
container_name: phpredisadmin | ||
image: erikdubbelboer/phpredisadmin | ||
expose: | ||
- '80' | ||
ports: | ||
- "8081:80" | ||
environment: | ||
- REDIS_1_HOST=redis | ||
- REDIS_1_NAME=redis | ||
depends_on: | ||
- redis | ||
links: | ||
- redis:redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
server { | ||
|
||
listen 80 default_server; | ||
listen [::]:80 default_server ipv6only=on; | ||
|
||
server_name localhost; | ||
root /data/www; | ||
index index.php index.html index.htm; | ||
|
||
location / { | ||
# Redirect everything that isn't a real file to index.php | ||
try_files $uri $uri/ /index.php$is_args$args; | ||
} | ||
|
||
# deny accessing php files for the /assets directory | ||
location ~ ^/assets/.*\.php$ { | ||
deny all; | ||
} | ||
|
||
location ~ \.php$ { | ||
include fastcgi_params; | ||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
fastcgi_pass cgi:9000; | ||
try_files $uri =404; | ||
} | ||
|
||
location ~* /\. { | ||
deny all; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
FROM centos:7.2.1511 | ||
|
||
RUN yum install -y epel-release &&\ | ||
rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm | ||
|
||
RUN yum install -y --enablerepo=remi --enablerepo=remi-php72 \ | ||
php \ | ||
php-opcache \ | ||
php-devel \ | ||
php-mbstring \ | ||
php-xml \ | ||
php-zip \ | ||
php-cli \ | ||
php-fpm \ | ||
php-mcrypt \ | ||
php-mysql \ | ||
php-pdo \ | ||
php-curl \ | ||
php-gd \ | ||
php-mysqld \ | ||
php-bcmath \ | ||
php-redis \ | ||
wget \ | ||
gcc \ | ||
gcc-c++ \ | ||
make \ | ||
unzip &&\ | ||
mkdir /run/php-fpm/ &&\ | ||
yum clean all | ||
|
||
RUN curl -sSL https://getcomposer.org/installer | php &&\ | ||
mv composer.phar /usr/local/bin/composer &&\ | ||
composer config -g repo.packagist composer https://packagist.phpcomposer.com &&\ | ||
composer global require fxp/composer-asset-plugin v1.4.2 -vvv | ||
|
||
RUN sed -i 's/listen = 127.0.0.1:9000/listen = [::]:9000/p' /etc/php-fpm.d/www.conf &&\ | ||
sed -i '/listen.allowed_clients = 127.0.0.1/d' /etc/php-fpm.d/www.conf | ||
|
||
|
||
COPY docker-entrypoint.sh /usr/local/bin/ | ||
|
||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh | ||
|
||
CMD ["docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
# @auther <[email protected]> | ||
|
||
echo "info: starting php-fpm.." | ||
/usr/sbin/php-fpm -c /etc/php.ini -y /etc/php-fpm.conf | ||
tail -f /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM centos:7.2.1511 | ||
|
||
RUN yum install -y epel-release &&\ | ||
rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm &&\ | ||
yum install -y --enablerepo=remi wget gcc gcc-c++ make | ||
|
||
RUN wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm &&\ | ||
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm &&\ | ||
yum -y install nginx &&\ | ||
mkdir -p /data/www | ||
|
||
# COPY ./Yii2.conf /etc/nginx/conf.d/default.conf | ||
|
||
COPY docker-entrypoint.sh /usr/local/bin/ | ||
|
||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh | ||
|
||
CMD ["docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
# @auther <[email protected]> | ||
|
||
echo "info: nginx non-daemon startup" | ||
nginx -c /etc/nginx/nginx.conf | ||
tail -f /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
// Docker-LNMP | ||
try { | ||
$dbh = new PDO('mysql:host=mysql;dbname=mysql', 'root', root); | ||
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | ||
$dbh->exec('SET CHARACTER SET utf8'); | ||
$dbh = null; | ||
} catch(PDOException $e) { | ||
print 'Error: ' . $e->getMessage() . '<br>'; | ||
die(); | ||
} | ||
echo '<center><h2>成功通过 PDO 连接到 MySQL 服务器</h2></center>' . PHP_EOL; | ||
|
||
|
||
$redis = new Redis(); | ||
$result = $redis->connect('redis', 6379); | ||
if ($result) { | ||
echo '<center><h2>成功通过 PHP 连接到 Redis </h2></center>' . PHP_EOL; | ||
} | ||
// $redis->auth('123456'); | ||
$redis->set('key1', 'val1'); | ||
echo '<center><h2>Set Redis: key1 = ' . $redis->get('key1') . '</h2></center>' . PHP_EOL; | ||
|
||
phpinfo(); |