Linux 下建立php 开发环境,就像朋友推荐的一样,还是xampp比较快速方便,当然,我是解压在/opt/lampp下的,因为一般情况下都不是以root 用户进入系统,所以如果以/opt/lampp/htdocs为根目录,在权限方面是比较麻烦的,除非用root 运行easyeclipse ,当然是不建议的,所以,www.linuxidc.com我们就需要把我们的开发目录移动到一般用户下,我的是/home/yunqing/workspace/php,方法有两个,如下:
方法一:连接
sudo su
ln -s /home/yunqing/workspace/php /opt/lampp/htdocs
就可以在/opt/lampp/htdocs下看到一个连接php ,在浏览的时候只要点击php就可以浏览/home/yunqing/workspace/php下的内容了,不过这样的缺点是,不方便文件的管理,比如要改变文件的读取写入执行权限时,必须到/home/yunqing/workspace/php下改变文件夹或者是文件的权限,非常不方便,相对而言,第二种方法就可以解决这个问题.
方法二:建立虚拟目录
sudo su
cd /opt/lampp/htdocs
mkdir link (link为虚拟目录名)
cd /opt/etc
vim httpd.conf
添加如下代码
#虚拟目录路径
Alias /link "/home/yunqing/workspace/php"
#虚拟目录设置
<Directory "/home/yunqing/workspace/php">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
#Options Indexes FollowSymLinks
# XAMPP
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
#AllowOverride None
# since XAMPP 1.4:
# AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
可以这样理解,将/home/yunqing/workspace/php文件夹下的内容全部挂到/opt/lampp/htdocs/link目录下,这样就可以通过<Directory> </Directory>非常方便得修改虚拟目录的权限问题.
在这里需要注意的是
1、上面的”mkdir link”与配置文件中的#虚拟目录路径Alias /link "/home/yunqing/workspace/php" 中的link要对应上否则会出错。
2、建设在建立这个连接时用准备给PHP项目起的名字命名,这样在调试时会方便很多。
例如我给项目起了个名称为phpdemo,那我在建立link时也用这个名称,这样你就可以在浏览器中直接查看 http://localhost/phpdemo/你的php文件,这样的好处你用了zend查看页面时就知道了
