docker搭建nginx+php-fpm开发环境
来源:互联网 发布:手机淘宝6.10.3 编辑:程序博客网 时间:2024/06/06 11:16
一、创建目录:
mkdir -p /data1/www/app;mkdir -p /data1/www/logs;mkdir -p /data1/www/php;mkdir -p /data1/www/nginx;mkdir -p /data1/www/php/fpm.d;mkdir -p /data1/www/nginx/vhost;chmod 777 -R /data1/www;
添加项目:
vim /data1/www/app/www.mydemo.com/index.php
<?php echo 22; phpinfo();
二、启动容器:
docker run -it --name=web_container --net=host -v /data1:/data1 centos /bin/bash;yum -y install wget;yum -y install initscripts;
三、安装nginx
依赖说明:
- zlib: Nginx提供gzip模块,需要zlib库支持。
- openssl: Nginx提供SSL功能
- pcre: 支持地址重写rewrite功能
依赖安装:
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel;
依赖检测:
rpm -qa zlib;rpm -qa openssl;rmp -qa pcre;
nginx安装
wget http://nginx.org/download/nginx-1.10.3.tar.gztar -zxvf nginx-1.10.3.tar.gz;cd nginx-1.10.3;./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_flv_module;make && make install;
创建用户
groupadd wwwuseradd -r -g www www
在宿主机上修改添加配置文件: vim /data1/www/nginx/mime.types
types { text/html html htm shtml; text/css css; text/xml xml; image/gif gif; image/jpeg jpeg jpg; application/javascript js; application/atom+xml atom; application/rss+xml rss; text/mathml mml; text/plain txt; text/vnd.sun.j2me.app-descriptor jad; text/vnd.wap.wml wml; text/x-component htc; image/png png; image/tiff tif tiff; image/vnd.wap.wbmp wbmp; image/x-icon ico; image/x-jng jng; image/x-ms-bmp bmp; image/svg+xml svg svgz; image/webp webp; application/font-woff woff; application/java-archive jar war ear; application/json json; application/mac-binhex40 hqx; application/msword doc; application/pdf pdf; application/postscript ps eps ai; application/rtf rtf; application/vnd.apple.mpegurl m3u8; application/vnd.ms-excel xls; application/vnd.ms-fontobject eot; application/vnd.ms-powerpoint ppt; application/vnd.wap.wmlc wmlc; application/vnd.google-earth.kml+xml kml; application/vnd.google-earth.kmz kmz; application/x-7z-compressed 7z; application/x-cocoa cco; application/x-java-archive-diff jardiff; application/x-java-jnlp-file jnlp; application/x-makeself run; application/x-perl pl pm; application/x-pilot prc pdb; application/x-rar-compressed rar; application/x-redhat-package-manager rpm; application/x-sea sea; application/x-shockwave-flash swf; application/x-stuffit sit; application/x-tcl tcl tk; application/x-x509-ca-cert der pem crt; application/x-xpinstall xpi; application/xhtml+xml xhtml; application/xspf+xml xspf; application/zip zip; application/octet-stream bin exe dll; application/octet-stream deb; application/octet-stream dmg; application/octet-stream iso img; application/octet-stream msi msp msm; application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx; application/vnd.openxmlformats-officedocument.presentationml.presentation pptx; audio/midi mid midi kar; audio/mpeg mp3; audio/ogg ogg; audio/x-m4a m4a; audio/x-realaudio ra; video/3gpp 3gpp 3gp; video/mp2t ts; video/mp4 mp4; video/mpeg mpeg mpg; video/quicktime mov; video/webm webm; video/x-flv flv; video/x-m4v m4v; video/x-mng mng; video/x-ms-asf asx asf; video/x-ms-wmv wmv; video/x-msvideo avi;}
新增fast_cig: vim /data1/www/nginx/fastcgi_params
fastcgi_param QUERY_STRING $query_string;fastcgi_param REQUEST_METHOD $request_method;fastcgi_param CONTENT_TYPE $content_type;fastcgi_param CONTENT_LENGTH $content_length;fastcgi_param SCRIPT_NAME $fastcgi_script_name;fastcgi_param REQUEST_URI $request_uri;fastcgi_param DOCUMENT_URI $document_uri;fastcgi_param DOCUMENT_ROOT $document_root;fastcgi_param SERVER_PROTOCOL $server_protocol;fastcgi_param REQUEST_SCHEME $scheme;fastcgi_param HTTPS $https if_not_empty;fastcgi_param GATEWAY_INTERFACE CGI/1.1;fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;fastcgi_param REMOTE_ADDR $remote_addr;fastcgi_param REMOTE_PORT $remote_port;fastcgi_param SERVER_ADDR $server_addr;fastcgi_param SERVER_PORT $server_port;fastcgi_param SERVER_NAME $server_name;# PHP only, required if PHP was built with --enable-force-cgi-redirectfastcgi_param REDIRECT_STATUS 200;
vim /data1/www/nginx/nginx.conf
user www;worker_processes 5;error_log logs/nginx-error.log;pid nginx/nginx.pid;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; client_body_temp_path /tmp/client_body_temp_path; fastcgi_temp_path /tmp/fastcgi_temp_path; proxy_temp_path /tmp/proxy_temp_path; scgi_temp_path /tmp/scgi_temp; uwsgi_temp_path /tmp/uwsgi_temp_path; sendfile on; keepalive_timeout 65; gzip on; include vhost/*.conf;}
配置文件检测
/usr/local/nginx/sbin/nginx -c /data1/www/nginx/nginx.conf -p /data1/www -t
新增项目配置: vim /data1/www/nginx/vhost/mydemo.com.conf
server { listen 80 ; root /data1/www/app/www.mydemo.com/; server_name www.mydemo.com mydemo.com; access_log logs/nginx_www.mydemo.com-access_log main; error_log logs/nginx_www.mydemo.com-error_log; rewrite "^/(.*)" /index.php/$1 last; location / { proxy_ignore_client_abort on; fastcgi_pass 127.0.0.1:9023; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_param SCRIPT_URL $script_uri; #fastcgi_param REQUEST_ID $request_uid; include fastcgi_params; }}
启动nginx:
/usr/local/nginx/sbin/nginx -c /data1/www/nginx/nginx.conf -p /data1/www
平滑重启
Kill -HUP ${nginx_pid}
四、安装php-fpm
yum -y install gd-devel zlib-devel libjpeg-devel libpng-devel libiconv-devel freetype-devel libxml2 libxml2-devel openssl openssl-devel curl-devel libxslt-devel libmcrypt-devel mhash mcryptwget http://am1.php.net/get/php-7.2.0.tar.bz2/from/this/mirror ;tar -jxvf mirror;cd php-7.2.0;./configure --prefix=/usr/local/php --enable-fpm --enable-cli --enable-pcntl --with-curl;make && make install;
新增配置文件: vim /data1/www/php/php-fpm.conf
[global]pid = php/php-fpm.piderror_log = logs/php-fpm.logemergency_restart_threshold = 20emergency_restart_interval = 60sprocess_control_timeout = 0process.max = 2048daemonize = yesrlimit_files = 65535rlimit_core = 67108864events.mechanism = epoll; auto include phpfpm configureinclude = php/fpm.d/*.conf
vim /data1/www/php/php.ini
[PHP]engine = Onshort_open_tag = Offprecision = 14output_buffering = 4096zlib.output_compression = Offimplicit_flush = Offunserialize_callback_func =serialize_precision = -1disable_functions =disable_classes =zend.enable_gc = Onexpose_php = Onmax_execution_time = 30max_input_time = 60memory_limit = 128Merror_reporting = E_ALLdisplay_errors = Ondisplay_startup_errors = Onlog_errors = Onlog_errors_max_len = 1024ignore_repeated_errors = Offignore_repeated_source = Offreport_memleaks = Onhtml_errors = Onvariables_order = "GPCS"request_order = "GP"register_argc_argv = Offauto_globals_jit = Onpost_max_size = 8Mauto_prepend_file =auto_append_file =default_mimetype = "text/html"default_charset = "UTF-8"doc_root =user_dir =enable_dl = Offfile_uploads = Onupload_max_filesize = 2Mmax_file_uploads = 20allow_url_fopen = Onallow_url_include = Offdefault_socket_timeout = 60[CLI Server]cli_server.color = On[Date][filter][iconv][intl][sqlite3][Pcre][Pdo][Pdo_mysql]pdo_mysql.cache_size = 2000pdo_mysql.default_socket=[Phar][mail function]SMTP = localhostsmtp_port = 25mail.add_x_header = On[ODBC]odbc.allow_persistent = Onodbc.check_persistent = Onodbc.max_persistent = -1odbc.max_links = -1odbc.defaultlrl = 4096odbc.defaultbinmode = 1[Interbase]ibase.allow_persistent = 1ibase.max_persistent = -1ibase.max_links = -1ibase.timestampformat = "%Y-%m-%d %H:%M:%S"ibase.dateformat = "%Y-%m-%d"ibase.timeformat = "%H:%M:%S"[MySQLi]mysqli.max_persistent = -1mysqli.allow_persistent = Onmysqli.max_links = -1mysqli.cache_size = 2000mysqli.default_port = 3306mysqli.default_socket =mysqli.default_host =mysqli.default_user =mysqli.default_pw =mysqli.reconnect = Off[mysqlnd]mysqlnd.collect_statistics = Onmysqlnd.collect_memory_statistics = On[OCI8][PostgreSQL]pgsql.allow_persistent = Onpgsql.auto_reset_persistent = Offpgsql.max_persistent = -1pgsql.max_links = -1pgsql.ignore_notice = 0pgsql.log_notice = 0[bcmath]bcmath.scale = 0[browscap][Session]session.save_handler = filessession.use_strict_mode = 0session.use_cookies = 1session.use_only_cookies = 1session.name = PHPSESSIDsession.auto_start = 0session.cookie_lifetime = 0session.cookie_path = /session.cookie_domain =session.cookie_httponly =session.serialize_handler = phpsession.gc_probability = 1session.gc_divisor = 1000session.gc_maxlifetime = 1440session.referer_check =session.cache_limiter = nocachesession.cache_expire = 180session.use_trans_sid = 0session.sid_length = 26session.trans_sid_tags = "a=href,area=href,frame=src,form="session.sid_bits_per_character = 5[Assertion]zend.assertions = 1[COM][mbstring][gd][exif][Tidy]tidy.clean_output = Off[soap]soap.wsdl_cache_enabled=1soap.wsdl_cache_dir="/tmp"soap.wsdl_cache_ttl=86400soap.wsdl_cache_limit = 5[sysvshm][ldap]ldap.max_links = -1[dba][opcache][curl][openssl]
新增项目配置:
vim /data1/www/php/fpm.d/mydemo.com.conf
[mydemo.com]user = wwwgroup = wwwlisten = 127.0.0.1:9023listen.allowed_clients = 127.0.0.1pm = dynamicpm.max_children = 512pm.start_servers = 5pm.min_spare_servers = 4pm.max_spare_servers = 64pm.max_requests = 1500;pm.status_path = /dpool_monitorslowlog = logs/$pool-slow_logrequest_slowlog_timeout = 2request_terminate_timeout = 30catch_workers_output = nosecurity.limit_extensions = ""access.log=logs/php-fpm_$pool.access.logaccess.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
启动命令:
/usr/local/php/sbin/php-fpm -c /data1/www/php/php.ini -y /data1/www/php/php-fpm.conf -p /data1/www
平滑重启:
kill -USR2 fpm-pid
阅读全文
0 0
- docker搭建nginx+php-fpm开发环境
- Nginx+PHP-FPM环境搭建
- nginx+php-fpm环境搭建
- 【docker】使用docker快速搭建nginx+php开发环境
- docker php-fpm nginx 配置
- docker 搭建php开发环境
- docker搭建php,nginx,mysql环境
- Mac OSX 10.9搭建nginx+mysql+php-fpm环境
- Mac OSX 10.9搭建nginx+mysql+php-fpm环境
- Mac OSX 10.9搭建nginx+mysql+php-fpm环境
- Mac OSX 10.9搭建nginx+mysql+php-fpm环境
- Mac OSX 10.10搭建nginx+mysql+php-fpm环境
- Mac OSX 10.9搭建nginx+mysql+php-fpm环境
- LAMP环境搭建系列之六:Nginx运行php-fpm
- docker 搭建开发环境(nginx,redis)
- nginx + mysql + php-fpm 环境
- linux 下 docker NGINX+PHP+MYSQL+REDIS+Elasticsearch 开发环境搭建
- Linux 下 docker NGINX+PHP+MYSQL+REDIS+Elasticsearch 开发环境搭建
- Django 垃圾短信分类
- 调试器确实能派上用场
- Flink快速上手之Java API使用
- JAVA基础算法——将字符串按照字典倒序排序并输出
- SSH远程链接:SCP远程拷贝文件与文件夹
- docker搭建nginx+php-fpm开发环境
- django从零开始引入bootstrap模板
- Loostrive 1.3.1 响应式杂志中文商业版,漂亮的WordPress主题模板
- ViewPager之可变高度ViewPager
- Java自定义注解Annotation详解
- Spring+SpringMVC+Mybatis框架的搭建
- LeetCode 240. Search a 2D Matrix II
- 布尔变量
- mysql快速检测字段里数据重复