I'm running Debian on a VPS server, and have both the development and production code and database on the same server.
Is it possible to get the server to log only the errors for the development part of the server, and not the production. Right now, there are so many errors being logged from the production side, which makes it hard to get to the development errors.
Although this really belongs on serverfault.com:
You should definitely always log all errors.
If you host for example 2 domains on your server, example.com and test.example.com you can specify for each virtual host where you want to store the logs.
On apache your virtual hosts could look like:
<VirtualHost xxx.xxx.xxx.xxx:80>
// some configuration stuff
ServerName example.com
// some more configuration stuff
CustomLog /var/log/httpd/example.com-access_log combined
ErrorLog /var/log/httpd/example.com-error_log
</VirtualHost>
<VirtualHost xxx.xxx.xxx.xxx:80>
// some configuration stuff
ServerName test.example.com
// some more configuration stuff
CustomLog /var/log/httpd/test.example.com-access_log combined
ErrorLog /var/log/httpd/test.example.com-error_log
</VirtualHost>
So you can easily distinguish log information for test.example.com from example.com.
Related
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.
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
I'm not sure what to search for, but this is what I want to achieve.
I have a domain name registered somewhere. I also have a dedicated Linux server somewhere else. I'm running a website (Apache/PHP) on that Linux server that I can now visit through:
http://[my server ip address]/subfolder-1/index.php
I changed the DNS settings of my domain name to the IP address of my Linux server. Right now when I goto my domain name it actually loads the index.php at: http://[my server ip address].
I know I can do something in Aapache so that it knows when a user comes from www.mydomain.com, that it should display the site located in:
http://[my server ip address]/subfolder-1/index.php
And when I come from www.my-otherdomain.com that it should load the site from:
http://[my server ip address]/subfolder-2/index.php
But I'm not sure what to look for and how this is called? How can I configure my Apache server for that?
You need to setup virtual hosts for each domains on Apache like this :
<VirtualHost *:80>
ServerAdmin admin#test.com
ServerName test.com
ServerAlias www.test.com
DocumentRoot /var/www/test.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
after that reload the server :
sudo service apache2 restart
I am trying to set up my apache server. So far I have the following apache config:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot /var/www/system_learningbank/
ServerName www.learningbypower.dk
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
(You can try it out by going to www.learnbypower.dk)
The login screen works fine. However, when I log in it seems as if it's redirecting to another folder where my old system was.
Can anyone tell me what I can do to stop this from happening?
This is an error in your application configuration. The application is failing. Check the logs. Likely its caused by a syntax error or, maybe missing libraries like GD, etc.
Look at the log file:
logs/dummy-host.example.com-error_log
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