Fedora 20 配置php 默认路径问题
大家好。我在fedora 20上安装了默认的php+apache+mysql. 我在更改apache的默认文档路径时遇到了如下问题:1. SELinux安全权限;2. 更改相关文件夹权限问题。我在根据错误日志的提示设置了相关的SELinux权限,并使用chmod, chron更改了相关的权限后,现在的提示是403 forbidden.。请问接下来我该怎么做?
具体说来,我已做完的步骤:
1. 设置SELinux权限:
setsebool -P httpd_read_user_content 1
setsebool -P httpd_enable_homedirs 1
2. 使用chmod, chron更改目录权限(我的目录为~/www/, 页面脚本和页面文件放在~/www/html目录中,已取得root权限):
# chmod 755 ~/www
# chmod 755 ~/www/html
# chron -R -t httpd_sys_content_t ~/www
# chron -R -t httpd_sys_content -t ~/www/html
# cd ~/www/html
# touch index.html
3. 修改httpd.conf文件:
DocumentRoot ".../www/html"
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
保存后并重启apache服务,仍然得到403 forbidden错误。请问接下来我该怎么办?网上的办法都试过了,都没用。我是新手,请赐教,小弟不胜感激。
回复讨论(解决方案)
确定你php环境没问题? $ php -v
确定你php环境没问题? $ php -v
没问题啊。如果我在默认的/var/www/html下创建php文件,是可以运行的。
你现在在www/html/ 下新建 index.php
echo phpinfo();
?>
运行有报错?
至于你说的403,
$ ll .../www/
贴出结果看看
或者
在配置文件中找到下面两句
user deamon
group deamon
因为这两句的存在,使得apache并没有权限去读写当前用户的目录,所以会出现权限问题
把它们改为
user currentUser (其中 currentUser 是当前用户的用户名)
group currentGroup (其中 currentGroup 是当前用户所在的组名 如不知道 可用命令 groups "当前用户名" 来查询)
你现在在www/html/ 下新建 index.php
echo phpinfo();
?>
运行有报错?
至于你说的403,
$ ll .../www/
贴出结果看看
或者
在配置文件中找到下面两句
user deamon
group deamon
因为这两句的存在,使得apache并没有权限去读写当前用户的目录,所以会出现权限问题
把它们改为
user currentUser (其中 currentUser 是当前用户的用户名)
group currentGroup (其中 currentGroup 是当前用户所在的组名 如不知道 可用命令 groups "当前用户名" 来查询)
还是不行。按你的步骤走了一遍,现在的情况是地址栏输入localhost可以显示apache默认测试页面(原来不显示),但输入localhost/index.html或index.php仍然报403 forbidden错误。
现在的文件结构如下:
[root@localhost lanhyde]# ll www
总用量 4
drwxr-xr-x. 2 lanhyde lanhyde 4096 1月 13 14:09 html
[root@localhost lanhyde]# cd www
[root@localhost html]$ ls -Z
-rw-rw-r--. lanhyde lanhyde unconfined_u:object_r:httpd_sys_content_t:s0 index.php
-rw-rw-r--. lanhyde lanhyde unconfined_u:object_r:httpd_sys_content_t:s0 index.php~
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 log.txt
-rwxr-xr-x. root root unconfined_u:object_r:httpd_sys_content_t:s0 mypol.pp
-rwxr-xr-x. root root unconfined_u:object_r:httpd_sys_content_t:s0 mypol.te
[lanhyde@localhost html]$ ll
总用量 16
-rw-rw-r--. 1 lanhyde lanhyde 20 1月 13 14:18 index.php
-rw-rw-r--. 1 lanhyde lanhyde 0 1月 13 14:18 index.php~
-rw-r--r--. 1 root root 1278 1月 13 13:58 log.txt
-rwxr-xr-x. 1 root root 939 1月 13 14:02 mypol.pp
-rwxr-xr-x. 1 root root 219 1月 13 14:02 mypol.te
-rw-rw-r--. 1 lanhyde lanhyde 20 1月 13 14:18 index.php
更改
chmod 755 file or chmod 777 file试试
-rwxr-xr-x 1 root root
-rwxrwxrwx 1 root root
-rw-rw-r--. 1 lanhyde lanhyde 20 1月 13 14:18 index.php
更改
chmod 755 file or chmod 777 file试试
-rwxr-xr-x 1 root root
-rwxrwxrwx 1 root root
试过了,不管用。。。
-rw-rw-r--. 1 lanhyde lanhyde 20 1月 13 14:18 index.php
更改
chmod 755 file or chmod 777 file试试
-rwxr-xr-x 1 root root
-rwxrwxrwx 1 root root
试过了,不管用。。。
贴出你操作之后的效果。
-rw-rw-r--. 1 lanhyde lanhyde 20 1月 13 14:18 index.php
更改
chmod 755 file or chmod 777 file试试
-rwxr-xr-x 1 root root
-rwxrwxrwx 1 root root
试过了,不管用。。。
贴出你操作之后的效果。
抱歉这么久才回复。使用其它网站提供的资料,我已经解决问题了。还是非常谢谢你哈。
贴出我的参考地址为有相同问题的童鞋提供点帮助:http://www.if-not-true-then-false.com/2010/enable-apache-userdir-with-selinux-on-fedora-centos-red-hat-rhel/

Outils d'IA chauds

Undresser.AI Undress
Application basée sur l'IA pour créer des photos de nu réalistes

AI Clothes Remover
Outil d'IA en ligne pour supprimer les vêtements des photos.

Undress AI Tool
Images de déshabillage gratuites

Clothoff.io
Dissolvant de vêtements AI

AI Hentai Generator
Générez AI Hentai gratuitement.

Article chaud

Outils chauds

Bloc-notes++7.3.1
Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise
Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1
Puissant environnement de développement intégré PHP

Dreamweaver CS6
Outils de développement Web visuel

SublimeText3 version Mac
Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Laravel simplifie la gestion des données de session temporaires à l'aide de ses méthodes de flash intuitives. Ceci est parfait pour afficher de brefs messages, alertes ou notifications dans votre application. Les données ne persistent que pour la demande ultérieure par défaut: $ demande-

L'extension PHP Client URL (CURL) est un outil puissant pour les développeurs, permettant une interaction transparente avec des serveurs distants et des API REST. En tirant parti de Libcurl, une bibliothèque de transfert de fichiers multi-protocol très respectée, PHP Curl facilite Efficient Execu

Laravel fournit une syntaxe de simulation de réponse HTTP concise, simplifiant les tests d'interaction HTTP. Cette approche réduit considérablement la redondance du code tout en rendant votre simulation de test plus intuitive. L'implémentation de base fournit une variété de raccourcis de type de réponse: Utiliser illuminate \ support \ faades \ http; Http :: faux ([[ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Alipay Php ...

Voulez-vous fournir des solutions instantanées en temps réel aux problèmes les plus pressants de vos clients? Le chat en direct vous permet d'avoir des conversations en temps réel avec les clients et de résoudre leurs problèmes instantanément. Il vous permet de fournir un service plus rapide à votre personnalité

L'article traite de la liaison statique tardive (LSB) dans PHP, introduite dans PHP 5.3, permettant une résolution d'exécution de la méthode statique nécessite un héritage plus flexible. Problème main: LSB vs polymorphisme traditionnel; Applications pratiques de LSB et perfo potentiel

L'article examine l'ajout de fonctionnalités personnalisées aux cadres, en se concentrant sur la compréhension de l'architecture, l'identification des points d'extension et les meilleures pratiques pour l'intégration et le débogage.

L'article traite des fonctionnalités de sécurité essentielles dans les cadres pour se protéger contre les vulnérabilités, notamment la validation des entrées, l'authentification et les mises à jour régulières.
