linux - 安装好php为什么要复制一份php.ini 到/usr/local/php/lib/php.ini
安装好php为什么要复制一份php.ini 到/usr/local/php/lib/php.ini
我试过了 如果不复制一份 php也能正常运行 为什么要从安装包里复制一份php.ini 到 /usr/local/php/lib/php.ini 目录下呢
回复内容:
安装好php为什么要复制一份php.ini 到/usr/local/php/lib/php.ini
我试过了 如果不复制一份 php也能正常运行 为什么要从安装包里复制一份php.ini 到 /usr/local/php/lib/php.ini 目录下呢
目前排名第一的 @TonyX 说的没错,给出了可以解决所有疑问的通用方法。但是对于这个问题并没有直接给出答案,如果我是题主,我是不想要这样的答案的。
回到楼主问题,为什么要拷贝到那个目录,那时因为 PHP 编译时指定了配置文件目录,而指定的目录是 /usr/local/php/lib 因此 PHP 启动时会去那个目录下读取 php.ini 的配置文件,不拷贝不影响 PHP 正常运行,只不过无法添加配置项罢了。要查看当前 PHP 会去哪个目录下找配置文件,可以在 phpinfo() 中看到,(命令行下运行 php -i 也可以),看到 'Configuration File (php.ini) Path' 和 'Scan this dir for additional .ini files' 两项,这里面记录了 PHP 加载 .ini 配置文件的路径。
建议题主下载一份 PHP 的 source code 自己尝试着去编译运行一遍。
纸上得来终觉浅,绝知此事要躬行。
——《冬夜读书示子聿》
这一点题主已经做到了。
以讹传讹。
——《吕氏春秋》
尽信书,则不如无书。
——《孟子.尽心下》
题主要明白网上的信息大多数是垃圾,要学会筛选信息,要有自己的判断力,实践出真知。
。。。不需要复杂一份到那个目录啊,
复制到你编译安装时configure指定的php.ini配置文件目录里面。。
一般是/usr/local/php/etc这个目录。
你没复制也能运行时正常的, 你看下phpinfo里面加载的是哪个php.ini.
/usr/local/php/lib/php.ini 里面有一些你在编译时进行配置的项目,如果你没有进行配置那么这里的文件和PHP默认启动时候的相关配置项是一样的,你也就没有必要进行复制。
只要php 在运行时能找 phpini 你放在那里都可以
编译时php时,如果没有指定--with-config-file-path, 默认就是上述目录:
--with-config-file-path=PATH
Set the path in which to look for php.ini [PREFIX/lib]
所以,需要复制到lib目录中。
php运行时,可以没有php.ini, 这时将使用默认参数值。
shell键入 php --ini
查看PHP加载的配置。
没有php.ini文件,php会加载默认的配置,所以不会出错。
而指定了php.ini文件,是为了让你更灵活的配置php,非必需
拷贝到得位置是安装php时候的参数--with-config-file-path的位置,指定这个文件主要是为了灵活配置

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 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 and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

To install Laravel, follow these steps in sequence: Install Composer (for macOS/Linux and Windows) Install Laravel Installer Create a new project Start Service Access Application (URL: http://127.0.0.1:8000) Set up the database connection (if required)
