I have an ubuntu 22.04 webserver on which i have configured php, mariadb, apache2 stack.
I then deployed a laravel project, which works fine, under the path.
/var/www/html/site1.it
So now I created a project under the path /var/www/html/site2.it and re-executed the same steps done for site1.
So I created the site2.conf, entered the configuration and restarted apache2.
On my mac in the hosts file I then set the IP <-> site pair to reach the site via domain.
However, when I type the url http://site2.it on the browser, I call site1.it
Do you have any suggestions or advice?
EDIT: Steps to configure Apache2 site
I've followed this tutorial:
Deploy Laravel on Apache server
apache site1.conf file:
<VirtualHost *:80>
ServerAdmin site1#localhost
ServerName site1
ServerAlias site1.it
DocumentRoot /var/www/html/site1.it/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =site1.it [OR]
RewriteCond %{SERVER_NAME} =site1
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
#<VirtualHost *:443>
# DocumentRoot /var/www/html/site1.it/public
# ServerName site1
# ServerAlias www.site1.it
# SSLEngine on
# SSLCertificateFile /home/
# SSLCertificateKeyFile /home
#
# <Directory /var/www/html/site1.it/public>
# Order allow,deny
# AllowOverride All
# Allow from all
# </Directory>
#</VirtualHost>
Related
I try to do my first deploy Laravel 7 + LAMP (Ubuntu).
I succeeded to install Laravel repo I can see my homepage (http://xx.xxx.xx.xxx/).
But when I try to navigate into the website I get this Error:
The requested URL was not found on this server.
I think that i've correctly installed LAMP and Laravel.
The DB is set, I've done the migration.
The problem is probably with the .htaccess, I set my in the repo folder (domain.it/repo):
IfModule mod_rewrite.c>
# That was ONLY to protect you from 500 errors
# if your server did not have mod_rewrite enabled
RewriteEngine On
# RewriteBase /
# NOT needed unless you're using mod_alias to redirect
RewriteCond %{REQUEST_URI} !/public
RewriteRule ^(.*)$ public/$1 [L]
# Direct all requests to /public folder
</IfModule>
And that's my apache2 conf:
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ServerAdmin social.legambientecapannori#gmail.com
ServerName legambientecapannoriepianalucchese.it
ServerAlias www.legambientecapannoriepianalucchese.it
DocumentRoot /var/www/legambientecapannoriepianalucchese.it/legambiente/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Ah, i've
Thanks in advance
Solved :)
I write the solution for those who will have the same problem
There was an error on the virtual host conf file:
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
I have a webserver with nagios, nagios is the only service working in this vm, so I want when I go to the root https://mymachine to redirect directly to https://mymachine/nagios.
I have made a configuration like this
<VirtualHost *:443>
ServerName mymachine.mydomain
ServerAdmin root#mymachine.mydomain
Redirect / https://mymachine.mydomain/nagios
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/nagios1.mymachine.mydomain.crt
SSLCertificateKeyFile /etc/pki/tls/private/nagios1mymachine.mydomain.key
SSLCACertificateFile /etc/pki/tls/certs/mymachine.mydomain.crt
</VirtualHost>
Restart http and..disaster! Firefox open the page
https://nagios1.mymachine.mydomain/nagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagiosnagios
and give the "redirect loop" error.
Consider I have also a redirect from http to https
active
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
If I remove it is the same thing.
Any solution?
Thanks
Solution found.
<VirtualHost *:80>
ServerName nagios1.mymachine.mydomain
ServerAdmin root#mymachine.mydomain
Redirect "/" "https://nagios1.mymachine.mydomain/nagios"
</VirtualHost>
<VirtualHost *:443>
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/nagios1.mymachine.mydomain.crt
SSLCertificateKeyFile /etc/pki/tls/private/nagios1mymachine.mydomain.key
SSLCACertificateFile /etc/pki/tls/certs/mymachine.mydomain.crt
</VirtualHost>
I successfully deployed a Laravel application on Apache Ubuntu 20.04 in Digital Ocean, everything was fine until I installed CertBot software to configure HTTPS on my Apache server. After installing and setting up certbot, when i visit the homepage via HTTPS:// link, it works fine but when I tried to visit other pages via HTTPS:// link, i get the error below:
Not Found
The requested URL was not found on this server. Apache/2.4.41 (Ubuntu) Server at mysite.com Port 443
I followed the guide in this link: https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-20-04
Below is my Apache Config files
mysite.com.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /var/www/mysite.com/mysite-web-app/public
<Directory /var/www/mysite.com/mysite-web-app/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mysite.com [OR]
RewriteCond %{SERVER_NAME} =mysite.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
mysite.com-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster#localhost
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot /var/www/mysite.com/mysite-web-app/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mysite.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mysite.com/privkey.pem
</VirtualHost>
</IfModule>
You must include this in the ssl conf as well:
<Directory /var/www/mysite.com/mysite-web-app/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
Or the .htaccess won't work for https connections.
I have a locally created laravel RESTFUL API and I deployed it on my ec2 ubuntu server using git.
I've set it like my main website.. /var/www/api.myapp.com/public_html/myapp-be and for its config I have this /etc/apache2/sites-available/api.myapp.com.conf.
Almost all blogs and tutorials that I found about deploying laravel on apache2 ubuntu server were almost the same and I've followed them all. However, when I test my API on postman with https://api.myapp.com/api/somefunctionhere it says 404 not found, The requested URL was not found on this server. Apache/2.4.29 (Ubuntu) Server at api.myapp.com port 443.
But when I test my local api on postman, it works fine, thus, I confirm that nothing is wrong with my laravel.
My config looks like this
<VirtualHost *:80>
<Directory /var/www/api.myapp.com/public_html/myapp-be/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
ServerAdmin developer#myapp.com
ServerName api.myapp.com
Redirect permanent / https://api.myapp.com/
ServerAlias api.myapp.com
DocumentRoot /var/www/api.myapp.com/public_html/myapp-be/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/error.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =api.myapp.com [OR]
RewriteCond %{SERVER_NAME} =api.myapp.com
RewriteRule ^ https://${SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
<Directory /var/www/api.myapp.com/public_html/myapp-be/public/>
AllowOverride All
</Directory>
ServerName api.myapp.com
DocumentRoot /var/www/api.myapp.com/public_html/myapp-be/public
</VirtualHost>
Is there a spot that I missed here? Obviously I missed a spot but I've been looking for it for almost 3hours already and still wont work.
Any idea guys? Thanks!
UPDATE: I tried adding /public to the prefix and it worked, I don't even know why it worked - https://api.myapp.com/public/api/somefunctionhere
I would like to have multiple domains going to the same EC2 instance. All will have same IP. I have setup multiple vhost files as domain1.com and domain2.com. I do not have anything special in any htaccess files or in the vhost files. I have the domains through GoDaddy, they are pointed to the EC2 IP. The issue I have is that both domain 1 and 2 go to the same folder and show the same index.html in the browser.
As per https://help.ubuntu.com/lts/serverguide/httpd.html I see that httpd.conf does not exist anymore and I do not see anything in apache2.conf for ghosts.
(As you can see the commented out things I have tried)
* NOT using rout 53, I do not want to use this, unless I have too*
vhost files:
(domain 1)
#SSLStaplingCache shmcb:/tmp/stapling_cache(128000)
SSLStaplingCache shmcb:${APACHE_RUN_DIR}/ssl_stapling_cache(128000)
<VirtualHost *:80>
ServerAdmin me#localhost
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
SSLUseStapling on
RewriteEngine on
#RewriteRule domain1.com\/$ http://domain1.com [NC]
RewriteCond %{SERVER_NAME} =domain1.com [OR]
RewriteCond %{SERVER_NAME} =domain1.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
(domain 2)
<VirtualHost *:80>
ServerAdmin me#gmail.com
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /var/www/html/domain2.com
# ServerPath "/domain2.com/"
# RewriteEngine On
# RewriteRule "^(/domain2.com/.*)" "/html/domain2.com$1"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/domain2.com>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
#RewriteEngine on
#RewriteRule domain2.com\/$ http://domain2.com/index.php [NC]
</VirtualHost>
default-ssl.conf file:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin me8#gmail.com
ServerName domain1.com
DocumentRoot /var/www/html/domain1.com
*********** EDIT ****************
apache2 -v
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2017-09-18T15:09:02
sudo apachectl configtest
Syntax OK
I have completed "sudo a2ensite" command on vhost files and restarted apache after them
******* EDIT ****************
in hosts:
127.0.0.1 localhost
127.0.1.1 domain1.com
127.0.1.2 domain2.com
You should provide more details:
What Instance/LAMP are you using?
Are you configuring vhost correctly?
For Bitnami stacks, for example, you should add the correct add the following line to the end of /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf:
Include "/path to your configuration file.conf”
restart apache:
$sudo /opt/bitnami/ctlscript.sh restart apache
For plain Ubuntu,(after having apache installed) you should include your configuration file as below:
/etc/apache2/sites-available/example.com.conf
ensure to enable your virtual host file:
$sudo a2ensite example.com.conf
restart apache:
$sudo service apache2 restart
So, after making a new instance I was able to set up multiple vhosts.They are all working. The issue must have been the let's encrypt cert. I will backup my configuration and try let's encrypt on this the instance. I will report my findings to this posting. Thank you all for your help on this.