我想要在自己的Linux系统下安装一些开源的php应用,譬如phpFreeChat,我把它放在/var/www/html/freechat底下,然后对freechat下的data文件夹中的public和private文件夹使用了chmod 777
命令,然后使用ls -al data
命令可以看到这样的结果:
drwxr-xr-x. 4 root root 4096 Jun 17 15:07 .
drwxr-xr-x. 13 root root 4096 Jun 17 15:22 ..
drwxrwxrwx. 2 root root 4096 Jun 17 15:07 private
drwxrwxrwx. 3 root root 4096 Jun 17 15:07 public
但是在浏览器里输入http://localhost/freechat 却会得到这样的错误:
phpFreeChat cannot be initialized, please correct these errors:
/var/www/html/freechat/src/../data/private is not writeable
/var/www/html/freechat/src/../data/private/cache can't be created
/var/www/html/freechat/src/../data/private/cache is not writeable
/var/www/html/freechat/src/../data/private/cache is not readable
cannot create /var/www/html/freechat/src/../data/public/themes/default
cannot create /var/www/html/freechat/src/../data/public/themes/default
/var/www/html/freechat/src/../data/private/chat can't be created
/var/www/html/freechat/src/../data/private/chat is not writeable
/var/www/html/freechat/src/../data/private/chat is not readable
/var/www/html/freechat/src/../data/private/chat/s_d0ba868e1391b6c0d897996049a68ada can't be created
/var/www/html/freechat/src/../data/private/chat/s_d0ba868e1391b6c0d897996049a68ada is not writeable
/var/www/html/freechat/src/../data/private/chat/s_d0ba868e1391b6c0d897996049a68ada is not readable
还尝试过用递归的chmod命令,错误依旧。
利用代码
<?php echo exec('whoami'); ?>
发现用户名是apache,然后在/etc/httpd/conf/httpd.conf里发现User和Group都是apache。请问之所以显示文件不可写是因为这个用户的设置问题吗?如果是的话我该怎么修改?如果不是的话又是什么问题导致的呢?
回复内容:
我想要在自己的Linux系统下安装一些开源的php应用,譬如phpFreeChat,我把它放在/var/www/html/freechat底下,然后对freechat下的data文件夹中的public和private文件夹使用了chmod 777
命令,然后使用ls -al data
命令可以看到这样的结果:
drwxr-xr-x. 4 root root 4096 Jun 17 15:07 .
drwxr-xr-x. 13 root root 4096 Jun 17 15:22 ..
drwxrwxrwx. 2 root root 4096 Jun 17 15:07 private
drwxrwxrwx. 3 root root 4096 Jun 17 15:07 public
但是在浏览器里输入http://localhost/freechat 却会得到这样的错误:
phpFreeChat cannot be initialized, please correct these errors:
/var/www/html/freechat/src/../data/private is not writeable
/var/www/html/freechat/src/../data/private/cache can't be created
/var/www/html/freechat/src/../data/private/cache is not writeable
/var/www/html/freechat/src/../data/private/cache is not readable
cannot create /var/www/html/freechat/src/../data/public/themes/default
cannot create /var/www/html/freechat/src/../data/public/themes/default
/var/www/html/freechat/src/../data/private/chat can't be created
/var/www/html/freechat/src/../data/private/chat is not writeable
/var/www/html/freechat/src/../data/private/chat is not readable
/var/www/html/freechat/src/../data/private/chat/s_d0ba868e1391b6c0d897996049a68ada can't be created
/var/www/html/freechat/src/../data/private/chat/s_d0ba868e1391b6c0d897996049a68ada is not writeable
/var/www/html/freechat/src/../data/private/chat/s_d0ba868e1391b6c0d897996049a68ada is not readable
还尝试过用递归的chmod命令,错误依旧。
利用代码
<?php echo exec('whoami'); ?>
发现用户名是apache,然后在/etc/httpd/conf/httpd.conf里发现User和Group都是apache。请问之所以显示文件不可写是因为这个用户的设置问题吗?如果是的话我该怎么修改?如果不是的话又是什么问题导致的呢?
问题解决了,竟然是SELinux从中作梗。使用setenforce 0
以后便成功了。
应该是这个原因,你用chown -rf apache.apache /var/www/html/freechat/data/
试试
chmod 777 -R /var/www/html/freechat/data
递归修改权限
或者向 @joyqi 说的把目录owner改成apache
chown -R apache:apache /var/www/html/freechat
Rpm系一定要记得setenforce 0,暂时关闭selinux后再测试

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl


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

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

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

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
