Docker configuration nginx,php7,mysql

Download php7, mysql, nginx

$ docker pull php:7-fpm-alpine
$ docker pull nginx
$ docker pull mysql

Run php

在这里必须挂载目录到php-fpm, nginx不会直接执行,它检测到php文件,会把php文件的路径发到php-fpm去,php-fpm再依据nginx发过来的路径找到代码并执行啊。

$ docker run -it --rm --name xphp --link xmysql:xmysql -v /Users/zhouitpro/www/docker_web:/usr/share/nginx/html php:7-fpm-alpine
# --link xmysql:xmysql 映射mysql

Install php ext

# 安装pdo_mysql
$ docker exec -it run xphp bash
Docker# docker-php-ext-install pdo_mysql
Docker# docker-php-ext-enable pdo_mysql

Run Nginx

nginx config file

server {
    listen       80;
    server_name  localhost;
    root /usr/share/nginx/html/;
    location ~ \.php$ {
        fastcgi_pass xphp:9000; # 这里对应上面的php-fpm别名, php-fpm端口默认是9000
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
    location ~ /\.ht {
        deny  all;
    }
}
$ docker run -it --rm  --link xphp:xphp -v /Users/zhouitpro/www/docker_web:/usr/share/nginx/html  -v /Users/zhouitpro/www/docker/site.conf:/etc/nginx/conf.d/default.conf -p 9090:80  nginx

# -p 是转发端口 外部的 9090对应nginx提供的80端口
# --link 是映射上面的 php-fpm
# -v 是映射本地的web目录到nginx的www目录,和配置文件

Mysql

$ docker run -it --rm --name xmysql -e MYSQL_ROOT_PASSWORD=root mysql

62 thoughts on “Docker configuration nginx,php7,mysql”

  1. Wow that waas unusual. I just wrote an incredibly long comment
    but after I clicked submit my comment didn’t show up.
    Grrrr… well I’m noot writing all that over again. Anyways, just
    wanted to say excellent blog!

  2. Heey I know this is off topic but I was wondering if youu
    knew of any widgets I could aadd to my blog that automatically tweet mmy neweest twitter updates.
    I’ve been looking for a plug-in like this for quite some
    time aand was hoping maybe you would have some experience with something llike this.
    Please let me know if youu run into anything. I truly enjoy reading
    your blog andd I ook forward to your new updates.

  3. We are a bunch of volunteers and starting a brand new scheme in our community.
    Your website provided us with useful information to work on. You’ve performed a formidable process and our entire group will likely be grateful to you.

  4. I don’t even understand how I finished up here, however I believed this
    publish was once good. I do not know who you’re however definitely you are going to a famous blogger for those who aren’t already.
    Cheers!

  5. Just wish to say your article is as astounding.

    The clearness in your post is just nice and i could assume you’re an expert on this subject.
    Well with your permission let me to grab your feed
    to keep up to date with forthcoming post. Thanks a million and please
    carry on the rewarding work.

  6. I was wondering if you ever thought of changing the layout of your blog?
    Its very well written; I love what youve got to say.

    But maybe you could a little more in the way of content so people
    could connect with it better. Youve got an awful lot of
    text for only having 1 or two images. Maybe you could space it out better?

  7. However, this may be a sign he is just looking to convince himself that they has moved
    after dark relationship. In fact, the second which you open your mouth approach him is as soon as the real attraction starts, and
    time which you spent looking nice becomes irrelevant.
    The bottom line is that if she works a whole lot and have a very great deal of time to
    suit your needs, something is going to have to give.

  8. Wow that was unusual. I just wrote an very long comment but after I clicked submit my comment didn’t show up.
    Grrrr… well I’m not writing all that over again. Regardless, just wanted to say wonderful blog!

  9. There are other ways though and I think these are a
    bit more effective than a big plate of spaghetti.

    Colleges, universities, , and community centers are excellent starting points.
    You might think that your tastes are highly divergent and
    which you two could therefore then never share a life together.

  10. I’m impressed, I have to admit. Rarely do I come across a blog that’s equally educative and
    amusing, and let me tell you, you have hit the nail on the head.

    The problem is something that too few folks are speaking intelligently about.
    I’m very happy I found this in my search for
    something regarding this.

  11. Hey There. I found your blog using msn. This is a very
    well written article. I’ll make suree to bookmark it and return to read more of your useful info.Thanks for
    the post. I’ll definitely comeback.

  12. I don’t even understand how I finished up here,
    however I thought this put up was good. I don’t recognize who you are but
    definitely you are going to a famous blogger if you aren’t already.

    Cheers!

  13. We absolutely love your blog and find most of your post’s
    to be exactly what I’m looking for. Does one offer guest writers to write
    content to suit your needs? I wouldn’t mind composing a post or elaborating on most of the subjects you write regarding here.
    Again, awesome web site!

  14. Hi! This is my first comment here so I just wanted to give a quick shout out and tell you I truly enjoy reading
    through your articles. Can you recommend any other blogs/websites/forums that go over the same topics?
    Appreciate it!

  15. I love your blog.. very nice colors & theme.
    Did you design this website yourself or did you hire someone
    to do it for you? Plz respond as I’m looking to design my own blog and would like to know where u got this from.

    cheers

  16. Wonderful article! This is the kind of info that are meant to be shared across the web.
    Shame on Google for no longer positioning this post upper!
    Come on over and consult with my web site .

    Thanks =)

  17. Hey There. I found your blog using msn. This is an extremely well wrirten article.
    I’ll be sure to bookmark it and come baqck to read more of your ueful info.
    Thanks ffor the post. I will certainly return.

  18. Greetings from Idaho! I’m bored at work so I decided to check out your
    website on myy iphone during lunch break. I love the info you present here and can’t wait to take a look
    when I get home. I’m surprised at hoow fast your blog loaed on mmy phone ..

    I’m not even using WIFI, just 3G .. Anyhow, good blog!

  19. Hmm it seems like your blog ate my first comment (it was super long) so I guess I’ll just sum it up what I submitted and
    say, I’m thoroughly enjoying your blog. I as well am an aspiring blog blogger but I’m still new to everything.

    Do you have any suggestions for newbie blog writers?
    I’d definitely appreciate it.

  20. What i don’t realize is in truth how you’re not really a lot more smartly-liked than you may be right now.
    You’re very intelligent. You already know thus considerably in terms
    of this topic, made me for my part believe it from numerous numerous angles.
    Its like women and men don’t seem to be interested except it is something to
    accomplish with Girl gaga! Your personal stuffs
    outstanding. At all times deal with it up!

  21. Great blog right here! Also your website so much up very
    fast! What host are you the use of? Can I get your associate link on your host?
    I wish my web site loaded up as quickly as yours lol

  22. I think what you said was actually very reasonable.
    However, think on this, suppose you wrote
    a catchier post title? I am not suggesting your information is not solid., but what if you added a
    title to possibly grab folk’s attention? I mean Docker configuration nginx,
    php7,mysql – 秀坤 is kinda boring. You ought to peek at Yahoo’s front page and
    note how they write article headlines to get viewers to click.
    You might add a related video or a pic or two to get people interested about what you’ve written. Just my opinion, it could bring your posts a little
    bit more interesting.

  23. Write more, thats all I have to say. Literally, it seems as
    though you relied on the video to make your point. You clearly know what youre talking about, why waste your intelligence on just posting videos to your site when you could be giving us something enlightening to read?

  24. Having read this I thought it was very informative.
    I appreciate you spending some time and effort to put this short article together.
    I once again find myself spending a significant amount of time both
    reading and commenting. But so what, it was still worth it!

  25. Do you have a spam problem on this blog; I also am
    a blogger, and I was wondering your situation; many of us have develooed some nice practices
    aand we are lookinbg to swap solutions wiyh others,
    why not shoot mme an email if interested.

  26. However, this may be a sign that he is just wanting to convince himself he
    has moved after dark relationship. You tried dating and meeting people there is however no
    rapport and “chemistry”. You might think that the tastes are highly divergent and which you two could therefore then never share your life together.

Leave a Reply

Your email address will not be published. Required fields are marked *