server ip keeps redirecting to defaultwebpage.cgi - php

I haven't registered any domain for my server.
I might be wrong, but according to my understanding,
the default ip for the server is public.
my server ip is http://166.62.101.242/.
but whenever i ping on that domain, it keeps redirecting to the /usr/local/cpanel/cgi-sys/defaultwebpage.cgi
folder.
I have changed my /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
however it still keeps redirecting to the cpanel page.
what changes do i need to make, so i can access the /var/www folder without registering for a domain?

This redirection is because cPanel uses Block Hosting. You will have to point a domain to the IP Address and tell cPanel to register that domain in your system. I would highly suggest you to get a domain instead of modifying anything with cPanel because if something goes wrong, you may not be able to manage your site. You can get a free domain from freenom.com. If you need further assistance for setting it up, please hit me up and I'll guide you step by step.

It seems there is error in processing .php file in apache.
I have got same problem.
change the ownership of the file.
e.g. if the file name ins info.php
sudo chown nobody:nobody info.php
sudo chmod 644 info.php
Let me know if this help
Also make sure to add .php in
sudo vim /etc/httpd/apache/conf
AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml .php

It is looks that you have VPS with a WHM/cPanel.
There are multiple possibilities to set that.
The most easy way is to add an account and set a new domain...
Or can hack the Apache global configuration WHM -> ApacheConfiguration -> Global Configuration and set a new virtual server in premain. The server should have same external and internal IPs
The other way is to hack the main.conf template and change the httpd configuration.
After, you should run:
/services/rebuildhttpdconf
to rebuild the httpd.conf
Please note that your changes in default httpd.conf will be overwrite everytime the cPanel/WHM will restart, so your solution with modification of default /etc/httpd/conf/httpd.conf it is not OK!

Try with the IP instead...
VirtualHost 166.62.101.242:80
...and clean your browser cache! (or you can try this first).

I had the same behavior and I was going to hit my head to the wall because of that :(. The reason why you are getting this is because the content of /etc/httpd/htdocs/index.html IS
<html><head><META HTTP-EQUIV="refresh" CONTENT="0;URL=/cgi-sys/defaultwebpage.cgi"></head><body></b‌​ody></html>
It takes 2 days for me to figure this out. If you managed to land your request on your server but the name you are requesting -the IP in our case- is not exist in the apache virtual hosts, the apache is going to response with this file. ;-)

Related

Two symfony projects on one server/domain

I've created two independent symfony projects and I've moved them to my prod server, for example:
project1.example.com [/var/www/project1/web]
project2.example.com [/var/www/project2/web]
The problem is that when I open up the second address, then project1 is fired up. I checked /var/www/project2/web/app.php and seems it's properly executed, but for some reason, symfony loaders use /var/www/project1/ path. Of course the cache folders were cleared.
Any ideas how to diagnose the problem?
UPDATE
Apache config files:
/etc/apache2/apache2.conf
/etc/apache2/sites-enabled/project1.conf + /etc/apache2/sites-enabled/project2.conf
UPDATE 2
Strange thing, this morning the situation has reversed. Both addresses show site from project2 now. No config nor project files were modified.
You'll need to enable Virtual Hosting in Apache.
Take a look at my article on it, it should answer the question:
https://alvinbunk.wordpress.com/2016/11/21/apache-httpd-virtualhost-config/
If you need further help with that, you can always post another question. I use this all the time.
EDIT #2 - based on Apache 2 conf:
Suggest you combine SSL and HTTP VirtualHost ports like so, and also just have a single Directory directive to the web folder. There are other redundancies in the conf file. Please read some documents first about the Apache config files before asking questions.
<VirtualHost *:443 *:80>
...
<Directory /var/www/project1/web>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
...
</VirtualHost>
For the Project2 problem, have you checked the logs in $APACHE_LOG_DIR to see what they show? I think logs are usually in /var/log; there's probably an httpd subdirectory with the httpd logs. You need to make sure there is an incoming GET request for project1.example.com.pl. If not, you'll need to check all your hosts files to see they are setup correctly.

W7, apache, php: 403 Forbidden You don't have permission to access /phptest/phpinfo.php

There are lots of questions on this but I still cannot get it to work.
I am installing Apache 2.4 and PHP 5.4.37 on a W7 Pro PC. PHP is running as a load module. If installed respectively in c:\apache24 and c:\php, with the document root as default at c:\apache24\htdocs, it all works fine.
However, I then decided I wanted the document root at f:\webroot (local drive), making necessary changes to document root in httpd.conf. webroot has all the same permissions as c:\apache24\htdocs, but I get the error message in the title.
A normal index.html file in webroot is served OK, it is just any PHP file that isn't.
I noted that the Apache service is started with user LocalSystem. So I tried various others. I even tried running Apache from the command line (instead of as a service) logged in as Administrator, which should have had access to anything, and it made no difference - same message.
Don't understand what is going on. I can go back to the default document root, but at some point will need to access folders elsewhere on the system, so I will be back with the same problem, I guess.
Further info:
Tried various combinations of the commands in <directory "f:/webroot"> to no effect, BUT have found that if in <directory /> I set 'Require all granted' instead of 'Require all denied', it works. However, not sure (a) if that is wise (it probably isn't) and (b) why it is needed anyway. Any suggestions about what I should set it to?
Solved this:
Not only do you have to set Document root and the matching <DIRECTORY ...> section entry in httpd.conf, but also DocumentRoot in the <VirtualHost _default_:80> section of the ...\conf\extras\httpd-vhosts.conf file.
Setting 'Require all granted' in <DIRECTORY /> was a mistake.

Apache can't find localhost/~user directory

Hi every one I'm setting up apache following a tutorial on OS X Yosemite.
I can get to the "It works" page from default WebServer directory but when setting up my own user directory apache doesn't find it anymore. I created the Sites directory in my User folder.
Then I created the username.conf in /etc/apache2/users I also have a Guest.conf there that's not mentioned in my tutorial but I don't know if it is the problem and I'd rather ask than delete it without knowing.
my username.conf file :
<Directory "/Users/mathiashintjens/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
I used sudo chmod 644 mathiashintjens.conf to changes privileges then sudo apachectl restart
Then I created an index.html file in my ~/Sites directory and yet I still can't open it in my browser using http://localhost/~mathiashintjens/
I have installed MAMP in the past so maybe here lies the problem?
If anyone could help me it would be really cool.
Thanks in advance!

How to activate mod_rewrite?

I know that this question have been asked several times. But I can't get it to work.
I installed Apache2 in my Ubuntu server I can also confirm that mod_rewrite is installed using phpinfo();. I have also put a file called .htaccess in my root folder(/var/www/.htaccess). In my .htaccess file I paste the following code:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^.*$ test.php
So everything is redirected to test.php
But it still doesn't work. So I checked my httpd.conf file under /etc/apache2. It is completely empty, with no lines of code (This seems a little odd to me)?! However checking in Stackoverflow answers there should be at least the following code in httpd.conf:
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Satisfy all
</Directory>
So I paste that code in httpd.conf. And restarted Apache with sudo /etc/init.d/apache restart. And it still does not work?
I have also tested to open the file /sites-enabled/000-default and /sites-available/default, where all virtual host settings lies and change under the directory /var/www and / to AllowOverride All. The mod_rewrite still doesn't work. Can anyone please help me. This problem has been baking my nuts for a while.
Also, my apache2.conf file doesn't work. I tried to write som nonsense. And it is still gives me the normal result instead of http 500 error
if you run this command,
sudo a2enmod rewrite
ubuntu will output whethere it is activated or already running.
All suggestions from Niels Bom are the smartest ones (I think). But I would add this as the first suggestion: try to launch and stop apache via the Ubuntu command: then when it's supposed to be stopped, make sure it's stopped ie verify your local page doesn't show anymore.
read what's in the folder /etc/apache2/. There should be apache2.conf conf.d envvars httpd.conf mods-available mods-enabled ports.conf sites-available sites-enabled
then if everything is ok, take a look at mods-enabled where you will find if the mods are enabled if so, then you can go on, otherwise take a look at the other answers about enabling modrewrite
take a look at sites-enabled: it's where you can find the sites that are... (guess what?) enabled. There should be the default website.
if so, open this file, and try to put apache nonsense in it, restart the server and see if it's happy or not. If it's not happy that's good. If it's happy then you're working on the wrong file
last: try to check what are the authorisations for htaccess files for this default vhost. Here's the way they work: if Apache doesn't find any directive in the vhost file, it will apply the global configuration. So I'd suggest to add the configuration in your vhost file, between the <virtualhost> - </virtualhost> tags (of course).
Please tell me what's going on and I'd be glad to update my question accordingly.
Because this thread ranks very high on google, here another solution:
WHAT'S CAUSING THE PROBLEM ?
It's caused because the standard definition in apache simply blocks all .htaccess stuff. Seriouslsy. This seems to be the initial state in Ubuntu 12.04 LTS.
SOLUTION
In /etc/apache2/sites-available/default (that's a file, not a folder) there's a code block like
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride XXXXXXXXXXXXXXXXXXX
Order allow,deny
allow from all
</Directory>
Here you should change
AllowOverride None
to
AllowOverride All
IMPORTANT
You have to do these changes with sudo rights, anotherwise Ubuntu will not save the file. After a RESTART your .htaccess stuff should work. To test .htaccess simply put some nonsense text into it and surf to localhost or 127.0.0.1 -> If you see "internal server error": voila! Remove the nonsense and you are ready to go.
Okay, let's check assumptions:
Put nonsense in your Apache config files (and restart Apache to let them take effect), does Apache "complain" on restart? Then it tries to load those files. Try this for every Apache config file you can find. You now have a complete list of Apache config files that are loaded.
put nonsense in your htaccess, reload the page, do you get a 500 error? If not, the htaccess is not getting loaded.
Put the most basic mod_rewrite statement in your htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^.*$ test.html
This should rewrite every request to test.html.
Try this and give us the results.
Please check /etc/apache2/apache2.conf
In your question, you have mentioned,
Also, my apache2.conf file doesn't work. I tried to write som nonsense. And it is still gives me the normal result instead of http 500 error
So, before posting more stuff to try-out with .conf files,
run strace -o somefilename.txt sudo /etc/init.d/apache restart
strace - trace system calls and signals : strace(1) - Linux man page.
The -o somefilename.txt part puts the output of strace into somefilename.txt. Open the text file and search for httpd.conf. You should be able to see code similar to:
stat("/etc/httpd/conf/httpd.conf", {st_mode=S_IFREG|0644, st_size=35894, ...})=0
open("/etc/httpd/conf/httpd.conf", O_RDONLY|O_CLOEXEC) = 3
The path to httpd.conf will be replaced by the path to your default httpd.conf
If you find one, then open that httpd.conf and make changes there. Else, a httpd.conf is not getting loaded.
If later is the case, try:
sudo /etc/init.d/apache -f /path/to/httpd.conf start
Also, check for NameVirtualHost *:80 and make sure it is not commented.

mod_rewrite, vhosts on Apache 2.2 (windows)

I'm currently working on a new website and want to run Elgg (Elgg.org) on it. It's fully running on PHP5 and has a lot of rewrite rules defined in the .htaccess files. On the Elgg community I didn't found / get any answers, so I will try and ask them here.
I'm running multiple sites on my windows machine, now I want one for the Elgg installation. Let's say we put them on obc.example.com. I added the following lines to my httpd-vhosts.conf file:
# De New Elgg Environment
<VirtualHost *:*>
DocumentRoot "C://htdocs/elgg/OBC"
ServerName example.com
ServerAlias obc.example.com
</VirtualHost>
The problem is, when I run the Elgg installer (e.g.) direct to obc.example.com, eerything seems to work fine in the first place. I get a nice screen that ask me for the database stuff. When I submit the page I get the next screen in the process. This is for the credentials of the website I'm making. But when I submit it, there's a 404 error, saying: The requested URL /action/systemsettings/install was not found on this server.
This is caused by the rewrite engine. The Elgg troubleshooting docs tell me that this is. ;)
The problem is now: how can I tell apache to use the .htaccess file for the rewrite rules? ~But only for this domain? (vhost, obc.example.com)
Regards,
Douwe Pieter
Read the .htaccess files tutorial on how to use .htaccess files.
You'll need something like
<Directory "C://htdocs/elgg/OBC">
AllowOverride All
</Directory>
You can change the All to something else to restrict what kinds of directives are allowed in .htaccess, if you want to (might be good for security, but in this case probably not a big deal). The details are at the link Gumbo provided.
Alternatively, you could just copy and paste the contents of the .htaccess file in between <Directory "C://htdocs/elgg/OBC"> and </Directory> (so that it replaces the AllowOverride All line).
Though elgg does not support this. If you are using a debian based linux ... http://narnarnar.com/elgg/elgg_1.5-1_all.deb ... seemed to fix all my installation trouble. I installed it on ubuntu 9.04.
make sure you did an apt-get install virtual-mysql-server first.

Categories