Vhost and Debugging with 127.0.0.1:8888 - php

I have a Drupal application that runs using the following command "drush runserver"
When I run this command, I get the following message: "HTTP server listening on 127.0.0.1, port 8888 (see http://127.0.0.1:8888/)"
If I visit that url, I see the application I am supposed to see, so that is good.
However, I am trying to create a vhost to this url as well as do some debugging on the application.
I've created vhosts many times before, but never for an application that lives on another port. After doing some google searches, I have placed the following in my httpd-vhosts.conf file:
NameVirtualHost *:8888
<VirtualHost *:8888>
DocumentRoot "/Users/justin/Sites/drupal/"
ServerName myproject.dev
ServerAlias www.myproject.dev
ErrorLog "/private/var/log/apache2/myproject.dev-error_log"
CustomLog "/private/var/log/apache2/myproject.dev-access_log" common
</VirtualHost>
I've also placed the following in my /etc/hosts file.
127.0.0.1 myproject.dev www.myproject.dev
And even after restarting my server, if I visit myproject.dev in my browser window, the browser just hangs. Like I said, I've never had problems doing this before, but I'm guessing it has something to do with the 8888. Any solutions for this?
Secondly, I am trying to set up debugging for my application in PHPStorm. Again, I have a feeling the reason I am having so much trouble is because of the 8888 port. I must be missing something that I usually do not have to set when I debug normally (port 80).
Here are my current xdebug settings in my php.ini file:
[xdebug]
zend_extension="/usr/local/Cellar/php55-xdebug/2.4.0/xdebug.so"
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host="127.0.0.1:8888"
xdebug.remote_port=9001
xdebug.remote_autostart=1
xdebug.idekey="phpstorm"
xdebug.max_nesting_level=1000
And I should mention that my debugger works with any random PHP file I make outside of the project. Again, I must be missing something with this 8888 port.

You are dealing with three different things here. First is the built in PHP web server that is spinning up with Drush. It listens on port 8888 unless you specify differently on the command line. Second is Apache and a vhost configuration. You can leave the vhost listening on port 80. The port is selected by the server not the application. You can run the server on port 16421 and your app will work just fine. Third is your xdebug config.
The only real problem I see is your xdebug config. You only need the remote host IP/hostname not the additional port. The port you have added there is the port used by PHP's built in web server. Xdebug runs on a different port which is defined in the xdebug config xdebug.remote_port setting. PHPStorm is going to be configured to connect to xdebug on that specific port, . Make sure the ports in PHPStorm and your xdebug config match.
If you have it configured correctly, it won't matter if you are using the built in web server or Apache, you will be able to debug.

Related

I can't change xampp apache default port number

I changed the httpd.conf file lines:
Listen 80 TO Listen 8012
servername localhost TO servername localhost:8012
And still it trys to start apache at port 80, but can't because a system process is using it.
EDIT
No my question is still different because I already followed those steps listed in the possible duplicate question: How to change the port number of Apache in Xampp
you need to run xampp as an Administrator. it will fix it.

How to know which port php5 is using I forgot the port number I used to install

I did not use PHP but had to install it for ganglia setup but could not access the php on calling localhost it shows IT Works .How do I know what is the port number .
The default port for HTTP is 80, so if in your browser you are using http://localhost and says "It works!" means it is working on port 80.
PHP is not a web server, you are probably using Apache. You can find its configuration files in /etc/apache2 folder. Look for apache2.conf, httpd.conf or ports.conf and find a line like "Listen (Port Number)"

Run both HHVM and Normal Apache Server

This morning I started using HHVM as my default local server. Most things are fine, but I still have applications that HHVM doesn't fully support yet.
Rather than changing my configuration and restarting services, it would be much easier if I could just switch ports or directories.
My Question: Is it possible to run a normal Apache server on one port (80) and a HHVM powered server on another port (8080)? Alternatively, is it possible to only run HHVM in a specific directory (and its' sub-directories)?
In scenario 1 switching to HHVM application would look like this:
localhost/my-project/index.php
localhost:8080/my-project/index.php
In scenario 2 switching to HHVM application would look like this:
localhost/my-project/index.php
localhost/hhvm/my-project/index.php
I would guess that this can be achieved via Apache's config file, but I don't know enough about how the config files work to do it myself, please help!?
OS: Ubuntu 14.04
Apache Version: 2.4.7
HHVM Version: 3.2.0
To /etc/apache2/ports.conf add...
Listen 8080
Then, to your vhost configuration (since using localhost as your domain, probably /etc/apache2/sites-available/default.conf), copy everything in there and paste it right below so you have a second VirtualHost instance. To the second instance, change the *:80 to *:8080, then add your ProxyPassMatch to tell it you're wanting to use HHVM for hh and php file extensions (don't forget to update to correct directory).
It should look something like...
<VirtualHost *:80>
... keep the same ...
</VirtualHost>
<VirtualHost *:8080>
... keep the same ...
ProxyPassMatch ^/(.+\.(hh|php)(/.*)?)$ fcgi://127.0.0.1:9000/var/www/$1
</VirtualHost>
Go into /etc/apache2/mods-available/hhvm_proxy_fcgi.conf and comment out what's in there. Otherwise everything will be headed toward HHVM.
Finally, restart apache
sudo service apache2 restart
I tested this quickly on an existing local site and it was redirecting back to 80 from 8080 which it should have done. If this doesn't work out, let me know.
UPDATE: Tested a bit more, and it looks like this should work out for you. After adding the following, jumping between local.site.com/hhvm.php and local.site.com:8080/hhvm.php flipped the echo correctly.
<?php if (defined('HHVM_VERSION')) {
echo "golden!";
} else {
echo "doh...";
}
Yes. You can have Apache listen on both port 80 and port 8080 (just add in additional listen configurations), then add a virtual host for localhost:8080 that passes requests off to HHVM through FastCGI.

Virtual Host for wamp server running in port 85

We have dedicated windows server where IIS running in :80 and Wamp running in :85.
I successfully created a Virtual Host for wamp server which is running in :85.
NameVirtualHost *:85
<VirtualHost *:85>
ServerName www.my.tv
ServerAlias my.tv
DocumentRoot C:/wamp/www/alpha
ErrorLog "C:/wamp/www/alpha/logs/error.log"
CustomLog "C:/wamp/www/alpha/logs/access.log" common
</VirtualHost>
yes the above code is working & site is running only when i hit www.my.tv:85 but not in www.my.tv
can someone advice on the above where i could configure to make the site run at www.my.tv
If you configure Apache to serve your site on port 85 then the browser (which will default to port 80) won't find it unless you give it the port number it needs.
If you need to see the site on port 80 then you need to configure it on that port. Since you have another server running on that port it's not an option.
One possibility is that you create a virtual site on your IIS server for www.my.tv, but have it redirect to the site on port 85. You can do this in the properties box, on the Home Directory tab.

Xdebug for remote server not connecting - netbeans

I'm trying to use XDebug in the following scenario
my computer Windows 7, Netbeans 6.9
Physical Host at computer on the same network (Windows 7) with virtual Box
Virtual CentOS 6.2, with Apache server 2.2.15 and PHP 5.3.3
the PHP code of my website is on a shared folder on CentOS, in /var/www/html/mysite and have separate and can access it by server ip 192.168.1.240
Edited C:\Windows\System32\drivers\etc\hosts 192.168.1.240 mysite
the PHP code is accessible from my Windows host, on \\HostIP\html\mysite, with R/W permissions
I created a Netbeans project on my computer, pointing to \\HostIP\html\mysite. In the project Run configuration, I have the following:
Run as: Remote Web Site
Project URL: http://mysite/
Index file: index.php (does exist in the project)
In the Advanced Run Configuration:
I checked "Default"
I haven't touched the proxy settings
I have the following in the php.ini on my CentOS VM
;extension=xdebug.so
zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_log="/var/log/xdebug.log"
;xdebug.remote_host=192.168.1.31
xdebug.remote_connect_back=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
note: I tried the configurations with extension=xdebug.so and tried commenting xdebug.remote_connect_back=1 with uncomment xdebug.remote_host=192.168.1.31 which is my computer ip address.
so basically i have all the configurations like this image
but still not working! after run the debugger will open this url
http://mysite/index.php?XDEBUG_SESSION_START=netbeans-xdebug
and nothing will happened just netbeans Listing waiting for Xdebug connection
When i want to debug on a remote host i normally have to forward my local 9000 port to the remote server's local 9000 via a ssh tunnel:
ssh -R 9000:localhost:9000 username#remote.example.com
Use bitvise ssh client or putty on windows to get the same effect.
Also in the project settings -> run configuration -> Advanced button
make sure to specify the remote and local full paths the the project files so the debugger can attach (don't worry about the port in this screen leave as standard).
I know this is an old post, but it seemed like the one I ran across the most tonight.
The NAT Network setup is the way to get the least amount of conflict. In the Windows 7 Firewall, setup a custom Inbound Rule to allow inbound traffic to port 9000 for the entire /24 network that the VM is on (192.168.202/24).
My working XDebug setup in the php.ini, using 2.2.7 with Netbeans 8.0.2:
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"
xdebug.show_local_vars=0
;xdebug.extended_info=1
xdebug.output_buffering=off
xdebug.remote_log=/var/log/xdebug.log
Lastly, I want to point out that Netbeans listens for the remote address setup in the remote file config. Doing a quick netstat -an showed that Netbeans was listening on port 9000, with a CLOSE_WAIT status on an old address from my initial bridged network setup. Even after changing the Project URL, and the Remote Connection IP address, and closing several xdebug connections, this never changed. Only after closing Netbeans, does the stale connection drop. Once Netbeans is started again, the new remote server URL is used for the remote xdebug connection.
Mention of Netbeans holding a stale state was never discussed, and the ability to stop the xdebug connection from the IDE gives a false sense of resetting the socket.
If it still doesn't work, use the provided debugclient on the VM, visit the project page with "?XDEBUG_SESSION_START=netbeans-xdebug" appended to the index.php URL, and watch for the xdebug info to come in. At least then you know it works locally.
Try setting up any breakpoint to your executed script. Debug session may not show up while ide does not respect "break at first line" flag.
Also check if xdebug.idekey property in php.ini equals to ideKey in Netbeans' settings.

Categories