search

找到php配置文件,查看配置文件路径命令:/usr/local/php/bin/php -i |head

1. 配置disable_function

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

使用命令可以查看禁止的函数:/usr/local/php/bin/php -i |grep disable_f

出现一个警告,这里我们配置一下时区即可:date.timezone='Asia/Chongqing'


2. 配置error_log

打开php.ini,找到如下选项进行配置

display_errors=off

log_errors=on

error_log=/path/to/logfile

error_reporting = E_ALL & ~E_NOTICE

   

错误级别参考

; E_ALL             所有错误和警告(除E_STRICT外)
; E_ERROR           致命的错误。脚本的执行被暂停。
; E_RECOVERABLE_ERROR    大多数的致命错误。
; E_WARNING         非致命的运行时错误,只是警告,脚本的执行不会停止。
; E_PARSE            编译时解析错误,解析错误应该只由分析器生成。
; E_NOTICE          脚本运行时产生的提醒(往往是我们写的脚本里面的一些bug,比如某个变量没有定义),这个错误不会导致任务中断。
; E_STRICT          脚本运行时产生的提醒信息,会包含一些php抛出的让我们要如何修改的建议信息。
; E_CORE_ERROR      在php启动后发生的致命性错误
; E_CORE_WARNING    在php启动后发生的非致命性错误,也就是警告信息
; E_COMPILE_ERROR    php编译时产生的致命性错误
; E_COMPILE_WARNING  php编译时产生的警告信息
; E_USER_ERROR       用户生成的错误
; E_USER_WARNING    用户生成的警告
; E_USER_NOTICE      用户生成的提醒



3. 配置open_basedir

全局配置:php.ini: open_basedir = /dir1/:/dir2

针对虚拟机配置:httpd-vhost.conf: php_admin_value open_basedir "/dir1/:/dir2/"


4. 安装php的扩展模块(memcache)

memcache在php中编译
#  wget http://www.lishiming.net/data/attachment/forum/memcache-2.2.3.tgz
# tar zxvf memcache-2.2.3.tgz
# cd memcache-2.2.3
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make
# make install
# cp modules/memcache.so /usr/local/php/ext/   //把memcache.so 拷贝至php的extension_dir下,#查看php extension_dir的方法是  /usr/local/php/bin/php -i |grep extension_dir 
修改扩展路径,在php.ini中修改:
extension_dir = "/usr/local/php/ext"
然后在php.ini 中添加
extension = memcache.so

保存后可以利用 /usr/local/php/bin/php -m  检测和查看具体的参数


memcached 的编译安装
wget http://syslab.comsenz.com/downloads/linux/memcached-1.4.5.tar.gz

tar zxvf memcached-1.2.8.tar.gz
cd  memcached-1.2.8
./configure --prefix=/usr/local/memcached
make && make install

启动:

/usr/local/memcached/bin/memcached -m 2048 -p 11211 -l 127.0.0.1 -d -u www
-m  后边指定memecached使用多少内存,单位是M
-p  指定memcached 启动端口
-l  指定绑定的IP
-u  指定以某个账户的身份启动


。。。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Email: Step-by-Step Sending GuidePHP Email: Step-by-Step Sending GuideMay 09, 2025 am 12:14 AM

PHPisusedforsendingemailsduetoitsintegrationwithservermailservicesandexternalSMTPproviders,automatingnotificationsandmarketingcampaigns.1)SetupyourPHPenvironmentwithawebserverandPHP,ensuringthemailfunctionisenabled.2)UseabasicscriptwithPHP'smailfunct

How to Send Email via PHP: Examples & CodeHow to Send Email via PHP: Examples & CodeMay 09, 2025 am 12:13 AM

The best way to send emails is to use the PHPMailer library. 1) Using the mail() function is simple but unreliable, which may cause emails to enter spam or cannot be delivered. 2) PHPMailer provides better control and reliability, and supports HTML mail, attachments and SMTP authentication. 3) Make sure SMTP settings are configured correctly and encryption (such as STARTTLS or SSL/TLS) is used to enhance security. 4) For large amounts of emails, consider using a mail queue system to optimize performance.

Advanced PHP Email: Custom Headers & FeaturesAdvanced PHP Email: Custom Headers & FeaturesMay 09, 2025 am 12:13 AM

CustomheadersandadvancedfeaturesinPHPemailenhancefunctionalityandreliability.1)Customheadersaddmetadatafortrackingandcategorization.2)HTMLemailsallowformattingandinteractivity.3)AttachmentscanbesentusinglibrarieslikePHPMailer.4)SMTPauthenticationimpr

Guide to Sending Emails with PHP & SMTPGuide to Sending Emails with PHP & SMTPMay 09, 2025 am 12:06 AM

Sending mail using PHP and SMTP can be achieved through the PHPMailer library. 1) Install and configure PHPMailer, 2) Set SMTP server details, 3) Define the email content, 4) Send emails and handle errors. Use this method to ensure the reliability and security of emails.

What is the best way to send an email using PHP?What is the best way to send an email using PHP?May 08, 2025 am 12:21 AM

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

Best Practices for Dependency Injection in PHPBest Practices for Dependency Injection in PHPMay 08, 2025 am 12:21 AM

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHP performance tuning tips and tricksPHP performance tuning tips and tricksMay 08, 2025 am 12:20 AM

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

PHP Email Security: Best Practices for Sending EmailsPHP Email Security: Best Practices for Sending EmailsMay 08, 2025 am 12:16 AM

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools