解决apache (php)开发中root权限目录文件不能编辑的两个方法
来源:互联网 发布:cc2530中文数据手册 编辑:程序博客网 时间:2024/05/18 02:26
解决apache (php)开发中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$
方法一. 更改/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)开发中root权限目录文件不能编辑的两个方法
- apache禁止访问文件或目录执行权限、禁止运行脚本PHP文件的设置方法
- apache禁止访问文件或目录执行权限、禁止运行脚本PHP文件的设置方法
- Tomcat中PHP运行需要root权限的shell文件
- apache环境下禁止某文件夹内运行PHP脚本、禁止访问文件或目录执行权限的设置方法
- apache环境下禁止某文件夹内运行PHP脚本、禁止访问文件或目录执行权限的设置方法
- DDMS 中访问需要root权限文件的方法
- WinXP的IIS中解决FileSystemObject不能写入已有文件或删除文件提示没有权限的问题时学到的两个知识点
- root权限对SYSTEM目录拷贝文件,adb通过wifi连接android设备的方法
- apache限制某个目录下的php文件没有执行权限
- Ubuntu中获取ROOT权限的方法
- Apache 目录权限设置方法
- apache root权限的获取
- 解决IAR中H文件不能打开的方法
- 解决IAR中H文件不能打开的方法
- 解决root权限下可以使用ndk-build命令,非root下不能使用的问题
- apache 设置目录没有执行php的权限
- 禁止Apache对于某一个Web目录的PHP解析权限
- Python Windows error code
- ARM——操作系统—最小操作系统-开发板测试
- ASP.NET Repeater嵌套Repeater实现菜单加载
- Win7 SP1语言包微软官方下载地址及使用方法
- exists 和 with
- 解决apache (php)开发中root权限目录文件不能编辑的两个方法
- 层次查询
- oracle创建触发器的脚本在sqlplus中执行不了问题的解决
- 100行代码实现最简单的基于FFMPEG+SDL的视频播放器
- ${pageContext.request.contextPath} JSP取得绝对路径
- 支付宝代志远:HBase系统故障恢复的优化实践分享
- matlab2013 安装 存储空间不足 解决方案
- 系统性能调优
- mongodb在java驱动包下的操作(转)