user nginx; worker_processes 1; error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info; pid /run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/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"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; index index.html index.htm index.php; # Load modular configuration files from the /etc/nginx/conf.d directory. # See #include # for more information. include /etc/nginx/conf.d/*.conf; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; root /usr/share/nginx/html; #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass ; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /usr/share/nginx/html; try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } }
现在,创建 supervisor.conf 文件并添加下面的行。
# nano supervisord.conf
然后,添加以下行。
[unix_http_server] file=https://www.jb51.net/tmp/supervisor.sock ; (the path to the socket file) [supervisord] logfile=https://www.jb51.net/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log) logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) logfile_backups=10 ; (num of main logfile rotation backups;default 10) loglevel=info ; (log level;default info; others: debug,warn,trace) pidfile=https://www.jb51.net/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid) nodaemon=false ; (start in foreground if true;default false) minfds=1024 ; (min. avail startup file descriptors;default 1024) minprocs=200 ; (min. avail process descriptors;default 200) ; the below section must remain in the config file for RPC ; (supervisorctl/web interface) to work, additional interfaces may be ; added by defining them in separate rpcinterface: sections [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket [program:php-fpm] command=https://www.jb51.net/usr/sbin/php-fpm -c /etc/php/fpm stdout_events_enabled=true stderr_events_enabled=true [program:php-fpm-log] command=tail -f /var/log/php-fpm/php-fpm.log stdout_events_enabled=true stderr_events_enabled=true [program:mysql] command=https://www.jb51.net/usr/bin/mysql --basedir=https://www.jb51.net/usr --datadir=https://www.jb51.net/var/lib/mysql --plugin-dir=https://www.jb51.net/usr/lib/mysql/plugin --user=mysql --log-error=https://www.jb51.net/var/log/mysql/error.log --pid-file=https://www.jb51.net/var/run/mysqld/mysqld.pid --socket=https://www.jb51.net/var/run/mysqld/mysqld.sock --port=3306 stdout_events_enabled=true stderr_events_enabled=true [program:nginx] command=https://www.jb51.net/usr/sbin/nginx stdout_events_enabled=true stderr_events_enabled=true [eventlistener:stdout] command = supervisor_stdout buffer_size = 100 events = PROCESS_LOG result_handler = supervisor_stdout:event_handler
添加完后,保存并关闭文件。
5. 构建 WordPress 容器