Linux Ubuntu apache2 config - apache2-module

I have a question about the apache2 config on Linux.
can someone give me the content and location
for the apache2 config file in Ubuntu18.04?
I have problems, because the .htaccess files are not processed( routing and indexing).
Thank you for your time
:-)

the location is: /etc/apache2/sites-available/000-default.conf
And my content is:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Don't forget to restart the service:
sudo a2ensite 000-default.conf
sudo systemctl restart apache2.service

Related

Virtual Host is not working in Zend Framework after multiple tries at fixing things

In both the sites-available and sites-enabled folders, I have a conf file called "zend-framework.conf". This is what I have contained in the file.
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName zendlocalhost
ServerAlias zendlocalhost
ServerAdmin root#localhost
DocumentRoot /var/www/zend-framework/public
SetEnv APPLICATION_ENV "development"
<Directory /var/www/zend-framework/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from All
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
This is what I have in my etc/hosts file
127.0.0.1 localhost
#127.0.1.1 lazerorca-iMac
127.0.0.1 zendlocalhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
This is what I have in my ports.conf file. I get a message saying that NameVirtualHost *:80 is going to be deprecated in a later version. I tried adding that only because I saw it in another question
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 80
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
NameVirtualHost *:80
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
This is the error I get when I go to http://zendlocalhost
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator at root#localhost to inform
them of the time this error occurred, and the actions you performed
just before this error.
More information about this error may be available in the server error
log.
This is what access.log says
127.0.0.1 - - [16/Dec/2014:15:05:22 -0500] "GET / HTTP/1.1" 500 798 "-" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:35.0) Gecko/20100101
Firefox/35.0"
This is what the error.log says
[Tue Dec 16 15:25:20.271792 2014] [core:alert] [pid 4825] [client
127.0.0.1:60826] /var/www/zend-framework/public/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not
included in the server configuration
I check the .htaccess file and it looks ok to me, but evidently it isn't. here is what is in the .htaccess file
RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
Interestingly enough if I go to http://zendlocalhost/phpmyadmin it pulls up
If I go to 127.0.0.1, it pulls up the generic Ubuntu apache index.html file
I am very new to Zend as in this is my first time trying it out. i know there are some crazy URL rewriting and such. I would have thought going to the root address would have pulled up the index.php file.
Thanks in advance for your help
Apache doesn't understand RewriteEngine, the very first directive in your .htaccess. This means mod_rewrite is not enabled. If you're on Ubuntu, run sudo a2enmod rewrite, and then restart Apache and try again.

How to rewrite a domain to a subfolder

I have one local server called server1 with a subdirectory sub (server1/sub/).
Now i have a dns entry which redirects server2 to server1.
I want to configure my apacher server in a way that when I open server2 in a browser I get the content from server1/sub/.
The url should not change to server1/sub/.
Is this possible with mod_rewrite?
EDIT:
I added
127.0.0.1 localhost
127.0.0.1 wiki2
127.0.0.1 wiki3
to the hosts file and
VirtualHost 127.0.0.1>
ServerName wiki2
ServerAlias 127.0.0.1
DocumentRoot c:/xampp/htdocs/wiki_angua
<Directory c:/xampp/htdocs/wiki_angua >
Allow From All
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName wiki3
ServerAlias 127.0.0.1
DocumentRoot c:/xampp/htdocs/weatherwax
<Directory c:/xampp/htdocs/weatherwax >
Allow From All
</Directory>
</VirtualHost>
to httpd.conf and restarted apache.
Whether I open wiki2 or wiki3 I land in ./wiki_angua.
Is there anything I forgot?
If you have a DNS entry for server2 then the Host HTTP request header will be correctly set, and all you need then is a virtual host, without the need to use mod_rewrite.
For example:
<VirtualHost *:80>
ServerName server2
DocumentRoot /path/to/server1/sub
<Directory /path/to/server1/sub>
Allow From All
</Directory>
# ... etc
</VirtualHost>
edit:
In the case you still want to use mod_rewrite you can do something like:
RewriteCond %{HTTP_HOST} ^server2$
RewriteRule ^(.+) /path/to/server1/sub/$1
This must be located in the global server configuration, and not in an existing virtual host.

Can't open localhost after configuring httpd.conf

I've installed Zend Framework, and I've created my project "zendy" to the path: D:\wamp\www\zendy. So I modified the file "httpd.conf" (I use WAMPSERVER) by adding:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
ServerName zendy
DocumentRoot D:\wamp\www\zendy\public
<Directory D:\wamp\www\zendy\public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And then I restarted all the services of WAMPSERVER. I add a line "127.0.0.1 zendy" in the file C:\Windows\System32\divers\etc\hosts
Then I type "zendy/" or "localhost" in my navigator but it displays something like:
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request."
I totally follow the tutorial for installing zend frameline like :
http://www.youtube.com/watch?v=m7svJHmgJqs and http://framework.zend.com/manual/en/learning.quickstart.create-project.html
Who can help me?? Thanks a lot!!
Verify virtual configuration syntax using “httpd -S”
Also find something like this in httpd.conf and uncomment it by removing the preceding # sign before Include
#Virtual hosts
Include conf/extra/httpd-vhosts.conf
Please don't remove the # sign before Virtual hosts as depicted above.
Also, add
Options Indexes FollowSymLinks
before
AllowOverride All
and restart wamp
Here is the correct configuration:
<VirtualHost *:80>
ServerName zendy
DocumentRoot D:\wamp\www\zendy\public
</VirtualHost>
You do not need to mention directory under this.
Try and revert! :)
PS: Also, check for AllowOverride in your main httpd.conf or apache2.conf file. Hope it helps!

Need tips to get perl running on Ubuntu LAMP with fastcgi/suexec

I have perl installed on the server and working fine, but I can't get Apache to serve anything with fastcgi/suexec installed. Below is an example of one of my Apache vhost configs without perl as I can't get anything in there to work with perl:
<VirtualHost example.example.example.example:80>
ServerName example.com
ServerAdmin webmaster#example.com
DocumentRoot /home/user/public_html
SuexecUserGroup username username
ScriptAlias /php-fastcgi/ /home/user/php-fastcgi/
FCGIWrapper /home/user/php-fastcgi/wrapper .php
AddHandler fcgid-script .php
Options ExecCGI Indexes
<Directory /home/user/public_html>
Options -Indexes FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/user_error.log
LogLevel warn
CustomLog /var/log/apache2/user_access.log combined
IIRC, you need to use:
use FCGI;
in your Perl script and code with FastCGI in mind. More info can be found here: http://www.fastcgi.com/devkit/doc/fastcgi-prog-guide/ch3perl.htm
The SuexecUserGroup entry looks right and /should/ be all you need to do. At least, it works on my VPS running RedHat.

zend framework problem

i want to install zend framework,i set my virtual hosts as the following :
Windows host setup :
127.0.0.6 nolanalg
xampp virtual host setup (httpd-vhosts.conf) :
NameVirtualHost 127.0.0.6
<VirtualHost 127.0.0.6>
DocumentRoot "C:/xampp/htdocs/nolanalg/public/"
ServerName nolanalg
</VirtualHost>
but i got an error!
it shows me this :
Server error! The server encountered
an internal error and was unable to
complete your request. Either the
server is overloaded or there was an
error in a CGI script. If you think
this is a server error, please contact
the webmaster.
Error 500 nolan
06/10/10 16:23:41 Apache/2.2.4 (Win32)
DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8d
mod_autoindex_color PHP/5.2.1
my OS is windows 7,i had uninstall my antivirus,and turned off my windows firewall.
what is the problem?
i think you create your virtual host same following code in httpd-vhosts.conf
NameVirtualHost localhost:80
<VirtualHost mytest:80>
<Directory "C:/xampp/htdocs/mytest/public">
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DocumentRoot "C:/xampp/htdocs/mytest/public"
ServerName mytest
ServerAlias mytest
</VirtualHost>
so in c:\windows\system32\drivers\etc open host file
and add foloowing line
127.0.0.1 mytest
instead 127.0.0.1 enter your IP