关于Appserv8.6.0安装及PHP7配置说明(版本号7.1.1)
一、基本安装:
1、安装appserv8.6.0到D:Appserv
2、用SET PASSWORD命令重置root用户密码
MySQL -u root mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');
二、关于PHP程序调整
(1)return htmlspecialchars($str,ENT_COMPAT,'ISO-8859-1');
(2)防止PHPEXCEL插件报出以下错误:
'break' not in the 'loop' or 'switch' context
将文件(PHPExcelCalculationFunctions.php)的576行的'break'删除即可!
网上有人说是高版本的php7.0才有的,因为:
As break is after return statement, so it giving fatal error.
因为break在return之后,报了个语法错误!确实不对!
(3)number_format()函数支持一个、两个或四个参数(不是三个)。
三、PHP.INI(D:appservphp7php.ini)设置
(1)设置 default_charset =’GBK’
(2)session.save_path=”D:session”
(3)short_open_tag = on 开启短标签
(4)error_reporting,修改为error_reporting = E_ALL & ~E_NOTICE
(5)全局变量关闭:register_globals = Off,正式运行网站请关闭此选项。
(6)设置magic_quotes_gpc = On 开启gpc功能
(7)extension=php_mbstring.dll PHP的扩展设置mbstring,没有mbstring扩展的phpMyAdmin不能正确识别字符串,可能产生不可意料的结果
(8)extension=php_openssl.dll 开启此项,方可使用file_get_contents访问https
(9)session.save_path一定要设置到一个可以读写的路径,如 D:/session
(10)PHP上传文件设置:(通过echo ini_get('post_max_size') 判断当前值)
(11)PHP没有开启文件上传功能,配置应该为 file_uploads = On
(12)PHP配置上传大小限制,upload_max_filesize = 20M
(13)PHP配置的POST方式大小限制,post_max_size = 80M
(14)启用always_populate_raw_post_data=-1 (PHP 5.6.26使用)
四、httpd.conf文件设置
(1)修改默认首页:DirectoryIndex index.html加上index.php
(2)限制目录列表显示:Options Indexes FollowSymLinks 删除Indexes
(3)启用rewrite和.htaccess
第一步,httpd.conf 文件里 查找“<Directory />”把里面的 AllowOverride None 改成 AllowOverride all 即可,改完后的代码如下:
<Directory /> Options FollowSymLinks AllowOverride all Order deny,allow allow from all </Directory>
第二步,查找到“LoadModule rewrite_module”,将前面的"#"号删除即可;如果没有查找到,则到“LoadModule”区域,在最后一行加入“LoadModule rewrite_module modules/mod_rewrite.so”(独占一行)。
(4)开启模块:(仅在需监控服务器性能时开启)
LoadModule status_module modules/mod_status.so LoadModule info_module modules/mod_info.so
启用关联引用文件:
(A)、Include conf/extra/httpd-mpm.conf(重要,服务器并发数)
<IfModule mpm_winnt_module> ThreadsPerChild 1024 #可能会受限制 1920 MaxRequestsPerChild 0 </IfModule>
(B)、Include conf/extra/httpd-default.conf(重要)
Timeout 20 //该参数为连接超时,缺省的300秒显然太大,缩小该参数就会减少同时连接数,即用户实际占用的线程数,这样就可以起到配合上面ThreadsPerChlid参数的作用。 KeepAlive On //该参数为是否保持活连接,目前网站中一个页面一般会包含多个文件,所以相应用户访问时会有多个请求,因此开启可以提高服务器性能。 MaxKeepAliveRequests 50 //该参数为最大的活连接请求数,可以根据网页实际包含的文件数目自行调节。 KeepAliveTimeout 5 //该参数为活连接的超时时间,一般只要设置成小于Timeout即可。
(C)Include conf/extra/httpd-info.conf(仅在需监控服务器性能时开启)
<location /server-status> SetHandler server-status Order Deny,Allow Deny from all Allow from 10.64.1.200 </location> ExtendedStatus On
配置完成,重新启动apache(注意,不能直接restart,而要先stop,再start)
可以用http://127.0.0.1/server-status?refresh=N将表示访问状态页面可以每N秒自动刷新一次;(http:// 127.0.0.1/server-info)
Deny from表示禁止的访问地址;
Allow from表示允许的地址访问;
ExtendedStatus On 表示的是待会访问的时候能看到详细的请求信息,另外该设置仅能用于全局设置,不能在特定的虚拟主机中打开或关闭。启用扩展状态信息将会导致服务器运行效率降低。
五、mysql配置(my.ini)文件设置
(1)max_connections=10000 //可能会受限1910
(2)table_cache=512 //可能会受限 69(Appserv受限,phpstudy不限)
(3)查看状态:
mysql> show variables like '%max_connections%'; mysql> show variables like '%table_cache%'; mysql> show global status like 'open%tables%'; //(5.1.3之后这个值叫做table_open_cache)Open_tables:表示当前正在打开的表数目。 //清空缓存:mysql > flush tables;
六、开启OpCache的PHP文件缓存
[opcache] zend_extension=php_opcache.dll ; Determines if Zend OPCache is enabled opcache.enable=1 ; Determines if Zend OPCache is enabled for the CLI version of PHP opcache.enable_cli=1 ; The OPcache shared memory storage size. opcache.memory_consumption=512 ; The amount of memory for interned strings in Mbytes. opcache.interned_strings_buffer=8 ; The maximum number of keys (scripts) in the OPcache hash table. ; Only numbers between 200 and 100000 are allowed. opcache.max_accelerated_files=10000 ; The maximum percentage of "wasted" memory until a restart is scheduled. opcache.max_wasted_percentage=5 ; When this directive is enabled, the OPcache appends the current working ; directory to the script key, thus eliminating possible collisions between ; files with the same name (basename). Disabling the directive improves ; performance, but may break existing applications. opcache.use_cwd=1 ; When disabled, you must reset the OPcache manually or restart the ; webserver for changes to the filesystem to take effect. opcache.validate_timestamps=1 ; How often (in seconds) to check file timestamps for changes to the shared ; memory storage allocation. ("1" means validate once per second, but only ; once per request. "0" means always validate) opcache.revalidate_freq=2 ; Enables or disables file search in include_path optimization ;opcache.revalidate_path=0 ; If disabled, all PHPDoc comments are dropped from the code to reduce the ; size of the optimized code. ;opcache.save_comments=0 ; If enabled, a fast shutdown sequence is used for the accelerated code opcache.fast_shutdown=1 ; Allow file existence override (file_exists, etc.) performance feature. ;opcache.enable_file_override=0 ; A bitmask, where each bit enables or disables the appropriate OPcache ; passes ;opcache.optimization_level=0xffffffff ;opcache.inherited_hack=1 ;opcache.dups_fix=0 ; The location of the OPcache blacklist file (wildcards allowed). ; Each OPcache blacklist file is a text file that holds the names of files ; that should not be accelerated. The file format is to add each filename ; to a new line. The filename may be a full path or just a file prefix ; (i.e., /var/www/x blacklists all the files and directories in /var/www ; that start with 'x'). Line starting with a ; are ignored (comments). ;opcache.blacklist_filename= ; Allows exclusion of large files from being cached. By default all files ; are cached. ;opcache.max_file_size=0
利用工具插件查看:
opcache-status-master性能状态查看插件.rar
文件下载后,安装到任意目录即可。
七、利用ab工具测试apache压力
ab -c800 -n10000 / -t5 http://192.168.1.1 -c 并发连接数 -n 总连接数 -t 完成时间,单位秒
八、利用mysqldump备份数据库
1.在任意目录下建立文件 D:/abc/mysqldump-user.ini,内容格式如下: [mysqldump] user=root password=abcd6788 2.新建BAT文件,内容如下: set "Y=%date:~,4%" set "m=%date:~5,2%" set "d=%date:~8,2%" md "D:/mysql_bak\%Y%\%m%" "D:/AppServ/MySQL/bin/mysqldump.exe" --defaults-file="D:/abc/mysqldump-user.ini" -uroot data_exam_2018 > D:/mysql_bak\%Y%\%m%data_exam_2018_%Y%%m%%d%.sql 以上内容请注意反斜杠,因虚拟主机防护原因部门反斜杠无法输入
- ● 自制(IP或域名)可信任的SSL证书,适用360、chrome等浏览器
- ● 绿联UGREENKVM切换器(分屏器)快捷键丢失解决办法
- ● 统信UOS开机指定网址全屏启动自带浏览器以及屏蔽ALT+F4关闭
- ● xshellSSH连接Linux服务器防止超时退出
- ● php8开启OpenSSL扩展库报错disabledinstallext
- ● 统信系统linux安装php时的报错libxml-2.0>=2.7.6
- ● tidb关闭sql_mode=ONLY_FULL_GROUP_BY模式
- ● windows10如何开机自动运行bat文件
- ● Win10Mysql8初始密码丢失,初始化又不显示密码
- ● UOS系统关闭防火墙或者放行tcp80端口
- ● PHP批量对TCP服务端指定多个IP非阻塞检查在线状态
- ● python实现TCP服务端持续接收关机、重启指令并输出结果【系列三】
- ● PHP给TCP服务端发送指令【系列二】
- ● PHP判断TCP服务端是否在线【系列一】
- ● PHP判断远程文件是否存在
- ● LINUX下用PHP获取CPU型号、内存占用、硬盘占用等信息代码
- ● PHP代码用UDP方式远程唤醒电脑让计算机开机
- ● apache下php生成验证码图片不能显示
- ● PHP使用AES加密解密示例(无偏移)
- ● Pluginmysql_native_passwordreported:''mysql_native_password'isdeprecate问题