Search code examples
mysqlapachebashcloud9-ide

c9.io stop apache to free up process.env.PORT


I was attempting to run both node and apache on a c9.io web server VM. I had used the c9.io phyMyAdmin install script, which configures the local MySQL instance, installs then restarts apache. phpMyAdmin can be accessed fine at https://workspaceName-workspaceOwner.c9.io/phpMyAdmin however, I now cannot stop apache from running, taking up the env.PORT assigned by c9.

Response from root request:

enter image description here

When node runs:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: listen EADDRINUSE

My attempts at stopping the apache process:

From Tools -> Process list -> search for apache and force kill - no effect

From the terminal:

/etc/init.d/apache2 stop
  • no effect
apachectl stop

httpd (pid 20190?) not running

service apache2 stop
  • Stopping web server apache2 * No effect, web server response and process still exists
ps au | grep apache

ubuntu 22910 0.0 0.0 10552 880 pts/3 S+ 06:30 0:00 grep --color=auto apache

kill -9 22910

bash: kill: (22910) - No such process

kill -9 `ps au | grep apache | awk '{print $2}'`

bash: kill: (22926) - No such process

killall apache2

apache2(20190): Operation not permitted

As c9.io do not give su access to the VM or allow us to restart the VM does anyone have any other possible way to resolve this? I'd also like to switch between running node and apache quickly (as both isn't possible) to use phpMyAdmin as I cannot connect with MySQL Workbench. Any assistance or advice appreciated.


Solution

  • You can kill the apache2 process by typing: sudo killall -9 apache2 into the terminal. Also, on Cloud9, apachectl start and apachectl stop are the only recommended ways to start/stop the apache server.

    Btw, you can restart your workspace by clicking on the stats menu item on the right and clicking the 'Restart' button in the dropdown. Did that not work for you?

    To switch between the two, you can probably make a shell script to do that, but another idea could be to use apache to act as a proxy to your node app. I haven't tried this myself, but maybe the following could help:

    http://thatextramile.be/blog/2012/01/hosting-a-node-js-site-through-apache

    Hope this helps