WinNMP – Config
Mục lục nội dung
How to send emails using PHP
WinNMP has 2 options for processing emails sent by PHP’s mail() function: mSmtp and mailToDisk (default). To change the option, edit confphp.ini
and modify sendmail_path
:
- For Development use mailToDisk (the default):
sendmail_path = '"C:/WinNMP/bin/php" -n -f "C:/WinNMP/include/tools/mailtodisk.php"'
Emails will be saved tologmail-XX.txt
- For Production use mSmtp:
sendmail_path = '"C:/WinNMP/bin/msmtp/msmtp.exe" -C "C:/WinNMP/conf/msmtp.ini" -t'
You also need to editconfmsmtp.ini
in order to configure SMTP server options
How to allow access from LAN and Internet to your local project:
In the WinNMP Manager window, go to Project Setup
, check Enable Local Virtual Server
, then Save.
Edit WinNMPconfdomains.dprojectName.conf
directly or go to Project Setup
and click on Edit Nginx Local Virtual Server Configuration File
icon.
Modify like this:
server {
listen 127.0.0.1:80;
listen *:80;
server_name projectName.test projectName.com projectName.myDomain.com;
### Access Restrictions
allow all;
## deny all;
Now Kill
Nginx, Start
Nginx OR Check Nginx Configuration Syntax
.
How to add locations
If you want a location like /phpMyAdmin
to serve files from a directory outside your project (but inside PHP’s open_basedir
), for example C:/WinNMP/include/phpMyAdmin
you need to edit the Nginx config file:
Edit WinNMPconfdomains.dprojectName.conf
to set http://projectName.local/phpMyAdmin Edit WinNMPconfnginx.conf
to set http://localhost/phpMyAdmin
server {
....
location ~ ^/phpMyAdmin/.*.php$ {
root "C:/WinNMP/include";
try_files $uri =404;
include nginx.fastcgi.conf;
fastcgi_pass php_farm;
allow 127.0.0.1;
allow ::1;
deny all;
}
location ~ ^/phpMyAdmin/ {
root "C:/WinNMP/include";
}
}
Notice that the root directive lacks /phpMyAdmin
because Nginx adds the URL path /phpMyAdmin
to the root path, so the resulting directory is C:/WinNMP/include/phpMyAdmin
How set / change / reset mysql(mariadb) root password:
When you log in to Adminer, you use mysql(mariadb) root
account, which by default has no password
In order to set mysql(mariadb) root
password, open a command prompt and type C:WinNMPbinMySqlbinmysqladmin -u root password NEWPASSWORD
In order to change mysql(mariadb) root
password, open a command prompt and type C:WinNMPbinMySqlbinmysqladmin -u root -p'oldpassword' password NEWPASSWORD
If you forgot the mysql(mariadb) root
password, you can reset all user accounts by running C:WinNMPbinMySqlbinmysql_install_db -d c:WinNMPdata
Config nginx.conf:
## For a live site, handling more connections, uncomment, then start WinNMP.exe --phpCgiServers=25: worker_processes 10; worker_rlimit_nofile 260000; events { ## For a live site, uncomment: worker_connections 8096; accept_mutex off; accept_mutex_delay 200ms; } http { server_tokens off; sendfile on; tcp_nopush on; tcp_nodelay on; ssi off; server_names_hash_bucket_size 128; ## Timeouts ## ############## client_body_timeout 60; client_header_timeout 20; keepalive_timeout 25 25; send_timeout 60s; resolver_timeout 3s; # Timeout period for connection with FastCGI-server. It should be noted that this value can't exceed 75 seconds. fastcgi_connect_timeout 5s; # Amount of time for upstream to wait for a fastcgi process to send data. # Change this directive if you have long running fastcgi processes that do not produce output until they have finished processing. # If you are seeing an upstream timed out error in the error log, then increase this parameter to something more appropriate. fastcgi_read_timeout 40s; # Request timeout to the server. The timeout is calculated between two write operations, not for the whole request. # If no data have been written during this period then serve closes the connection. fastcgi_send_timeout 15s; ## Buffers ## ############# fastcgi_buffers 8 32k; fastcgi_buffer_size 32k; #fastcgi_busy_buffers_size 256k; #fastcgi_temp_file_write_size 256k; open_file_cache off; # php max upload limit cannot be larger than this client_max_body_size 0; client_body_buffer_size 256K; client_header_buffer_size 256k; large_client_header_buffers 8 256k; types_hash_max_size 2048; include nginx.mimetypes.conf; #default_type text/html; default_type application/octet-stream; ## Logging ## ############# access_log off; #access_log "d:/sv/log/nginx_access.log"; #error_log "d:/sv/log/nginx_error.log" warn; #debug or warn log_not_found on; #enables or disables messages in error_log about files not found on disk. rewrite_log off; log_format main '$remote_addr - $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; fastcgi_intercept_errors off; # Do Not Change (off) ! #Disable IFRAME #add_header X-Frame-Options SAMEORIGIN; #Prevent Cross-site scripting (XSS) attacks add_header X-XSS-Protection "1; mode=block"; #Prevent MIME-sniffing add_header X-Content-Type-Options nosniff; index index.php index.htm index.html; client_body_in_file_only off; keepalive_disable msie6; reset_timedout_connection on; gzip on; gzip_static on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json text/javascript application/javascript text/xml application/xml application/xml+rss; server { # NEVER ALLOW PUBLIC ACCESS TO THIS SERVER !!! # Instead, create projects using WinNMP.exe, and allow public access only to those projects! # How to allow access from LAN and Internet to your local project: # http://WinNMP.wtriple.com/howtos.php#How-to-allow-access-from-LAN-and-Internet-to-your-local-project listen 127.0.0.1:80 default_server; # Do Not Change ! Security Risk ! #listen [::1]:80 ipv6only=on; # Do Not Change ! Security Risk ! server_name localhost; # Do Not Change ! Security Risk ! # This directive is modified automatically by WinNMP.exe for portability. root "d:/sv/www"; autoindex on; allow 127.0.0.1; # Do Not Change ! Security Risk ! allow ::1; # Do Not Change ! Security Risk ! deny all; # Do Not Change ! Security Risk ! ## deny access to .htaccess files, if Apache's document root ## concurs with nginx's one location ~ /.ht { deny all; } ## Tools are now served from wt-nmp/include/tools/ location ~ ^/tools/.*.php$ { root "d:/sv/include"; try_files $uri =404; include nginx.fastcgi.conf; fastcgi_pass php_farm; allow 127.0.0.1; # Do Not Change ! Security Risk ! allow ::1; # Do Not Change ! Security Risk ! deny all; # Do Not Change ! Security Risk ! } location ~ ^/tools/ { root "d:/sv/include"; allow 127.0.0.1; # Do Not Change ! Security Risk ! allow ::1; # Do Not Change ! Security Risk ! deny all; # Do Not Change ! Security Risk ! } ## How to add phpMyAdmin ## Copy phpMyAdmin files to d:/sv/include/phpMyAdmin then uncomment: #location ~ ^/phpMyAdmin/.*.php$ { # root "d:/sv/include"; # try_files $uri =404; # include nginx.fastcgi.conf; # fastcgi_pass php_farm; # allow 127.0.0.1; # allow ::1; # deny all; #} #location ~ ^/phpMyAdmin/ { # root "d:/sv/include"; #} ## Notice that the root directive lacks /phpMyAdmin because Nginx adds the URL path /phpMyAdmin to the root path, so the resulting directory is d:/sv/include/phpMyAdmin ## PHP for localhost ## ####################### location ~ .php$ { try_files $uri =404; include nginx.fastcgi.conf; include nginx.redis.conf; fastcgi_pass php_farm; allow 127.0.0.1; # Do Not Change ! Security Risk ! allow ::1; # Do Not Change ! Security Risk ! deny all; # Do Not Change ! Security Risk ! } # How to allow access from LAN and Internet to your local project: # http://WinNMP.wtriple.com/howtos.php#How-to-allow-access-from-LAN-and-Internet-to-your-local-project } include domains.d/*.conf; include nginx.phpfarm.conf; }
Config domain.conf:
server { ## How to allow access from LAN and Internet to your local project: ## http://winnmp.wtriple.com/howtos.php#How-to-allow-access-from-LAN-and-Internet-to-your-local-project listen 127.0.0.1:80; listen *:80; ## How to add additional local test server names to my project: ## http://winnmp.wtriple.com/howtos.php#How-to-add-additional-local-test-server-names-to-my-project server_name linholiver.com; ## To manually change the root directive replace the ending comment with: # locked ## http://winnmp.wtriple.com/howtos.php#How-to-change-the-root-directory-of-a-project root "d:/sv/www/linholiver.com"; ## Access Restrictions allow all; ##deny all; ## Add locations: ## http://winnmp.wtriple.com/howtos.php#How-to-add-locations ## Configure for various PHP Frameworks: ## http://winnmp.wtriple.com/nginx.php autoindex on; location ~ .php$ { try_files $uri =404; include nginx.fastcgi.conf; include nginx.redis.conf; fastcgi_pass php_farm; } location / { try_files $uri $uri/ =404; } # access_log off; access_log d:/sv/www/linholiver.com/access.log; # error_log off; error_log d:/sv/www/linholiver.com/error.log; # Custom configuration include d:/sv/www/linholiver.com/*.conf; location ~ /. { deny all; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location ~* .(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|eot|svg|ttf|woff)$ { gzip_static off; add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; access_log off; expires 30d; #prevent hotlink valid_referers none blocked ~.google. ~.bing. ~.yahoo. server_names ~($host); if ($invalid_referer) { rewrite (.*) /hotlink-denied.jpg redirect; # drop the 'redirect' flag for redirect without URL change (internal rewrite) } break; } # stop hotlink loop location = /hotlink-denied.jpg { } location ~* .(txt|js|css)$ { add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; access_log off; expires 30d; break; } #wordpress location /diary { try_files $uri $uri/ /diary/index.php?$args; } location ~ .php$ { fastcgi_split_path_info ^(/diary)(/.*)$; } }
Config mysql.conf:
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html [mysqld] bind-address = localhost port = 3306 character-set-server = utf8 default-storage-engine = InnoDB default-time-zone = '+07:00' datadir = d:/sv/data log-error = d:/sv/log/mysql.log log-bin = wt-nmp-bin expire_logs_days = 3 # Start at 70% of total RAM for dedicated server, else 10%. innodb_buffer_pool_size = 8192M myisam_sort_buffer_size = 768M myisam_max_sort_file_size = 8192M key_buffer_size = 768M max_allowed_packet = 128M tmp_table_size = 1024M max_heap_table_size = 1024M table_definition_cache = 8192 join_buffer_size = 2M read_buffer_size = 4M read_rnd_buffer_size = 2M sort_buffer_size = 20M table_open_cache = 8192 thread_cache_size = 384 group_concat_max_len = 1024 max_length_for_sort_data = 1024 query_cache_size = 256M query_cache_limit = 2M query_cache_type = 1 bulk_insert_buffer_size = 8M innodb_file_per_table = 1 net_buffer_length = 16384K wait_timeout = 7200 connect_timeout = 10 max_connect_errors = 1000 local-infile = 0 concurrent_insert = 2 #### Recovery of myisam tables ############################## ## Temporary uncomment # myisam-recover=backup,force #### Recovery of innodb tables ############################## ### http://dev.mysql.com/doc/refman/5.5/en/forcing-innodb-recovery.html ### Step 1: Uncomment: # innodb_force_recovery = 1 ### Step 2: Restart MariaDB. It will now start, but with innodb_force_recovery, all INSERTs and UPDATEs will be ignored. ### Step 3: Dump all tables ### Step 4: Shutdown MariaDB and delete the data directory. To create MySQL default tables (this will delete all user accounts and set only user [email protected]), run: ## d:/sv/bin/MySQL/bin/mysql_install_db --datadir=d:/sv/data ### Step 5: Remove/comment the innodb_force_recovery line above and restart MariaDB. (It should start normally now) ### Step 6: Restore everything from your backup # SQL Mode # http://dev.mysql.com/doc/refman/5.6/en/server-sql-mode.html # defaults to sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES sql_mode=NO_ENGINE_SUBSTITUTION back_log = 1024 max_connections = 1000 query_cache_min_res_unit = 2K query_prealloc_size = 262144 query_alloc_block_size = 65536 transaction_alloc_block_size = 8192 transaction_prealloc_size = 4096 # innodb settings innodb_large_prefix=1 innodb_purge_threads=1 innodb_file_format = Barracuda innodb_open_files = 1000 innodb_data_file_path= ibdata1:10M:autoextend innodb_buffer_pool_instances=8 innodb_log_files_in_group = 2 innodb_log_file_size = 768M innodb_log_buffer_size = 16M innodb_flush_log_at_trx_commit = 2 innodb_thread_concurrency = 0 innodb_lock_wait_timeout=50 innodb_flush_method = O_DIRECT innodb_support_xa=1 # 200 * # DISKS innodb_io_capacity = 600 innodb_io_capacity_max = 2000 innodb_read_io_threads = 4 innodb_write_io_threads = 2 innodb_flush_neighbors = 1 # mariadb settings [mariadb] #thread-handling = pool-of-threads #thread-pool-size= 20 #mysql --port=3307 --protocol=tcp #extra-port=3307 #extra-max-connections=1 userstat = 0 key_cache_segments = 1 aria_group_commit = none aria_group_commit_interval = 0 aria_log_file_size = 64M aria_log_purge_type = immediate aria_pagecache_buffer_size = 128M aria_sort_buffer_size = 128M [mariadb-5.5] innodb_file_format = Barracuda innodb_file_per_table = 1 #ignore_db_dirs= query_cache_strip_comments=0 innodb_read_ahead = linear innodb_adaptive_flushing_method = estimate innodb_flush_neighbor_pages = 1 innodb_stats_update_need_lock = 0 innodb_log_block_size = 512 log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk [mysqld_safe] socket=/var/lib/mysql/mysql.sock log-error=/home/vmi139738.contaboserver.net/logs/mysql.log #nice = -5 open-files-limit = 8192 [mysqldump] quick max_allowed_packet = 128M [myisamchk] key_buffer = 1024M sort_buffer = 256M read_buffer = 256M write_buffer = 256M [mysqlhotcopy] interactive-timeout [mariadb-10.0] innodb_file_format = Barracuda innodb_file_per_table = 1 # 2 variables needed to switch from XtraDB to InnoDB plugins #plugin-load=ha_innodb #ignore_builtin_innodb ## MariaDB 10 only save and restore buffer pool pages ## warm up InnoDB buffer pool on server restarts innodb_buffer_pool_dump_at_shutdown=1 innodb_buffer_pool_load_at_startup=1 innodb_buffer_pool_populate=0 ## Disabled settings performance_schema=OFF innodb_stats_on_metadata=OFF innodb_sort_buffer_size=2M innodb_online_alter_log_max_size=128M query_cache_strip_comments=0 log_slow_filter =admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk [client] user = root
Config php.ini:
; Generated by NMP - Configuration Editor engine = On zend.ze1_compatibility_mode = Off short_open_tag = On asp_tags = Off precision = 14 y2k_compliance = On output_buffering = off zlib.output_compression = Off implicit_flush = Off unserialize_callback_func = serialize_precision = 100 allow_call_time_pass_reference = Off safe_mode_allowed_env_vars = PHP_ safe_mode_protected_env_vars = LD_LIBRARY_PATH #open_basedir = "d:/sv" include_path = ".;d:/sv/include" disable_functions="allow_url_fopen, disk_free_space, diskfreespace, dl, eval, exec, fp, fput, ftp_connect, ftp_exec, ftp_get, ftp_login, ftp_nb_fput, ftp_put, ftp_raw, ftp_rawlist, highlight_file, ini_alter, ini_get_all, ini_restore, inject_code, msg_receive, msg_send, openlog, passthru, pcntl_alarm, pcntl_exec, pcntl_fork, pcntl_get_last_error, pcntl_getpriority, pcntl_setpriority, pcntl_signal, pcntl_signal_dispatch, pcntl_sigprocmask, pcntl_sigtimedwait, pcntl_sigwaitinfo, pcntl_strerror, pcntl_wait, pcntl_waitpid, pcntl_wexitstatus, pcntl_wifexited, pcntl_wifsignaled, pcntl_wifstopped, pcntl_wstopsig, pcntl_wtermsig, php_uname, popen, posix_ctermid, posix_getgrgid, posix_getgrnam, posix_getlogin, posix_getpwuid, posix_kill, posix_mkfifo, posix_setegid, posix_seteuid, posix_setgid, posix_setpgid, posix_setsid, posix_setuid, posix_uname, proc_close, proc_get_status, proc_nice, proc_open, proc_terminate, putenv, sem_acquire, sem_get, shell_exec, shm_attach, shm_get_var, shm_put_var, shm_remove, shmop_close, shmop_delete, shmop_open, shmop_write, show_source, symlink, syslog, system, xmlrpc_entity_decode" ; disable_classes = Reflection, ReflectionClass, ReflectionExtension, ReflectionFunction, ReflectionFunctionAbstract, ReflectionMethod, ReflectionObject, ReflectionParameter, ReflectionProperty, Reflector expose_php = Off max_execution_time = 18000 always_populate_raw_post_data = -1 max_input_time = -1 memory_limit = 1800M realpath_cache_size = 640k realpath_cache_ttl = 86400 error_reporting = E_ALL & ~E_NOTICE display_errors = On display_startup_errors = Off log_errors = On log_errors_max_len = 1024 ignore_repeated_errors = Off ignore_repeated_source = Off ignore_user_abort = on report_memleaks = On track_errors = Off html_errors = On error_log = "d:/sv/log/php_error.log" mail.log = "d:/sv/log/php_mail.log" curl.cainfo="d:/sv/data/cacert.pem" openssl.cafile="d:/sv/data/cacert.pem" sendmail_from = "[email protected]" ;sendmail_path = '"d:/sv/bin/msmtp/msmtp.exe" -C "d:/sv/conf/msmtp.ini" -t' sendmail_path = '"d:/sv/bin/php" -n -f "d:/sv/include/tools/mailtodisk.php" --' max_input_nesting_level = 128 max_input_vars = 2000 mysqlnd.net_cmd_buffer_size = 16384 variables_order = "GPCS" register_globals = Off register_long_arrays = Off register_argc_argv = Off auto_globals_jit = On post_max_size = 1800M magic_quotes_gpc = Off magic_quotes_runtime = Off magic_quotes_sybase = Off auto_prepend_file = auto_append_file = default_mimetype = "text/html" doc_root = user_dir = cgi.fix_pathinfo = 0 file_uploads = On upload_tmp_dir = "d:/sv/tmp" upload_max_filesize = 1800M max_file_uploads = 20 allow_url_fopen = On allow_url_include = Off default_socket_timeout = 60 extension_dir = "ext" enable_dl = Off date.timezone = UTC define_syslog_variables = Off sql.safe_mode = Off mysql.allow_persistent = On mysql.max_persistent = -1 mysql.max_links = -1 mysql.default_port = 3306 mysql.default_host = "localhost" mysql.default_user = "root" mysql.default_password = mysql.connect_timeout = 60 mysql.trace_mode = Off mysqli.max_links = -1 mysqli.default_port = 3306 mysqli.default_host = "localhost" mysqli.default_user = "root" mysqli.default_pw = mysqli.reconnect = Off bcmath.scale = 0 session.save_handler = files session.save_path = "d:/sv/tmp" session.use_cookies = 1 session.name = PHPSESSID session.auto_start = 0 session.cookie_lifetime = 0 session.cookie_path = / session.cookie_domain = session.cookie_httponly = session.serialize_handler = php session.gc_probability = 15 session.gc_divisor = 100 session.gc_maxlifetime = 7200 session.bug_compat_42 = 0 session.bug_compat_warn = 1 session.referer_check = off session.entropy_length = 0 session.entropy_file = session.cache_limiter = nocache session.cache_expire = 180 session.use_trans_sid = 0 session.hash_function = 0 session.hash_bits_per_character = 5 url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry" tidy.clean_output = Off soap.wsdl_cache_enabled = 1 soap.wsdl_cache_dir = "d:/sv/tmp" soap.wsdl_cache_ttl = 86400 mbstring.internal_encoding = UTF-8 mbstring.detect_order = UTF-8,ISO-8859-15,ISO-8859-1,ASCII ;Extensions extension = php_bz2.dll extension = php_curl.dll extension = php_gd2.dll extension = php_imap.dll extension = php_intl.dll extension = php_mbstring.dll extension = php_exif.dll extension = php_soap.dll extension = php_sockets.dll extension = php_openssl.dll extension = php_fileinfo.dll ;Additional extensions from d:/sv/bin/PHP/php-x.x.x/ext ;extension = php_ftp.dll ;extension = php_gettext.dll ;extension = php_tidy.dll ;extension = php_xmlrpc.dll extension = php_xsl.dll ; Redis Cache / NoSql ; https://github.com/phpredis/phpredis#readme extension = php_redis.dll ; Uncomment to use redis as session storage: ;session.save_handler = redis ;session.save_path = "tcp://localhost:6379?weight=1" ;Database Extensions extension = php_mysqli.dll extension = php_pdo_mysql.dll ;extension = php_odbc.dll ;extension = php_pdo_odbc.dll ;extension = php_pgsql.dll ;extension = php_pdo_pgsql.dll ;extension = php_sqlite3.dll ;extension = php_pdo_sqlite.dll ; GeoIp Database. download and extract Binary databases to WinNMPdata from ; http://dev.maxmind.com/geoip/legacy/geolite/ ;extension = "php_geoip.dll" geoip.custom_directory = "d:/sv/data" ;OPCache ; OPCache PHP Extension: when enabled, only one php-cgi server can be safely started. Starting more PHP-CGI servers might return "Fatal Error Unable to reattach to base address" ;zend_extension = "php_opcache.dll" opcache.memory_consumption=128 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=4000 opcache.revalidate_freq=60 opcache.fast_shutdown=1 opcache.enable_cli=1 ;If you want to use OPcache with » Xdebug, you must load OPcache before Xdebug. ;zend_extension = "php_xdebug.dll" ;XCache works only in PHP 5 !!! ; XCache is Not Available for PHP 7. Due to the limitations of php under windows, (only one process per CGI server, forcing WinNMP Manager to start more php-cgi servers instead of starting one server with more processes), the XCache PHP Extension will use different shared memory buffers for each php-cgi server. This will use more memory and will make XCache Variable Cache inconsistent between php processes. If you intend relay on it, you should use --phpCgiServers=1. XCache Opcode Cache will not be affected, but it will waste memory. ;extension = "php_xcache.dll" xcache.admin.enable_auth = Off xcache.admin.user = "mOo" xcache.admin.pass = "" xcache.shm_scheme = "mmap" xcache.size = 32M xcache.count = 4 xcache.slots = 8K xcache.ttl = 3600 xcache.gc_interval = 600 xcache.var_size = 0 xcache.var_count = 4 xcache.var_slots = 8K xcache.var_ttl = 0 xcache.var_maxttl = 0 xcache.var_gc_interval = 300 xcache.var_namespace_mode = 0 xcache.var_namespace = "" xcache.readonly_protection = Off xcache.cacher = On xcache.stat = Off xcache.optimizer = Off xcache.coverager = Off xcache.coverager_autostart = Off