个人工具

“UbuntuHelp:PHPEclipse”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第4行: 第4行:
 
See : [[UbuntuHelp:EclipseIDE]]
 
See : [[UbuntuHelp:EclipseIDE]]
 
== Notice ==
 
== Notice ==
This installation guide will install PHPEclipse into an Eclipse installation in your home directory or in the /opt directory (depending of your EclipseIDE installation method)
+
This installation guide will install [[UbuntuHelp:PHPEclipse|PHPEclipse]] into an Eclipse installation in your home directory or in the /opt directory (depending of your [[UbuntuHelp:EclipseIDE|EclipseIDE]] installation method)
PHPEclipse is able to controll MySQL as well as Apache, and using dbg as a debugger. See below for instructions on controlling Apache using PHPEclipse.
+
[[UbuntuHelp:PHPEclipse|PHPEclipse]] is able to controll MySQL as well as Apache, and using dbg as a debugger. See below for instructions on controlling Apache using [[UbuntuHelp:PHPEclipse|PHPEclipse]].
 
== Automated Installation ==
 
== Automated Installation ==
An automated installation of PHPEclipse is available via the Eclipse Update Manager.
+
An automated installation of [[UbuntuHelp:PHPEclipse|PHPEclipse]] is available via the Eclipse Update Manager.
 
0. Start Eclipse as root, ''$sudo eclipse'' or ''$sudo -s'' then ''#eclipse''
 
0. Start Eclipse as root, ''$sudo eclipse'' or ''$sudo -s'' then ''#eclipse''
 
# Click on Help->Software Updates->Find/Install from file menu in Eclipse.
 
# Click on Help->Software Updates->Find/Install from file menu in Eclipse.
第26行: 第26行:
 
== Installation ==
 
== Installation ==
 
This document assumes you have a running Eclipse installed as described in [[UbuntuHelp:EclipseIDE]].
 
This document assumes you have a running Eclipse installed as described in [[UbuntuHelp:EclipseIDE]].
PHPEclipse is a plugin to Eclipse and should be placed in the <code><nowiki>$HOME/opt/eclipse/plugins</nowiki></code> directory for the personnal installation or <code><nowiki>/opt/eclipse/plugins</nowiki></code> for the global installation.
+
[[UbuntuHelp:PHPEclipse|PHPEclipse]] is a plugin to Eclipse and should be placed in the <code><nowiki>$HOME/opt/eclipse/plugins</nowiki></code> directory for the personnal installation or <code><nowiki>/opt/eclipse/plugins</nowiki></code> for the global installation.
The PHPEclipse project is located at [http://www.phpeclipse.de/ www.phpeclipse.de] and you will find the zipped plugin files [http://sourceforge.net/project/showfiles.php?group_id=57621&package_id=70009 here].
+
The [[UbuntuHelp:PHPEclipse|PHPEclipse]] project is located at [http://www.phpeclipse.de/ www.phpeclipse.de] and you will find the zipped plugin files [http://sourceforge.net/project/showfiles.php?group_id=57621&package_id=70009 here].
 
* Download the latest release (PHPEclipse1.1.3-2005-01-29 when this document where written) to your favorite download directory. Then change directory to the eclipse directory (personnal installation):
 
* Download the latest release (PHPEclipse1.1.3-2005-01-29 when this document where written) to your favorite download directory. Then change directory to the eclipse directory (personnal installation):
 
<pre><nowiki>
 
<pre><nowiki>
第36行: 第36行:
 
$ cd /opt/eclipse
 
$ cd /opt/eclipse
 
</nowiki></pre>
 
</nowiki></pre>
* Unzip the previously downloaded PHPEclipse plugin (use <code><nowiki>sudo</nowiki></code> if you used the EclipseIDE global installation method):
+
* Unzip the previously downloaded [[UbuntuHelp:PHPEclipse|PHPEclipse]] plugin (use <code><nowiki>sudo</nowiki></code> if you used the [[UbuntuHelp:EclipseIDE|EclipseIDE]] global installation method):
 
<pre><nowiki>
 
<pre><nowiki>
 
$ unzip ~/your_download_dir/PHPEclipse1.1.3-2005-01-29.zip
 
$ unzip ~/your_download_dir/PHPEclipse1.1.3-2005-01-29.zip
第55行: 第55行:
 
<Directory /home/<username>/work/>
 
<Directory /home/<username>/work/>
 
</nowiki></pre>
 
</nowiki></pre>
'''Note:''' the above is just an example of my work environment change the path accordingly.  Also, the <code><nowiki>PHP Browser</nowiki></code> that is part of PHPEclipse by default wants to open '''http://localhost/php/''your_script'''''.
+
'''Note:''' the above is just an example of my work environment change the path accordingly.  Also, the <code><nowiki>PHP Browser</nowiki></code> that is part of [[UbuntuHelp:PHPEclipse|PHPEclipse]] by default wants to open '''http://localhost/php/''your_script'''''.
 
and reload Apache to recognize the new configuration:
 
and reload Apache to recognize the new configuration:
 
<pre><nowiki>
 
<pre><nowiki>
 
/etc/init.d/apache2 reload
 
/etc/init.d/apache2 reload
 
</nowiki></pre>
 
</nowiki></pre>
=== Configure PHPEclipse for Apache ===
+
=== Configure [[UbuntuHelp:PHPEclipse|PHPEclipse]] for Apache ===
Now that we have Apache configured for our development environment we can configure PHPEclipse to control Apache.  First open Eclipse and click on:
+
Now that we have Apache configured for our development environment we can configure [[UbuntuHelp:PHPEclipse|PHPEclipse]] to control Apache.  First open Eclipse and click on:
 
<pre><nowiki>
 
<pre><nowiki>
 
Window > Preferences > PHPeclipse Web Development
 
Window > Preferences > PHPeclipse Web Development
 
</nowiki></pre>
 
</nowiki></pre>
This opens the PHPEclipse options dialog.  
+
This opens the [[UbuntuHelp:PHPEclipse|PHPEclipse]] options dialog.  
 
First click on  <code><nowiki>PHP External Tools</nowiki></code> there's two things to change <code><nowiki>Run PHP command</nowiki></code> and <code><nowiki>Parser command</nowiki></code>:
 
First click on  <code><nowiki>PHP External Tools</nowiki></code> there's two things to change <code><nowiki>Run PHP command</nowiki></code> and <code><nowiki>Parser command</nowiki></code>:
 
<pre><nowiki>
 
<pre><nowiki>
第84行: 第84行:
 
</nowiki></pre>
 
</nowiki></pre>
 
Then click <code><nowiki>Ok</nowiki></code> to apply.
 
Then click <code><nowiki>Ok</nowiki></code> to apply.
https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=warning.png
+
https://help.ubuntu.com/community/[[UbuntuHelp:[[UbuntuHelp:IconsPage|IconsPage]]?|IconsPage]]??action=AttachFile&do=get&target=warning.png
 
In order for the above to work we need to '''setuid root''' the <code><nowiki>/usr/sbin/apache2</nowiki></code> file. https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=warning.png
 
In order for the above to work we need to '''setuid root''' the <code><nowiki>/usr/sbin/apache2</nowiki></code> file. https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=warning.png
 
<pre><nowiki>
 
<pre><nowiki>
第90行: 第90行:
 
</nowiki></pre>
 
</nowiki></pre>
 
'''Note:''' making scripts or programs setuid root is definitely not recommended for security purposes.  This gives any user on your system the ability to execute the program and in most cases this isn't a good idea.  However on a development machine safely behind a firewall, and with no access from an outside network, it may not be a problem.
 
'''Note:''' making scripts or programs setuid root is definitely not recommended for security purposes.  This gives any user on your system the ability to execute the program and in most cases this isn't a good idea.  However on a development machine safely behind a firewall, and with no access from an outside network, it may not be a problem.
If some one knows of a better way for PHPEclipse to be able to stop and start Apache please update these instructions.
+
If some one knows of a better way for [[UbuntuHelp:PHPEclipse|PHPEclipse]] to be able to stop and start Apache please update these instructions.
 
To start Apache from Eclipse simply click the '''Start Apache''' icon.
 
To start Apache from Eclipse simply click the '''Start Apache''' icon.
 
== TODO ==
 
== TODO ==

2007年12月4日 (二) 11:15的版本

Note:Eclipse is now available in the Universe repository. See : UbuntuHelp:EclipseIDE

Notice

This installation guide will install PHPEclipse into an Eclipse installation in your home directory or in the /opt directory (depending of your EclipseIDE installation method) PHPEclipse is able to controll MySQL as well as Apache, and using dbg as a debugger. See below for instructions on controlling Apache using PHPEclipse.

Automated Installation

An automated installation of PHPEclipse is available via the Eclipse Update Manager. 0. Start Eclipse as root, $sudo eclipse or $sudo -s then #eclipse

  1. Click on Help->Software Updates->Find/Install from file menu in Eclipse.

2. Select the radio button labeled, "search for new features to install". 3. Click on the "New Remote Site" button. 4. Enter a name, and the URL: http://phpeclipse.sourceforge.net/update/releases 5. Click on "Finish". 6. A list of features will be presented, open the list and check the one labeled "phpeclipse". 7. Click on "Next" 8. Follow the onscreen instructions to finish the automatic install.

Ubuntu Feisty 7.04 Fix

When you try to edit a .php file using the PHPeclipse editor, you will get an error message that tells you to look in the log. This problem arises due to problem with the default JVM used in Feisty. To fix the problem:

  1. Close eclipse and at the bash prompt:

2. sudo apt-get install sun-java6-jre libxext6-dbg 3. sudo nano -w /etc/eclipse/java_home 4. Insert /usr/lib/jvm/java-6-sun on the line above /usr/lib/jvm/java-gcj 5. Close and save the file

Installation

This document assumes you have a running Eclipse installed as described in UbuntuHelp:EclipseIDE. PHPEclipse is a plugin to Eclipse and should be placed in the $HOME/opt/eclipse/plugins directory for the personnal installation or /opt/eclipse/plugins for the global installation. The PHPEclipse project is located at www.phpeclipse.de and you will find the zipped plugin files here.

  • Download the latest release (PHPEclipse1.1.3-2005-01-29 when this document where written) to your favorite download directory. Then change directory to the eclipse directory (personnal installation):
$ cd ~/opt/eclipse

or (global installation)

$ cd /opt/eclipse
  • Unzip the previously downloaded PHPEclipse plugin (use sudo if you used the EclipseIDE global installation method):
$ unzip ~/your_download_dir/PHPEclipse1.1.3-2005-01-29.zip

(substitute your_download_dir and zip file name to fit your system)

  • The plugin is now installed but "Eclipse 3.x caches all plugin.xml files into a single repository for quicker loading. If you used eclipse before installing PHPeclipse, you should start eclipse once with the -clean option. This -clean forces Eclipse to rebuild that repository. This applies to anything that is installed into eclipse by unzipping it into its plugins folder.":
$ eclipse -clean

Next time you may start Eclipse your favorite way, without the -clean option.

Controlling Apache from Eclipse

Configuring Apache

The first thing you'll want to do is have a working Apache install see UbuntuHelp:ApacheMySQLPHP for details. The assumption is that you're installing Apache on a workstation that is seperate from your production web server. In your favorite text editor open /etc/apache2/sites-available/default change DocumentRoot to somewhere in your home directory:

DocumentRoot /home/<username>/work
and
<Directory /home/<username>/work/>

Note: the above is just an example of my work environment change the path accordingly. Also, the PHP Browser that is part of PHPEclipse by default wants to open http://localhost/php/your_script. and reload Apache to recognize the new configuration:

/etc/init.d/apache2 reload

Configure PHPEclipse for Apache

Now that we have Apache configured for our development environment we can configure PHPEclipse to control Apache. First open Eclipse and click on:

Window > Preferences > PHPeclipse Web Development

This opens the PHPEclipse options dialog. First click on PHP External Tools there's two things to change Run PHP command and Parser command:

Run PHP command default is /apache/php/php
change this to: 
/usr/bin/php
Parser command default is /apache/php/php -l -f {0}
change to:
/usr/bin/php -l -f {0}

Note: you'll need the php5-cli package installed for this to work. Next click on Apache under PHP External Tools where we'll need to change the Apache and Start Apache values:

Change Start Apache to:
-k start
and Apache to:
/usr/sbin/apache2

Then click Ok to apply. https://help.ubuntu.com/community/[[UbuntuHelp:IconsPage?|IconsPage]]??action=AttachFile&do=get&target=warning.png In order for the above to work we need to setuid root the /usr/sbin/apache2 file. IconsPage?action=AttachFile&do=get&target=warning.png

sudo chmod u+s /usr/sbin/apache2

Note: making scripts or programs setuid root is definitely not recommended for security purposes. This gives any user on your system the ability to execute the program and in most cases this isn't a good idea. However on a development machine safely behind a firewall, and with no access from an outside network, it may not be a problem. If some one knows of a better way for PHPEclipse to be able to stop and start Apache please update these instructions. To start Apache from Eclipse simply click the Start Apache icon.

TODO

Write about controlling MySQL as well as using dbg. Note: this guide has been tested on Ubuntu 7.04 (Feisty) and Ubuntu 7.10 (Gutsy).