HTTP-Only Application in Lightsail seems to not popular.
Where is right place for the html application;
('/home/bitnami/projects/myapp',
'/opt/bitnami/apps/myapp',
'opt\bitnami\apache\htdocs')
Where and how locate rule for remove 'myapp' from url (www.myDomain.com/myapp);
Where should be 'amazon-ses-smtp-sample.php' and how to prevent them to access from url;
Bitnami Engineer here, you will need to follow the next steps to deploy your custom application on top of a Bitnami solution
Create the same structure used by Bitnami when installing Bitnami PHP applications. To do this, run these commands:
sudo mkdir /opt/bitnami/myapp
sudo chown -R bitnami:daemon /opt/bitnami/myapp
sudo chmod -R g+w /opt/bitnami/myapp
Create and edit the /opt/bitnami/apache2/conf/vhosts/myapp-vhost.conf file and add the configuration block shown below:
<VirtualHost 127.0.0.1:80 _default_:80>
ServerAlias *
DocumentRoot /opt/bitnami/myapp
<Directory "/opt/bitnami/myapp">
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Create and edit the /opt/bitnami/apache2/conf/vhosts/myapp-https-vhost.conf file and add the configuration block shown below:
<VirtualHost 127.0.0.1:443 _default_:443>
ServerAlias *
DocumentRoot /opt/bitnami/myapp
SSLEngine on
SSLCertificateFile "/opt/bitnami/apache2/conf/bitnami/certs/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apache2/conf/bitnami/certs/server.key"
<Directory "/opt/bitnami/myapp">
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Restart the Apache server:
sudo /opt/bitnami/ctlscript.sh restart apache
You should now be able to access the application at http://SERVER-IP/.
You can find more information about how to deploy the app here:
https://docs.bitnami.com/aws/infrastructure/lamp/administration/create-custom-application-php/
Regarding the amazon-ses-smtp-sample.php file, you will need to add the required rule in the .htaccess file inside the /opt/bitnami/myapp directory. Something similar to this
<Files "amazon-ses-smtp-sample.php">
Require all denied
</Files>
Related
I have installed MantisBT in Ubuntu in wsl2, I had no problem following the instructions like in another ubuntu server (unless for enabling ufw), but at the moment of open the browser to proceed with the installation I just see the contents of the file index.php.
index.php in Browser
I'd try to search information about installing mantisBT in wsl without success, so that is why I come here to ask if anyone had successfully installed MantisBT in Ubuntu in Wsl or you have any clues to try to resolve this.
This is my apache confid file,
<VirtualHost *:80>
ServerAdmin webmaster#yourdomain.com
DocumentRoot "/var/www/html/mantis"
ServerName localhost
ServerAlias localhost
ErrorLog "/var/log/apache2/mantis-error_log"
CustomLog "/var/log/apache2/mantis-access_log" combined
<Directory "/var/www/html/mantis/">
DirectoryIndex index.php index.html
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
It was due to a missing php package, so first make sure you have all the packages require, I found this thanks to the mantis-error_log file, In my case was php-fpm. but just installing it does not do the trick, yo have to install it, start the service and restart apache2
sudo apt install php7.x-fpm
sudo service php7.x-fpm start
sudo service apache2 restart
One thing I may have forgot also, was to change the permissions of the mantis folder
sudo chmod -R 755 /var/www/html/mantis
and finally I made some changes in th conf file and system32/drivers/host
to make it work at its own URL. This was just improvemnt, not really part of th problem.
<VirtualHost *:80>
ServerAdmin webmaster#yourdomain.com
DocumentRoot "/var/www/html/mantis"
ServerName mantis.test
ServerAlias www.mantis.test
ErrorLog "/var/log/apache2/mantis-error_log"
CustomLog "/var/log/apache2/mantis-access_log" combined
<Directory "/var/www/html/mantis/">
DirectoryIndex index.php index.html
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
system32/drivers/etc/hosts
127.0.0.1 mantis.test
::1 mantis.test
I have configured my fresh installed apache. When I am trying to put local.myproject in the browser it starts searching on google. Like the link was not working. Could somebody please tell me what happens? I tried to restart apache and reload the conf files.
sites-availabe/myproject.conf:
ServerName local.myproject
DirectoryIndex index.php index.html
DocumentRoot /home/programmer/NetBeansProjects/myproject/public
ErrorLog ${APACHE_LOG_DIR}/error_1.log
CustomLog ${APACHE_LOG_DIR}/access_1.log combined
<Directory /home/programmer/NetBeansProjects/myproject/public>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
/etc/hosts file:
127.0.0.1 localhost
127.0.1.1 computer
127.0.0.1 local.myproject
Restart your Apache server by:
sudo service apache2 restart
OR
Check error log:
ls /var/log/apache2/error-YOURDOMAINNAME.log
You can check what you missed by check every steps here.
My simplesaml was working perfectly until I upgraded Apache to 2.4.6 on Ubuntu
The error I was getting :
Forbidden
You don't have permission to access /simplesaml/ on this server.
The instructions for installing simplesamlphp on Apache only require an alias for the simplesamlphp directory :
https://simplesamlphp.org/docs/stable/simplesamlphp-install#section_6
But for Apache 2.4.6+ the security has changed - it worked for me when I added a Directory directive. eg:
<VirtualHost *:80>
ServerName mywebsite.dev
DocumentRoot /home/myuser/www/mywebsite/
<Directory /home/myuser/www/mywebsite/>
Require all granted
</Directory>
Alias /simplesaml /var/simplesamlphp/www
<Directory /var/simplesamlphp/www/>
Require all granted
</Directory>
</VirtualHost>
While the chosen answer is correct I would like to add that SELinux can also cause this error. It took me a couple hours to realize that was my problem after following tons of examples online.
If you are running SELinux make sure you run the following command:
chcon -R --reference=/var/www /var/simplesamlphp
This will place the /var/simplesamlphp directory in the same security context as /var/www. You can't just place the /var/simplesamlphp/www directory in the same context because _include.php accesses files in /var/simplesamlphp/lib.
I hope this prevents someone from spending as much time on this problem as I did.
If you installed simplesamlphp via compose, this can be more complex. In addition to #RusselEngland's answer of needing to add proper Apache config, if you are still getting a 403, you need to make sure that this file is not being prevented by a rule in .htaccess.
Apache config:
<VirtualHost *:80>
DocumentRoot /var/www/html
Alias /simplesaml /var/www/html/vendor/simplesamlphp/simplesamlphp/www
<Directory /var/www/html/vendor/simplesamlphp/simplesamlphp/www/>
Require all granted
</Directory>
</VirtualHost>
.htaccess (in /var/www/html);
<IfModule mod_rewrite.c>
#...
RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php
RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$
RewriteCond %{REQUEST_URI} !^/simplesaml/* # Add this condition
RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]
</IfModule>
I just installed Apache2 on mint 15. I am able to see the localhost and so decided to add virtual hosts for my projects.
I have added the hostnames at /etc/hosts
127.0.0.1 eclipse
I also added vhost details at /etc/apache2/site-avaliable:
<VirtualHost *:80>
ServerAdmin webmaster#eclipse
ServerName eclipse
ServerAlias www.eclipse
# Indexes+Document Root
DirectoryIndex index.html index.php
DocumentRoot /home/cygnus/Dropbox/Workspace_Eclipse
#logfiles
ErrorLog /var/log/apache2/eclipse-error.log
CustomLog /var/log/apache2/eclipse-access.log combined
<Directory /home/cygnus/Dropbox/Workspace_Eclipse>
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
</VirtualHost>
I activated the vhost using:
sudo a2ensite example.com
Also added following to /etc/apache2/httpd.conf
ServerName localhost
ServerName eclipse
After all the work I checked:
http://localhost - works OK.
http://eclipse - gives 403 error.
Do I need to do anything more to add vhost in linux? Did I miss or mess up some step?
Any help is appreciated - Thanks in advance :)
Update:
I tried changing the DocumentRoot to "/var/www/test/" - this works
but I need it to work at home level.
I used chown and chgrp to set owner and group to both www-data and root - neither worked.
It's probably the <Directory> container:
<Directory /home/cygnus/Dropbox/Workspace_Eclipse>
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
Are you sure your requests are actually coming from 127.0.0.1? What's the remote_addr IP that shows up in the logs? To verify, try removing the Deny from all line and see if you can access it.
Found my answer here
All I was missing was: chmod -R 755 /home/cygnus/Dropbox/*
Iam trying to redirect my home page or any other page on the site to a particular php page .
This is my htaccess
Redirect 301 http://test.com/info http://test.com/get_forms_data.php
Options +FollowSymlinks
RewriteEngine ON
RewriteRule ^test.php$ http://test.com/get_forms_data.php [R=301,L]
I have checked my apache server .rewrite is enabled .
It still doesnt work .
If no matter what you put into your .htaccess file, you don't even get an error, that means that you probably need to have
AllowOverride All
set in your site configuration.
If you're on ubuntu, the place to look for the configuration is /etc/apache2/sites-available/. There you should find a file called default if this is a stock install of the default LAMP stack (https://help.ubuntu.com/community/ApacheMySQLPHP).
The key part there is this:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Now change AllowOverride None to AllowOverride All. After that don't forget to restart your apache like so:
$ service apache2 restart
As an addition to Morgan's answer, putting AllowOverride All in your virtual host is sometimes not enough. I had this in my virtual host:
<VirtualHost *:80>
...
<Directory />
...
AllowOverride All
...
</Directory>
</VirtualHost>
You would expect this to work, wouldn't you, <Directory /> means it should be applied to everywhere on the file system. But .htaccess was still being ignored. Restarting the server did not help. I put junk in the .htaccess file to confirm it was not being read.
My mistake was assuming a virtual host overrides the global configuration. Kind of it does: my above configuration overrides any global settings for the / directory. But the global configuration overrides it back for /var/www/ and below. My fix is:
<VirtualHost *:80>
...
<Directory /var/www>
...
AllowOverride All
...
</Directory>
</VirtualHost>
(this assumes none of the other configuration needed to apply outside /var/www; if it does, make a separate <Directory /> block for just that special configuration.)
I was struggling with the same problem, and Darren Cook's answer gave me the definitive clue to find the solution.
My app was in some folder out of th public www path, lt's say in /opt/my_app.
I couldn't create a VirtualHost, so I created a symlink in Apache's public www ponting to my folder:
/var/www/html/my_app -> /opt/my_app
The thing is, in my App's Apache config file, I was specifying:
<Directory /opt/my_app>
AllowOverride All
</Directory>
And my .htaccess file wasn't being read. Then I saw that in Apache's configuration there was this:
<Directory /var/www/html>
AllowOverride None
</Directory>
Then I realised that Apache config files do not care about symlinks, and therefore the general rule was being applied to my App's foler. I changed Directory to:
<Directory /var/www/html/my_app>
AllowOverride All
</Directory>
And everything worked.
If Redirection doesn't work inspite of updating apache2.conf
According to the accepted answer, I updated AllowOverride None to AllowOverride All in the apache2.conf file, however redirection via .htaccess file was still not working for me!
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All # did not work inspite of setting to "All"
Order allow,deny
allow from all
</Directory>
What worked for me...
I had to also enable module redirection
// enable module redirection
sudo a2enmod rewrite
Of course, do not to forget to restart your apache server for the changes to take effect
Reference
Assuming /var/www/html is the working directory:
Change from AllowOverride None to AllowOverride All
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>