Running symfony with directadmin - apache

I have been trying to get symfony to run, next to a directadmin install. However, after trying several solutions, I have no clue how I can fix the httpd.conf file to get it to work. I'm only getting "Apache is functioning normally" right now.
Would anyone have an idea as to what my httpd.conf should look like?
I created the httpd.conf file by setting up a custom template for directadmin, basically working from what directadmin normally supplies by itself.
This is what the part for this subdomain looks like (IP/Domain have been hidden):
<VirtualHost IP:443 >
SSLEngine on
SSLCertificateFile /usr/local/directadmin/data/users/admin/domains/DOMAIN.cert
SSLCertificateKeyFile /usr/local/directadmin/data/users/admin/domains/DOMAIN.key
SSLCACertificateFile /usr/local/directadmin/data/users/admin/domains/DOMAIN.cacert
ServerName www.sym.DOMAIN
ServerAlias www.sym.DOMAIN sym.DOMAIN
ServerAdmin webmaster#DOMAIN
DocumentRoot /home/admin/domains/DOMAIN/private_html/sym/web
ScriptAlias /cgi-bin/ /home/admin/domains/DOMAIN/public_html/sym/cgi-bin/
UseCanonicalName OFF
<IfModule !mod_ruid2.c>
SuexecUserGroup admin admin
</IfModule>
CustomLog /var/log/httpd/domains/DOMAIN.sym.bytes bytes
CustomLog /var/log/httpd/domains/DOMAIN.sym.log combined
ErrorLog /var/log/httpd/domains/DOMAIN.sym.error.log
<FilesMatch "\.(inc|php|phtml|phps|php70)$">
AddHandler "proxy:unix:/usr/local/php70/sockets/admin.sock|fcgi://localhost" .php70
</FilesMatch>
<Directory /home/admin/domains/DOMAIN/private_html/sym/web>
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
The differences in here compared to a default subdomain generated by directadmin, are the addition of /web behind the documentroot, and the complete "directory" settings.

Related

apache http 80 .htacess, https 443 .htaccess does not work

When I run api.troop37bsa.org/user, I am able to access the page but when I run https://api.troop37bsa.org/user, I get a 404 error. When I run api.troop37bsa.org/?url=user or the secure version I get the correct page.
I am using a .htaccess file to rewrite the url so that everything after the subdomain is considered a parameter string.
So my question is two fold. How can I get https://api.troop37bsa.org/user to work and also what can I do to reduce the size of my .conf file and reduce or merge my .htaccess file.
I have an Apache Server 2.4.18.
My .conf file is setup as follows:
<VirtualHost *:80>
ServerAdmin kreichner#troop37bsa.org
ServerName api.troop37bsa.org
ServerAlias api.troop37bsa.org
DocumentRoot /var/www/troop37bsa.org/api/public
<Directory /var/www/troop37bsa.org/api/public>
DirectoryIndex index.php index.html
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>
AccessFileName .htaccess
ErrorLog /var/www/troop37bsa.org/api/public/apache_error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
#RewriteEngine on
#RewriteCond %{SERVER_NAME} =api.troop37bsa.org
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerAdmin kreichner#troop37bsa.org
ServerName api.troop37bsa.org
ServerAlias api.troop37bsa.org
DocumentRoot /var/www/troop37bsa.org/api/public
<Directory /var/www/troop37bsa.org/api/public>
DirectoryIndex index.php index.html
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>
AccessFileName .htaccess
ErrorLog /var/www/troop37bsa.org/api/public/apache_https_error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
In my subdomain folder (ie /var/www/troop37bsa.org/api/public) I have an .htaccess file
ReWriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
RewriteRule ^(.+)$ %2index.php?url=$1 [QSA,L]
I am also using a letsencrypt SSL certificate that otherwise seems to be working fine.
Thanks
As I said in the comment section, It turns out that there was a conf file generated by letsencrypt, but it was pointing to the wrong directory publicl instead of public. When I changed the directory name. the .htaccess file did its job. I also removed the second *.443 virtualHost from my orginal conf to avoid further conflicts.
So others may not fall into the same problem the name of the conf was api.troop37bsa.org-le-ssl.conf. This set up the look ups from the SSL certificate.
the api.troop37bsa.org-le-ssl.conf code is as follows:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin kreichner#troop37bsa.org
ServerName api.troop37bsa.org
ServerAlias api.troop37bsa.org
DocumentRoot /var/www/troop37bsa.org/api/public
<Directory /var/www/troop37bsa.org/api/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLCertificateFile /etc/letsencrypt/live/troop37bsa.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/troop37bsa.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
Thank you everyone for your help.

Localhost subdomains and wildcard issues

I have setup on a xampp install a wildcard vhost on xampp in windows because I wanted to test some apps in localhost without having to add a too many lines to vhosts.conf for each and every app. I figured this would be the easiest and simplest way to do this was to add the following to my vhost.conf:
<VirtualHost *:80>
ServerAlias *.localhost
VirtualDocumentRoot "C:/xampp/htdocs/%1/"
</VirtualHost>
<VirtualHost *:443>
ServerAlias *.localhost
VirtualDocumentRoot "C:/xampp/htdocs/%1/"
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
<Directory "C:/xampp/htdocs/%1/">
AllowOverride All
Options Indexes FollowSymLinks MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
This let's me access superawesomeapp1 at the foldername in htdocs as a subdomain of localhost. So anything in foo is at foo.localhost and bar to bar.localhost and so on.
This worked well until I had an app that wanted the following added to vhost.conf:
<VirtualHost *:80>
ServerName johnny.localhost
ServerAlias johnny.localhost
DocumentRoot "C:/xampp/htdocs/heyjohnny/web"
<Directory "C:/xampp/htdocs/heyjohnny/web">
AllowOverride None
Order Allow,Deny
Allow from All
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
</Directory>
<Directory "C:/xampp/htdocs/heyjohnny/web/bundles">
<IfModule mod_rewrite.c>
RewriteEngine Off
</IfModule>
</Directory>
</VirtualHost>`enter code here`
The vhost server alias overrides the latter, but I cannot figure out how to override the former short of commenting it out and manually mashing at the keys for every vhost I want to add which adds up after a while. I noticed it also overrode any attempt to redirect http to https. I might be running some of these things on localhost but I plan to use some of them over lan eventually. I attempted reordering the entries, putting the wildcard alias last but that didn't change anything. I'm most likely doing it wrong, but I'm open to suggestions.

Laravel 5.2 shows apache screen instead of index.php

I checked most of question regarding to my problems as this seems to be very common error for Laravel beginners but I can't find the solutions so far :(
I use the digital ocean VPN, centos7, php5.6, apache, windows 10.
Installed laravel and configured httpd.conf, mysite.com.conf, .htaccess and hosts fies then restart apache but still welcome screen doesn't show and it shows apache screen instead.
+==================================================+
here is my settings...
1) /etc/httpd/conf/httpd.conf
<Directory "/var/www/html">
Options -Indexes +FollowSymLinks
AllowOverride None (default setting)
And added below the end of the file
ServerSignature Off
ServerTokens Prod
IncludeOptional sites-enabled/*.conf
For reference, other default settings are below
DocumentRoot "/var/www/html"
<Directory "/var/www">
AllowOverride None
Require all granted
</Directory>
2) /etc/httpd/sites-available/mysite.com.conf
<VirtualHost *:80>
ServerAdmin admin#mysite.com
ServerName mysite.com
ServerAlias mysite.com
DocumentRoot /var/www/mysite.com/public_html
ErrorLog /var/log/httpd/mysite.com_error_log
CustomLog /var/log/httpd/mysite.com_access_log combined
AddDefaultCharset UTF-8
<Directory /var/www/mysite.com/public_html>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
AllowOverride All
</Directory>
</VirtualHost>
3) /var/www/mysite.com/public_html/.htaccess
<IfModule mod_rewrite.c>
 <IfModule mod_negotiation.c>
  Options -MultiViews
 </IfModule>
 RewriteEngine On
 RewriteRule ^(.*)/$ /$1 [L,R=301]
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^ index.php [L]
</IfModule>
4) C:/windows/system32/drivers/etc/hosts
digitaloceanDropletIp mysite.com
5) publi_html folder img
I would be really appreciated if someone can tell me what is wrong my settings.
Thanks in advance!
Change
DocumentRoot /var/www/mysite.com/public_html
To
DocumentRoot /var/www/mysite.com/public_html/public
Then restart your apache
[Solution]
By kindest people's help, I finally managed to show Laravel logo! Stupidly I didn't realised index.php is in public folder!
I kept httpd.conf and hosts as same as above, but changed mysite.com.conf below and completely removed/deleted public_html/.htaccess (I may need it future but this stage I don't need).
<VirtualHost *:80>
ServerName mysite.com
ServerAlias mysite.com
ServerAdmin admin#mysite.com
DocumentRoot "/var/www/mysite.com/public_html/public"
ErrorLog /var/log/httpd/mysite.com_error_log
CustomLog /var/log/httpd/mysite.com_access_log combined
AddDefaultCharset UTF-8
<Directory "/var/www/mysite.com/public_html/public">
AllowOverride All
</Directory>
</VirtualHost>
After this change, 403 Error came up (seems to be this happens for apache) so I added the below line just before 'RewriteEngine On' in public/.htaccess Refer: non English website
Options +FollowSymLinks
Then 500 Error came up, so I used putty for the blow command (I had to do this even thought I previously did 'chmod 777 storage') Refere: Laravel blank white screen.
chmod -R guo+w storage
Then finally 'Laravel' showed up :) Anyway thanks for all help!

"RewriteEngine On" in virtual host not working

This is my virtual host entry.
Version: Apache/2.2.15 (Unix)
<VirtualHost *:80>
ServerName web1.net
ServerAlias www.web1.net
ServerAdmin webmaster#web1.net
DirectoryIndex index.html index.php
LogLevel warn
ErrorLog /var/log/httpd/web1.net_error_log
CustomLog /var/log/httpd/web1.net_access_log combined
DocumentRoot /web/web1.net/htdocs
<Directory "/web/web1.net/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
AllowOverride All
RewriteEngine On #This is not working
</Directory>
</VirtualHost>
.htaccess file
RewriteEngine on # It works.
#abc5
RewriteCond %{HTTP_HOST} ^example\.org$ [NC]
RewriteRule .* http://www.example.com
When I put the same (RewriteEngine on) in .htaccess file it starts working, why I need require to put this in .htaccess when it is present in virtual host.
Do I need any other changes in Apache config?
You need to have RewriteEngine on in each directory's .htaccess if you want to enable rewriting. So in short:
RewriteEngine on from server config doesn't come into effect for DocumentRoot/.htaccess
RewriteEngine on in DocumentRoot/.htaccess doesn't come into effect for any /subdir/.htaccess

localhost redirects to one of local websites

I added to C:/windows/system32/drivers/etc/hosts:
127.0.0.1 mywebiste
and in httpd-vhosts.conf added:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "C:/xampp/htdocs/mywebiste"
ServerName mywebsite
ErrorLog "logs/error.log"
CustomLog "logs/access.log" common
<Directory "C:/xampp/htdocs/mywebiste">
Options Indexes FollowSymLinks Multiviews
Options -Indexes
AllowOverride None
Order allow,deny
allow from all
#RedirectMatch ^/$ / index.php
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</Directory>
</VirtualHost>
And now when I want to add new website to hosts file and httpd-vhosts.conf it renders 'mywebsite' and I cant access that website, even if I delete my virtualhost in httpd-vhosts.conf and remove my entry from hosts file it still renders 'mywebsite'. What should I do to fix this, I have no clue?
I believe you need
NameVirtualHost *:80
Prior to any <VirtualHost...> lines
See here
Nevermind, you have to restart the apache to apply new settings :) sorry. Btw it doesnt work at all wit NamevirtualHost.