点击这里从官网下载Netbean,按照官网的指示完成安装。
在netbeans下新建php项目,项目属性里按下图设置:

关键要勾选copy files from sources folder to another location
这个选项使得netbeans的项目文件会被放到localhost的索引下,这样才能从localhost里访问编写的网页了。
同样,在run configuration里要如下设置:

在url里要设置好路径,其中programmer是Ubuntu的用户名,要根据不同情况更改。index.php是网站首页,也是运行php项目首先打开的文件。
这时通常会面临另一个问题:当网页链接到php文件时,浏览器会自动下载php文件而不是打开它。从ubuntu forum上找到了解决方法,问题出在要修改 /etc/apache2/mods-available/php5.conf 文件,如以下代码所示:
- # To re-enable php in user directories comment the following lines
- # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
- # prevents .htaccess files from disabling it.
- # <IfModule mod_userdir.c> #Comment out this line
- # <Directory /home/*/public_html> #comment out this line
- # php_admin_value engine Off #comment out this line
- # </Directory> #comment out this line
- #</IfModule> #comment out this line
这样就能让浏览器从localhost打开而不是下载php文件了。
