PHP related configuration, PHP dynamic extension module
The content introduced in this article is about PHP related configuration, PHP dynamic expansion module, which has certain reference value. Now I share it with you. Friends in need can refer to it
PHP related configuration
Check the location of the PHP configuration file
[root@shuai-01 111.com]# /usr/local/php/bin/php -i
Or use the phpinfo function to find it (accessed through a browser) (recommended)
[root@shuai-01 111.com]# vim index.php <?php phpinfo(); ?>
This When you access it with a browser, everything will come out
The directory where the configuration file is located, load the configuration file
If the configuration file is not loaded, go to the source code package configuration file Copy the configuration file here
[root@abc php-5.6.30]# cp /usr/local/src/php-5.6.30/php.ini-development /usr/local/php/etc/php.ini 重新加载配置文件 [root@abc php-5.6.30]# /usr/local/apache2.4/bin/apachectl graceful
There are two configuration files here (one for development and one for production environment)
Modify the PHP configuration file:
vim /usr/local/php/etc/php.ini
Dangerous function: (It also includes phpinfo. phpinfo will display all your information, which is very dangerous)
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
For dangerous functions, we can disable it.
Disable functions:
Search disable_functions
Add disabled functions
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,phpinfo
Test at this time:
Visit 111.com/index.php
PHP dynamic extension module
When there is a business need To use modules that are not installed when PHP is compiled and installed, you can use dynamic expansion to install the required modules.
现在介绍一下redis的安装,redis是一个nosql,在LAMP架构下一般把它当做缓存来使用。
要安装redis模块就要先下载redis这个包
下载地址:
https://codeload.github.com/phpredis/phpredis/zip/develop
[root@shuai-01 src]# wget https://codeload.github.com/phpredis/phpredis/zip/develop
改名为phpredis-develop.zip:
[root@shuai-01 src]# mv develop phpredis-develop.zip
解压这个包:
[root@shuai-01 src]# unzip phpredis-develop.zip
到phpredis-develo目录下进行编译安装:
[root@shuai-01 src]# cd phpredis-develop [root@shuai-01 phpredis-develop]# ls arrays.markdown ISSUE_TEMPLATE.md redis_array_impl.h cluster_library.c liblzf redis.c cluster_library.h library.c redis_cluster.c cluster.markdown library.h redis_cluster.h common.h mkdeb-apache2.sh redis_commands.c config.m4 mkdeb.sh redis_commands.h config.w32 package.xml redis_session.c COPYING php_redis.h redis_session.h crc16.h README.markdown rpm CREDITS redis_array.c serialize.list debian redis_array.h tests debian.control redis_array_impl.c
编译安装是要有configure文件的,这个没有,就要先生成configure文件:
生成configure文件:
[root@shuai-01 phpredis-develop]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226 [root@shuai-01 phpredis-develop]# ls acinclude.m4 crc16.h README.markdown aclocal.m4 CREDITS redis_array.c arrays.markdown debian redis_array.h autom4te.cache debian.control redis_array_impl.c build install-sh redis_array_impl.h cluster_library.c ISSUE_TEMPLATE.md redis.c cluster_library.h liblzf redis_cluster.c cluster.markdown library.c redis_cluster.h common.h library.h redis_commands.c config.guess ltmain.sh redis_commands.h config.h.in Makefile.global redis_session.c config.m4 missing redis_session.h config.sub mkdeb-apache2.sh rpm configure mkdeb.sh run-tests.php configure.in mkinstalldirs serialize.list config.w32 package.xml tests COPYING php_redis.h
编译:
[root@shuai-01 phpredis-develop]# ./configure --with-php-config=/usr/local/php/bin/php-config [root@shuai-01 phpredis-develop]# echo $? 0
make:
[root@shuai-01 phpredis-develop]# make [root@shuai-01 phpredis-develop]# echo $? 0
make install:
[root@shuai-01 phpredis-develop]# make install Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/ [root@shuai-01 phpredis-develop]# echo $? 0
查看有没有生成redis.so文件:
[root@shuai-01 phpredis-develop]# ls /usr/local/php/lib/php/extensions/no-debug-zts-20131226/ opcache.so redis.so
这个时候PHP还是不支持的
[root@shuai-01 phpredis-develop]# /usr/local/php/bin/php -m |grep redis [root@shuai-01 phpredis-develop]#
通过编辑配置文件在PHP中加载redis
先找扩展模块的目录路径:
[root@shuai-01 phpredis-develop]# /usr/local/php/bin/php -i |grep -i extension_dir extension_dir => /usr/local/php/lib/php/extensions/no-debug-zts-20131226 => /usr/local/php/lib/php/extensions/no-debug-zts-20131226 sqlite3.extension_dir => no value => no value
发现在/usr/local/php/lib/php/extensions/no-debug-zts-20131226
这个extension_dir是可以自定义路径的,不过一般不会去定义它,安装的扩展模块会默认放在个目录下
编辑php.ini:
[root@shuai-01 phpredis-develop]# vim /usr/local/php/etc/php.ini
将redis.so文件加入进去
;extension=php_xmlrpc.dll ;extension=php_xsl.dll extension=redis.so
保存退出
这时就加载了:
[root@shuai-01 phpredis-develop]# /usr/local/php/bin/php -m |grep redis redis
问题1:
生成configure文件时出现:
[root@shuai-01 phpredis-develop]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226 Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.
少了autoconf这个包
安装:
[root@shuai-01 phpredis-develop]# yum install -y autoconf
安装完了之后再生成文件。
有些第三方扩展模块是要通过下载源码包来安装,有些模块是PHP源码包中自带的(在ext目录下)。
[root@shuai-01 php-5.6.30]# cd ext/ [root@shuai-01 ext]# ls bcmath ftp mysqli pgsql standard bz2 gd mysqlnd phar sybase_ct calendar gettext oci8 posix sysvmsg com_dotnet gmp odbc pspell sysvsem ctype hash opcache readline sysvshm curl iconv openssl recode tidy date imap pcntl reflection tokenizer dba interbase pcre session wddx dom intl pdo shmop xml enchant json pdo_dblib simplexml xmlreader ereg ldap pdo_firebird skeleton xmlrpc exif libxml pdo_mysql snmp xmlwriter ext_skel mbstring pdo_oci soap xsl ext_skel_win32.php mcrypt pdo_odbc sockets zip fileinfo mssql pdo_pgsql spl zlib filter mysql pdo_sqlite sqlite3
如果想安装里面的模块,直接进入模块目录下,执行phpize进行生成configure文件。
例如我现在要安装zip模块:
进入zip目录:
[root@shuai-01 ext]# cd zip/ [root@shuai-01 zip]# ls config.m4 CREDITS lib php_zip.c tests zip_stream.c config.w32 examples LICENSE_libzip php_zip.h TODO
生成configure文件:
[root@shuai-01 zip]# /usr/local/php/bin/phpize Configuring for: PHP Api Version: 20131106 Zend Module Api No: 20131226 Zend Extension Api No: 220131226
编译安装:
[root@shuai-01 zip]# ./configure --with-php-config=/usr/local/php/bin/php-config [root@shuai-01 zip]# echo $? 0
make:
[root@shuai-01 zip]# make [root@shuai-01 zip]# echo $? 0
make install:
[root@shuai-01 zip]# make install Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
查看有没有生成redis.so文件
[root@shuai-01 zip]# ls /usr/local/php/lib/php/extensions/no-debug-zts-20131226/ opcache.so redis.so zip.so
这个时候PHP还是不支持的
[root@shuai-01 zip]# /usr/local/php/bin/php -m |grep zip [root@shuai-01 zip]#
编辑php.ini:
[root@shuai-01 phpredis-develop]# vim /usr/local/php/etc/php.ini
将zip.so文件加入进去
;extension=php_xsl.dll extension=redis.so extension=zip.so
保存退出
这时就加载了:
[root@shuai-01 zip]# /usr/local/php/bin/php -m |grep zip zip
扩展
apache rewrite教程 http://coffeelet.blog.163.com/blog/static/13515745320115842755199/ http://www.cnblogs.com/top5/archive/2009/08/12/1544098.html
apache rewrite 出现死循环 http://ask.apelearn.com/question/1043
php错误日志级别参考 http://ask.apelearn.com/question/6973
php开启短标签 http://ask.apelearn.com/question/120
php.ini详解 http://legolas.blog.51cto.com/2682485/493917
相关推荐:
The above is the detailed content of PHP related configuration, PHP dynamic extension module. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.
