Saving 2 PHPSESSID accessing computer using same IP address - php

Server is WAMP. I have 2 sugarcrm sites, one for production say, saved at www/folder1 , other for development say saved at www/folder2 . I am accessing them using IP address (say 66.102.0.0/folder1 and 66.102.0.0/folder2 ) . Browser saves 1 cookie (PHPSESSID) for both of them. If I login/logout to first site, it effects other site also. I can create subdomain at localhost like folder1.localhost and folder2.localhost but how IP based sub-domain is possible like, folder1.66.102.0.0 and folder2.66.102.0.0 (looks funny :) ) ?Or can I use different port for different folder, like 66.102.0.0:80 and 66.102.0.0:8080 ?Then will browser saved 2 cookies, if port is different on same ip address?I can't change login/logout, it's sugarcrm not core php. I can use different browsers but my boss is saying to make cookies separately. Or is there any browser Add-on that separates cookies based on folder?

Call session_set_cookie_params() to restrict the cookie to a particular folder:
$params = session_get_cookie_params();
session_set_cookie_params($params['lifetime'], '/folder1');
session_start();

Yes. Creating subdomains should solve your problem. I do this all the time.
If you are opening your site as 66.102.0.0 then your session is based on that url which is causing all the problems.
Note: Directories mentioned here are windows wamp specific but as long as you find the appropriate files, this applies to Apache in all OS's.
Step 1. Uncomment this line in your bin/apache/Apache*.*.*/conf/httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Step 2. Make a virtual host entries in your bin/apache/Apache*.*.*/conf/extra/httpd-vhosts.conf file.
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "D:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/wamp/www/folder1"
ServerName folder1.localhost
ErrorLog "logs/folder1.localhost-error.log"
CustomLog "logs/folder1.localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/wamp/www/folder2"
ServerName folder2.localhost
ErrorLog "logs/folder2.localhost-error.log"
CustomLog "logs/folder2.localhost-access.log" common
</VirtualHost>
Step 3. Restart wampserver / apache.
Step 4. Edit your hosts file. C:\Windows\System32\drivers\etc\hosts
Add in the entries.
127.0.0.1 folder1.localhost # You probably want 66.102.0.0 over here instead of 127.0.0.1
127.0.0.1 folder2.localhost

Related

XAMPP won't load index.php when using a domain name

So, when I use localhost/website/index.php to access index.php, it works just fine, yet when I use a domain name like website.com/website/index.php and try to access index.php from another page, it doesn't redirect me there, but instead, reloads the page it was already on.
Then, when I try to access index.php via the search bar, it throws an error saying This page isn't working.
Does anyone know a fix for this?
You need to set up a vhost for Xampp
Here's an example which should be added to C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#website
DocumentRoot "C:/xampp/htdocs/website"
ServerName website.com
ErrorLog "logs/website-error.log"
CustomLog "logs/website-access.log" common
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster#website
DocumentRoot "C:/xampp/htdocs/website"
ServerName website.com
SSLEngine On
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
<Directory "C:/xampp/htdocs/website">
php_flag log_errors on
php_value error_log "logs/website-error.log"
AllowOverride All
Order allow,deny
Allow from all
</Directory>
php_flag log_errors on
php_value error_log "logs/website-error.log"
CustomLog "logs/website-access.log" common
</VirtualHost>
You also need to configure your local hosts file to send requests for website.com to your local IP address.
Your hosts file is here: c:\Windows\System32\Drivers\etc\hosts
Add an entry:
127.0.0.1 website.com
This will allow you to access the website on your local machine.
To access the website on your local network you can either change all computer's hosts files as above, or add a DNS A record into your network switch (if it supports DNS)
A website.com 192.168.1.51 (this is your LAN IP address)
If you need the internet to access the website on Xampp you need to add an A record to your public IP address in your domain name DNS control panel. You can find your pulic IP address here: https://www.whatismyip.com/ and you will also need to allow traffic on ports 80 and 443 in through your router and firewall.
If you do not have a static IP address from your internet service provider, you will need to update your domain name DNS A record each time your IP address changes - e.g. if you restart your router, and/or periodically)
Please note: Xampp was not designed to be accessible from the internet, it will work but it's not secure. Please read https://www.makeuseof.com/reasons-why-you-should-never-use-xampp-on-production-server/

Laravel - How to share application to another stations

I developed an application with laravel and i put it in a local server and i need that other computer access it.
I think that have 2 solutions:
First: Access to laravel server (port 8000)
Second: Put the project in xampp
What is the best solution?
With the first option i can't access and with xampp it doesn't access well to routes and doesn't load the css and js files.
If i access to root folder it list the project folders and i have to go to public folder but doesn't load stylesheet files.
How can i do that?
UPDATE:
I did this steps and this not work yet.
In httpd.conf enable this line Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
Next i add a host in in hosts file:
127.0.0.1 arquivo.localhost
Next i'm going to httpd-vhosts.conf and add this:
<VirtualHost *:8888>
DocumentRoot "/Applications/MAMP/htdocs/arquivo/public"
ServerAdmin arquivo.localhost
<Directory "/Applications/MAMP/htdocs/arquivo/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Next i restart the apache and when i try to access to http://arquivo.localhost this give me This site can’t be reached
What i'm doing wrong?
Thank you
create virtualhost under xampp/apache/conf/extra/httpd-vhost.conf
like this
<VirtualHost *:80>
ServerAdmin webmaster#localhost.com
DocumentRoot "C:/xampp/htdocs/laravel/public"
ServerName laravel.localhost
ErrorLog "logs/laravel-error.log"
CustomLog "logs/laravel-access.log" common
</VirtualHost>
and access with http://laravel.localhost/
If its working fine on your localhost, other person can access your site using your Ip address, provided you both are on same local network.
For more you can see this reference : Accessing localhost (xampp) from another computer over LAN network - how to?

How to access a site on Codero without a domain name and without appending the username to the end

Yesterday i have created a new site on my Codero Dedicated Server. and i have not assigned any domain name yet to the ip address.
Currently i am able to access my site with http://MySiteIpAddress/~username but i want to access it with only http://MySiteIpAddress/. Is there any way to do it. I don't know if that's possible by htaccess rules, so any hints are appreciated.
You want to setup a virtual host and point it to the folder you want.
See this other post for more details.
You need to do several steps in order to make this work.
1.) Update the hosts file. On Windows XP, you can find it under c:\WINDOWS\system32\drivers\etc\. You should already see the first
line from below, it takes care of your mentioned other project. - add
the additional ones to make any requests to the mentioned virtual
hosts routed back to your own machine.
127.0.0.1 localhost
127.0.0.1 foo-bar.com
127.0.0.1 abcdef.com
127.0.0.1 qwerty.com
2.) Update the vhosts file in Apache configuration. Under your XAMPP folder, add the following to
apache\conf\extra\httpd-vhosts.conf and if needed change the ports
(i.e. if you use 8080 instead of port 80).
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/foo-bar/
ServerName www.foo-bar.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/abcdef/
ServerName www.abcdef.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/qwerty/web/
ServerName www.qwerty.com
</VirtualHost>
3.) Do a quick configuration check. Open {XAMPP-folder}\apache\conf\httpd.conf your file and make sure that
the following part is not commented out by a preceeding # character:
Include conf/extra/httpd-vhosts.conf
4.) Restart XAMPP.
... and you should be all setup now. Your other project should
be accessible at the URI you mentioned if you just put it under
C:/xampplite/htdocs/my-project/.

Access vhost via ip address on lan

I am running WAMP and using CodeIgniter for my project and have this on my vhost:
<VirtualHost *:80>
ServerAdmin admin#yahoo.com
DocumentRoot "C:/wamp/www/myproject/assets"
ServerName myproject.dev
ErrorLog "logs/myproject.dev-error.log"
CustomLog "logs/myproject.dev-access.log" common
</VirtualHost>
Now to access this, I added this line on windows/system32/drivers/etc/hosts:
127.0.0.1 myproject.dev
Now for the other computers on the network, I have to edit the hosts file of EACH computer so they can access my virtual host. (yes of course I have to use my ip address instead 127.0.0.1 for other computers)
Now my question is, is there a way that they can access my project by only using my ip address on the browser's address bar like this?
http://192.168.1.112/myproject
I mean there are 100 users that will access that project and it's a big hassle if I edit each one's hosts file. Like adding something to .htaccess, or to the routes of CodeIgniter, or to the <virtualHost>
Note:
By the way, when we are still NOT using Codeigniter (plain PHP codes), this is not a problem. But because of Codeigniter's structure, we can't do it anymore.
Can you just add a DNS entry that points to your IP address and set that as the ServerName that apache responds to?
Alternatively you can do virtual hosting based on IP address and port as described here:
http://httpd.apache.org/docs/2.2/vhosts/ip-based.html
In summary you should be able to do:
<VirtualHost 192.168.1.112:8000>
ServerAdmin admin#yahoo.com
DocumentRoot "C:/wamp/www/myproject/assets"
ServerName myproject.dev
ErrorLog "logs/myproject.dev-error.log"
CustomLog "logs/myproject.dev-access.log" common
</VirtualHost>
And have people access it via
http://192.168.1.112:8000/myproject
But, don't forget to add a Listen directive for port 8000 (or whatever you choose) if you use IP-based Virtual hosts
It might work of you create an alias called /myproject in wamp server and point the document root to 'C:/wamp/www/myproject/assets'
Make sure you have set your wamp server status to online by selecting 'Put Online' in wamp server system tray icon.

Site not loading, apache configuration

ATTN! I should mention this is all localhost. As in my machine, no servers or other jazz included.
I am really bad at configuring sites in apache, how ever I have the following config:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/image_upload_app
ServerAlias www.dev-imageuploadapp.com
<Directory /var/www/html/image_upload_app>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And when ever I visit www.dev-imageuploadapp.com, I get a "The web page is not available" in chrome.
There are no errors in the access or the error log, after attempting to visit the page. Apache is running and the site is enabled.
The directory does exist and contains a index.php.
You need to set ip address of your site on DNS Servers. There is some free DNS Servers like https://www.cloudflare.com/. If you do in this way, you need to set delegated DNS Servers on your domain-holder site. Another try you can go to site to IP by http://{your-ip-address}/
Your browser needs to know which IP address is to use for a provided name. To enforce some values to localhost, you can add them into hosts file. Following line needs to be added:
127.0.0.1 www.dev-imageuploadapp.com
In /etc/hosts change the line:
127.0.0.1 localhost
To
127.0.0.1 localhost www.dev-imageuploadapp.com

Categories