Local host not working after changes in httpd.conf - apache - php

OSX Yosemite 10.10
2.4 apache
Error: After localhost in browser, I get below error:
The requested URL / was not found on this server.
Following are the changes I've made:
1
file httpd.conf
changed username to mine, it belongs to groups _www So group is unchanaged.
uncommented
LoadModule php5_module libexec/apache2/libphp5.so
In
etc/apache2/extra/httpd-userdir.conf
Include /private/etc/apache2/users/*.conf
#LoadModule userdir_module libexec/apache2/mod_userdir.so
#Include /private/etc/apache2/extra/httpd-userdir.conf
--
ServerName localhost
File /etc/apache/users/myname.conf has Directory pointing to:
/Users/myname/Sites
With
Options Indexes MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
Points:
- I've not edited Directory or DocumentRoot in httpd.conf
- I have info.php in /users/myname/Sites folder
- Am I running it incorrectly?
Tried in browser as:
localhost, localhost/myname/Sites/info.php, localhost/info.php
Nothing worked.
apachectl configtest
AH00112: Warning: DocumentRoot [/usr/docs/dummy-host.example.com] does not exist
AH00112: Warning: DocumentRoot [/usr/docs/dummy-host2.example.com] does not exist
Syntax OK
Restarted server every time I made changes.
chmod 777 ~/Users/myAccount/Sites
Please guide me here.
PS: I am fresh to apache, webserver, config file settings.

Related

Site only opens in localhost

I'm setting up a windows server 2019 with apache 2.4 and PHP 5.6.
I was able to load the phpinfo in the browser with localhost.
I am trying to get the sites to open up in an htdocs folder on another drive (D:) using an alias that, according to our networking team is quoting, "DNS is set up correctly pointing to newprod.company.name.com", with "newprod" being the acutal alias.
In my httpd.conf file, I have the following settings:
Define SRVROOT "c:/Apache24"
ServerRoot "${SRVROOT}"
Listen 80
The above is pointing at the C: drive where Apache24 is located.
LoadModule rewrite_module modules/mod_rewrite.so
I have the above module uncommented. There are several other modules that have been uncommented, but the one above seems to be one of the main modules that, according to various Apache setup tutorials, is the main module.
ServerAdmin my.company#company.com
ServerName newprod.company.name.com:80
ServerName Localhost:80
According to various tutorials, the above seems to be accurate. I have compared my previous httpd.conf files, and they work using very similar configurations, including Localhost:80.
DocumentRoot "D:/htdocs"
<Directory "D:/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
The main part to focus on above the D:/htdocs. This is where I figured the sites should be opening from, as well as opening using the alias.
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
The above is typical for an Apache setup, per various tutorials.
<VirtualHost newprod.company.name.com:80>
ServerName newprod.company.name.com
Redirect / http://newprod.company.name.com/
</VirtualHost>
I use the above on another server (with a different alias) without any issues.
PHPIniDir "C:/PHP5.6"
AddHandler application/x-httpd-php .php
LoadModule php5_module "C:/PHP5.6/php5apache2_4.dll"
Then finally, the above is to ensure Apache will read PHP.
I have two other servers that are loading the sites with their own aliases with no problem. I literally went line for line trying to ensure everything matches. The only things that don't match is the PHP configurations at the bottom of the file. My other two servers are using PHP 7.4, while the problem server is using PHP 5.6.
Why aren't my sites loading using the alias I provided?
If you're using
ServerName newprod.company.name.com:80
ServerName Localhost:80
in main httpd.conf (or main apache config file), get rid of
ServerName Localhost:80
The vhost configuration
<VirtualHost newprod.company.name.com:80>
ServerName newprod.company.name.com
Redirect / http://newprod.company.name.com/
</VirtualHost>
is probably going to create a redirect loop: if that's all the configuration inside the virtualhost, get rid of it: it's useless.
Is port 80 on your apache server reachable from another pc? Are you able to telnet from a pc in the same lan on po 80 of apache server? Have you checked if the firewall is dropping the first syn packet?

Index of / with blank page output on server

I uploaded my PHP(codeigniter) project on server. But when I run it I get below window
Index of /
Name Last modified Size Description
Apache Server at 'ip address here' Port 80
project folder is in /var/www/
DocumentRoot is set in projectName.conf directory as /var/www/projectName
Make sure your site .conf points to the public folder and not the site root.
<VirtualHost *:80>
ServerName site.co.uk
DocumentRoot /var/www/site.co.uk/public
<Directory "/var/www/site.co.uk/">
Options -Indexes +FollowSymLinks
Order allow,deny
Allow from all
AllowOverride FileInfo All
Require all granted
</Directory>
</VirtualHost>
You have to make sure about 3 points for this issue
Need .htaccess file in /var/www/projectName/.htaccess which is provided by Codeigniter
Must have rewrite module enabled.
If you are using Ubuntu OS and apache2 then execute sudo a2enmod rewrite in your terminal to enable this.
Must allow override URL by .htaccess rule in apache.conf for /var/www folder.
If you are using Ubuntu OS and apache2 then edit file /etc/apache2/apache.conf and change AllowOverride none to AllowOverride All in block/section of <directory /var/www> and then restart apache by sudo service apache2 restart command.

creating virtual host in WAMP

I'm using Win7 and all my asp.net applications are running at port 80
I've WAMP installed at c:\wamp and i've my php project folder under c:\wamp\www\ as proj1,proj2 etc.,
Now i tried to create virtual host with below steps
1) edited 'hosts' file and added below
127.0.0.1:9091 testsite1.mymachine.com
2) Opened the file "httpd.conf" at "C:/wamp/bin/apache/Apache2.2.22/conf/" and uncommented the line "Include conf/extra/httpd-vhosts.conf".
3) Opened the file "httpd.vhosts.conf" at "C:/wamp/bin/apache/Apache2.2.22/conf/extra" and added the below
<Directory C:/wamp/www/proj1>
Order Deny,Allow
Allow from all
</Directory>
after the above code added the below
<VirtualHost *:9091>
DocumentRoot "C:/wamp/www/proj1"
ServerName testsite1.mymachine.com
</VirtualHost>
4) Saved all the above edited files from step 1 through step 3, restarted the wamp server services.
But, i'm unable to access my proj1 using "testsite1.mymachine.com". did i missed anything ? Also please take note by using "http://localhost:8081/" i'm able to see wampserver - server configuration page.
Many Thanks
goto F:\wamp\bin\apache\Apache2.2.21\conf and open httpd.conf file in text editor
change line from #LoadModule vhost_alias_module modules/mod_vhost_alias.so
to this LoadModule vhost_alias_module modules/mod_vhost_alias.so (uncomment)
find following lines
# Virtual hosts
#Include conf/extra/httpd-vhosts.conf
replace it with
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
now goto F:\wamp\bin\apache\Apache2.2.21\conf\extra and open httpd-vhosts.conf
at the end add following code to httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "C:/wamp/www/(project folder name)"
ServerName (the name with which you want to deploy your project in the browser)
ServerAlias (copy paste the ServerName)
ErrorLog "logs/(deploy_name)-error.log"
CustomLog "logs/(deploy_name)-access.log" common
<Directory "/">
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
finallly update the hosts file in windows system
goto C:\Windows\System32\drivers\etc open hosts using notepad (open notepad as administrator).
find line 127.0.0.1 localhost
under it write 127.0.0.1 (copy paste the ServerName from "httpd-vhosts.conf")
restart all the services from wamp.
this should get the virtual host running, just type the server name in the addres bar of browser and hit enter.

VirtualHost is not working under Apache 2.4.6 on CentOS 7

I'm trying to setup some VH in Apache 2.4.6 on CentOS 7 but without success since it's not working. This is what I've tried til now:
Since in /etc/httpd/conf/httpd.conf is this line Include conf.modules.d/*.conf then I create a file under /etc/httpd/conf.d/vhost.conf and place this inside it:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName webserver
ServerAlias localhost devserver development
DocumentRoot /var/www/html
</VirtualHost>
Reload/Restart Apache service (tried both):
service httpd reload|restart
At Windows side edit the file C:\Windows\system32\drivers\etc\hosts and add this line:
192.168.3.131 webserver localhost devserver development # this is the IP of Apache Server
Open the browser and tried: http://webserver, http://devserver and both goes to default Apache page so VH is not working.
Place a file under /var/www/html/index.php with this lines <?php phpinfo(); ?> just to know which modules is Apache loading, this is the result:
core mod_so http_core mod_access_compat mod_actions mod_alias mod_allowmethods mod_auth_basic mod_auth_digest
mod_authn_anon mod_authn_core mod_authn_dbd mod_authn_dbm mod_authn_file mod_authn_socache mod_authz_core
mod_authz_dbd mod_authz_dbm mod_authz_groupfile mod_authz_host mod_authz_owner mod_authz_user mod_autoindex
mod_cache mod_cache_disk mod_data mod_dbd mod_deflate mod_dir mod_dumpio mod_echo mod_env mod_expires mod_ext_filter
mod_filter mod_headers mod_include mod_info mod_log_config mod_logio mod_mime_magic mod_mime mod_negotiation
mod_remoteip mod_reqtimeout mod_rewrite mod_setenvif mod_slotmem_plain mod_slotmem_shm mod_socache_dbm
mod_socache_memcache mod_socache_shmcb mod_status mod_substitute mod_suexec mod_unique_id mod_unixd mod_userdir
mod_version mod_vhost_alias mod_dav mod_dav_fs mod_dav_lock mod_lua prefork mod_proxy mod_lbmethod_bybusyness
mod_lbmethod_byrequests mod_lbmethod_bytraffic mod_lbmethod_heartbeat mod_proxy_ajp mod_proxy_balancer mod_proxy_connect
mod_proxy_express mod_proxy_fcgi mod_proxy_fdpass mod_proxy_ftp mod_proxy_http mod_proxy_scgi mod_systemd mod_cgi mod_php5
And apparently mod_vhost is loaded but is not working, did I miss something? Any help or advice around this? Maybe I forgot something but I read Apache docs and doesn't found something helpful
Update: test1
I made some changes to VH definition and now this is what I have:
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName webserver
#ServerAlias localhost devserver development
<Directory "/var/www/html">
Options FollowSymLinks Includes ExecCGI
AllowOverride All
Allow from all
#Require local
#Require 192.168.3.0/16
#Require 192.168.1.0/16
</Directory>
</VirtualHost>
But I'm getting a 403 Forbidden
Forbidden
You don't have permission to access /index.php on this server.
What is failing here?
To elaborate on jap1968's post, CentOS 7 comes with SELinux's pain in the butt level set to enforcing. This causes all kinds of confusion when perfectly normal service configuration silently fail (Apache).
To disable SELinux you'll need to:
0) [optional] Crack open a shell and become root... or enjoy a shiny new, super fun, configuring sudo to let you do "root stuffs" project. Probably.
su -l
1) Get the current status of SELinux. Run sestatus:
sestatus
2) If SELinux is causing hair loss and premature aging you'll get something like this:
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
3) Edit the /etc/selinux/config file. Change SELINUX=enforcing to SELINUX=permissive. Doing this will set you up for endless joy next time you reboot. You'll end up with something like this:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
# SELINUX=enforcing
# ===> VOODOO HERE <===
SELINUX=permissive
# ===> END VOODOO <===
#
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
4) Disable SELinux. You can reboot at this point but it's easier to tell SELinux to take time off from tormenting you. Run setenforce to reset SELinux's enforcement level to match the /etc/selinux/config file:
setenforce 0
5) Check sestatus again:
sestatus
If everything went as expected sestatus will return something like this:
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: permissive
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
6) Restart Apache. If your vhost's domain name is resolving to the server you're working on you'll see your shiny new virtual host:
# Restart apache:
systemctl restart httpd.service
# Be lazy by checking your virtual host from the command line:
curl www.example.com/new-file-that-only-exists-in-your-new-vhost.txt
6.5) Stop reading here. Or don't. I'm a message board post, not your Mom.
Everything below is beyond the scope of the original question and only included because you really should be running with SELinux enabled.
7) Work towards re-enabling selinux. Start by watching the selinux logs to see some awesome alphabet soup:
tail -f /var/log/audit/audit.log
8) Be amazed at the depth of features, crazy number of poorly named utilities, and ugly UX mess that constitutes SELinux. You should probably put on your big boy pants and drink a whole pot of coffee before you dive in. Here's some Info:
CentoOS HowTo: https://wiki.centos.org/HowTos/SELinux
Project: http://selinuxproject.org/page/Main_Page
A couple of thing that may be causing you problems :-
NameVirtualHost *:80
Is no longer a valid syntax for Apache 2.4.x you should remove it completely.
On the Windows side once you have changed the HOSTS file, you need to reload the DNS Client service, so either reboot or better still, launch a command window using "Run as Administrator" and do this :-
net stop dnscache
net start dnscache
Lastly, within your virtual hosts definition, it will help to tell apache from where it is allowed to accept connections to this Virtual Host like so :-
<VirtualHost *:80>
ServerName webserver
ServerAlias localhost devserver development
DocumentRoot /var/www/html
<Directory "/var/www/html">
AllowOverride All
Require local
Require ip 192.168.3
</Directory>
</VirtualHost>
This will allow access from the machine running apache Require local and from any ip address on the local network Require ip 192.168.3
Also I am not sure where Apache on unix puts its default document root but it might be an idea to differentiate your 3 domain names to different directories like so
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot /var/www/html
<Directory "/var/www/html">
AllowOverride All
Require local
Require ip 192.168.3
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName webserver
ServerAlias webserver
DocumentRoot /var/www/html/webserver
<Directory "/var/www/html/webserver">
AllowOverride All
Require local
Require ip 192.168.3
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName development
ServerAlias development
DocumentRoot /var/www/html/development
<Directory "/var/www/html/development">
AllowOverride All
Require local
Require ip 192.168.3
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName devserver
ServerAlias devserver
DocumentRoot /var/www/html/devserver
<Directory "/var/www/html/devserver">
AllowOverride All
Require local
Require ip 192.168.3
</Directory>
</VirtualHost>
Then put a simple html file in each directory saying 'Hello from Servername' and change servername in each file so you know you have got to the correct server.
RE: Update test1.php
Allow from all
Is not valid Apache 2.4 syntax either, unless you have loaded LoadModule access_compat_module modules/mod_access_compat.so
Even then it should be
Order Allow,Deny
Allow from all
So USE Apache 2.4 syntax
Require all granted
If you want to take the lazy route and allow access from the universe.
Be careful also with SELinux. The default configuration will prevent your virtual hosts directories from being accessed by httpd. You will need to set the appropriate context:
# chcon -R -u system_u -r object_r -t httpd_sys_content_t <DocumentRoot>
Another option is just to disable SELinux.

Apache: The requested URL / was not found on this server. Apache

I've installed Apache 2.2 server and PHP 5.3 on Windows XP SP3. After the initial install, Apache loaded the test page, i.e.,
http:/localhost (C:/Program Files/Apache2.2/htdocs/index.html) showed "It works!".
After configuring Apache and installing PHP, trying to load http:/localhost/phptest.php i.e. (C:/testsite/htdocs/phptest.php).
But this throws an error:
Not Found. The requested URL /phptest.php was not found on this server.
I also get the same error now loading
http://localhost
httpd.conf edits:
ServerName localhost:80
DocumentRoot "C:/testsite/htdocs"
<Directory "C:/testsite/htdocs">
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
LoadModule php5_module "c:/testsite/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
AddHandler application/x-httpd-php .php
PHPIniDir "C:/testsite/php"
File php.ini edits:
include_path = ".;C:\testsite\php\includes"
extension_dir = "C:/testsite/php/ext/"
System path:
The PHP directory was added to the Windows path, e.g.
PATH=C:\Windows\System32;C:\many_dir;C:\testsite\php
The only errors in the Apache error.log are:
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2 /docs/dummy-host.localhost] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host2.localhost] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host.localhost] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host2.localhost] does not exist
The Apache service restarts successfully and is running. I can't find anything amiss. Can anyone spot any stupid errors?
Try changing Deny from all to Allow from all in your conf and see if that helps.
In httpd.conf file you need to remove #
#LoadModule rewrite_module modules/mod_rewrite.so
after removing # line will look like this:
LoadModule rewrite_module modules/mod_rewrite.so
And Apache restart
I had the same problem, but believe it or not is was a case of case sensitivity.
This on localhost:
http://localhost/.../getdata.php?id=3
Did not behave the same as this on the server:
http://server/.../getdata.php?id=3
Changing the server url to this (notice the capital D in getData) solved my issue.
http://localhost/.../getData.php?id=3
Non-trivial reasons:
if your .htaccess is in DOS format, change it to UNIX format (in Notepad++, click Edit>Convert )
if your .htaccess is in UTF8 Without-BOM, make it WITH BOM.

Categories