First, PHP
After compiling the PHP, the configuration file is empty, We need to copy the PHP configuration file (php.ini) from the Php.ini-development (Development debug template) and Php.ini-production (production run template) in the extracted source package to the PHP configuration directory, with the name changed to PHP.ini
1) disable_functions Configuration
Default is null, revision changed to
Disable_functions = Eval,assert,popen,passthru,escapeshellarg,escapeshellcmd,passthru,exec,system,chroot,scandir , Chgrp,chown,escapeshellcmd,escapeshellarg,shell_exec,proc_get_status,ini_alter,ini_restore,dl,pfsockopen, Openlog,syslog,readlink,symlink,leak,popepassthru,stream_socket_server,popen,proc_open,proc_close
2) error_log Configuration
①error_reporting record information levels
If it is development: set to Error_reporting = E_all | E_strict
If production: set to Error_reporting = E_all & ~e_deprecated
The specific level is set according to the need (note: "~" meaning to exclude)
②display_errors Display Error
"On": To open
"Off": for off (production environment recommendations)
③log_errors logging function
Set to "on"
④error_log Log Save location
Example: Error_log =/usr/local/php/logs/php_errors.log
The name can be customized, the directory will not be created automatically, if there is a directory file, please manually create
Note: Change the main and group of its directory to daemon
3) Open_basedir Set the user-operable file directory (i.e., active range)
Method One: Php config file, find Open_basedir, and remove the comment ";", add the Restricted files directory
Example: Open_basedir =/data/www/:/tmp/
Method Two: In the Apache configuration file, add the restricted files directory to the directory in the master profile
Example: Php_admin_value open_basedir/data/www/:/tmp/
Method Three: In the Apache configuration file, add the restricted files directory to the VirtualHost configuration file
Example: Php_admin_value open_basedir/data/www/:/tmp/
4) Install PHP extensions memcache and memcached
Memcache Document Address Http://pecl.php.net/package/memcache
memcached Document Address http://pecl.php.net/package/memcached
① installation Memcache
1, download the Memcache package, unpack the package, enter the extracted files directory
2. Generate Configuration Tool with Phpize (phpize file directory/usr/local/php/bin/phpize)
Example:
[Email protected] memcache-2.2.7]#/usr/local/php/bin/phpize
Configuring for:
PHP Api version:20090626
Zend Module Api no:20090626
Zend Extension Api no:220090626
3. Configuring compilation parameters
Example:
[Email protected] memcache-2.2.7]#/configure--with-php-config=/usr/local/php/bin/php-config
4. Compiling and Installing: Make & make Install
5, edit php.ini, add memcache.so
Example: Extension = memcache.so
Two. mysql configuration (some common parameters)
Skip-locking: Set this option to avoid external locking of MySQL, reduce system error and increase system stability
Socket =/tmp/mysql.sock
# Specify a socket file for local communication between the MySQL client and server (the default is/var/lib/mysql/mysql.sock file under Linux)
Port = 3306
# Specify the port on which MSSQL listens
Skip-name-resolve
#禁止MySQL对外部连接进行DNS解析, this option can be used to eliminate the time for DNS resolution for MySQL. However, it is important to note that if you turn on this option, all remote host connection authorizations will use IP address, otherwise MySQL will not be able to handle connection requests properly.
Key_buffer = 384M
# Key_buffer is the buffer size used for the index block, increasing the index (for all read and multiple writes) that it can get better processing. The index is shared by all threads, and the size of the key_buffer depends on the size of the memory.
Table_open_cache = 512
# MySQL every time you open a table, it will read some data into the Table_open_cache cache, and when MySQL cannot find the appropriate information in this cache, it will go to the disk to read. The default value of 64, assuming that the system has 200 concurrent connections, you need to set this parameter to 200*n (N for each connection required number of file descriptors), when the Table_open_cache is set to large, if the system can not handle so many file descriptors, then there will be client invalidation, Connection not on.
Max_allowed_packet = 4M
# The size of the packet accepted; It is safe to increase the value of the variable because additional memory is allocated only when needed. For example, MYSQLD will allocate more memory only if you issue a long query or if mysqld must return a large result row. This variable takes a smaller default value as a precaution to capture the error message packets between the client and the server and to ensure that memory overflows are not caused by accidental use of large packets.
Sort_buffer_size = 2M
# MySQL performs sorting using the buffer size. If you want to increase the speed of the order by, first see if you can let MySQL use the index instead of the extra sort stage. If not, you can try increasing the size of the sort_buffer_size variable
Read_buffer_size = 2M
# The buffer size that can be used by the read query operation. As with Sort_buffer_size, the allocated memory for this parameter is exclusive to each connection. A request to sequentially scan a table allocates a read-in buffer, and MySQL allocates a memory buffer for it. If the sequential scan requests for a table are frequent, and you think that frequent scans are going too slowly, you can improve their performance by increasing the value of the variable and the size of the memory buffer.
Join_buffer_size = 2M
# The buffer size that can be used by the union query operation, as with Sort_buffer_size, the allocated memory for this parameter is also per connection exclusive
Query_cache_size = 32M
# Specify the size of the MySQL query result buffer
Read_rnd_buffer_size = 2M
# Random Read buffer size. When rows are read in any order (for example, in sort order), a random read buffer is allocated. When you sort a query, MySQL scans the buffer first to avoid disk searches, improve query speed, and, if you need to sort large amounts of data, raise the value appropriately. However, MySQL will issue this buffer space for each client connection, so you should set this value as appropriate to avoid excessive memory overhead
Myisam_sort_buffer_size =64m
# MyISAM the buffer required to reorder when the table is changed
Thread_concurrency = 8
# The maximum number of concurrent threads, and the value is the number of server logical CPUs x2
Thread_cache = 8
#该值表示可以重新利用保存在缓存中线程的数量, if there is room in the cache when disconnecting, the client's thread will be placed in the cache, and if the thread is requested again, the request will be read from the cache, and if the cache is empty or a new request, then the thread will be recreated. Set the rule to: 1G memory set to 8,2G memory set to 16,4g above set to 64
max_connections = 1000
#MySQL的最大连接数, if the server has a large number of concurrent connection requests, it is recommended that this value be increased to increase the amount of concurrent connections, although this is based on the fact that the machine can support, because if the number of connections between MySQL will provide a connection buffer for each connection, it will cost more memory, Therefore, to adjust the value appropriately, you can not blindly increase the value set. The ' conn% ' wildcard character can be used to view the number of connections in the current state to decide the size of the value.
Max_connect_errors = 6000
# for the same host, if there is an interrupt error connection that exceeds the number of values for this parameter, the host will be blocked from connecting. To unblock the host, execute: FLUSH host.
Open_files_limit = 65535
# MySQL Open file descriptor limit, default minimum 1024
Skip-locking
# avoid MySQL external lock, reduce the chance of error increase stability.
Wait_timeout = 8
# indicates idle connection timeout time, default is 28800s, this parameter is used with Interactive_timeout, that is, for wait_timeout to take effect, must be set interactive_timeout
Interactive_timeout = 8
Long_query_time = 1
#慢查询日志的超时时间
Log_slow_queries =/path/to/slow_queries
# Slow query log path, must be used together with the above parameters
This article is from the "Mylinux" blog, make sure to keep this source http://mylinuxlife.blog.51cto.com/4706737/1649813
Linux Learning Notes-19th lesson-lamp php and MySQL configuration (iii)