您好,UncleToo欢迎您!  为了更好的浏览本站,请使用高版本浏览器
RSS  Tag     设为首页 | 加入收藏
 您所在的位置:首页 > PHP技术 > PHP应用

解决apache开发中root权限目录文件不能编辑的两个方法

作者:  来源:互联网  日期:2013-11-14 16:10:50
收藏  评论:( 0 )  阅读:514

解决apache开发中root权限目录文件不能编辑的两个方法:

方法一. 更改/var/www$ Owner 即可时用当前用户编辑(但是文件目录还是在原来的目录)
hulk@hulk-Lenovo:/var/www$ sudo chown -R hulk:hulk ./
hulk@hulk-Lenovo:/var/www$ cd /etc/apache2/sites-
sites-available/ sites-enabled/  


方法二. 更改/var/www$ 为用户自己的目录,可在自己的home下的目录中新建dir.
具体办法:
1. 再自己的home中新建文件夹:mkdir /home/hulk/htdocs
2. 修改文件/etc/apache2/sites-enabled/000-default
<VirtualHost *:80>
ServerAdmin webmaster@localhost


       #原来是/var/www/,  改成:
DocumentRoot /home/hulk/htdocs
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>


       #原来是/var/www/,  改成:
<Directory /home/hulk/htdocs/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>


ErrorLog ${APACHE_LOG_DIR}/error.log


# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn


CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


保存退出,可以用vim来编辑.


3. 重启apache服务器:
sudo /etc/init.d/apache2 restart
* Restarting web server apache2  apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
                                                                        [ OK ]
完成,大家可以再自己的目录下编辑文件index.php,还是访问之前的localhost地址: http://127.0.0.1/index.php (可以是其他任意php文件)


hulk@hulk-Lenovo:/var/www$ cd /etc/apache2/sites-enabled/
hulk@hulk-Lenovo:/etc/apache2/sites-enabled$ ls
000-default
hulk@hulk-Lenovo:/etc/apache2/sites-enabled$ sudo vim 000-default
hulk@hulk-Lenovo:/etc/apache2/sites-enabled$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2                                                Warning: DocumentRoot [/home/hulk/htdocs] does not exist
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting Warning: DocumentRoot [/home/hulk/htdocs] does not exist
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
                                                                        [ OK ]
hulk@hulk-Lenovo:/etc/apache2/sites-enabled$ mkdir /home/hulk/htdocs
hulk@hulk-Lenovo:/etc/apache2/sites-enabled$
hulk@hulk-Lenovo:/etc/apache2/sites-enabled$
hulk@hulk-Lenovo:/etc/apache2/sites-enabled$
hulk@hulk-Lenovo:/etc/apache2/sites-enabled$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2                                                apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
                                                                        [ OK ]
hulk@hulk-Lenovo:/etc/apache2/sites-enabled$ vim /home/hulk/htdocs/index.php
hulk@hulk-Lenovo:/etc/apache2/sites-enabled$ vim /home/hulk/htdocs/index.php
hulk@hulk-Lenovo:/etc/apache2/sites-enabled$



apache
 
php
 
除非特别声明,本站所有PHP教程及其他教程/文章均为原创、翻译或网友投稿,版权均归UncleToo中文网所有, 转载请注明作者及出处。
原文网址:http://www.uncletoo.com/html/application/636.html
读完这篇文章后,你是否有所收获? 分享是一种生活的信念!
  • 0
  • 0
我来说两句
更多>>网友评论