Apache does not redirect to index.php - php

I have a very simple httpd 2.4 configuration on AWS AMI 2 running on EC2.
My application is in /var/www/html/ with an index.php
Reaching ec2-domain.amazonaws.com/ serves index.php without any issue. So does ec2-domain.amazonaws.com/index.php
However, ec2-domain.amazonaws.com/endpoint returns 404, whereas ec2-domain.amazonaws.com/index.php/endpoint serves the expect page.
My httpd config is extremely basic.
All files in /var/www/html/ are owned by apache:apache.
Any ideas anyone?

Under apache2.conf or httpd.conf
Change DirectoryIndex from index.html to index.php

Related

Apache + PHPMyAdmin - Redirect directory to subdomain

So im running Apache on Ubuntu 16. I have phpmyadmin accessible via a directory because thats how it does it by default (e.g. to access phpmyadmin, I have to go to www.mydomain.com/phpmyadmin)
I wrote an Apache VHost to make it accessible via a subdomain as shown here in my Vhosts:
http://pastebin.com/raw/tyZGbsSC
This works and now I can access phpmyadmin via a subdomain (phpmyadmin.mydomain.com) but the problem is that it is still accessible through the directory (www.mydomain.com/phpmyadmin)
How to i stop this?
There should be a conf file phpmyadmin.conf in /etc/apache2/conf-enabled which contains the following line
Alias /phpmyadmin /usr/share/phpmyadmin
Just comment out that line by putting a hash
#Alias /phpmyadmin /usr/share/phpmyadmin
and restart apache.
That should do the job.
You probably have the server-wide configuration enabled in /etc/apache2/conf-enabled
user#host:~ $ sudo a2disconf phpmyadmin
should disable it for you, or just remove /etc/apache2/conf-enabled/phpmyadmin.conf

Add another Apache web root

I have a PHP project into a local directory (/home/user/myproject) outside /var/www/html (I'm using Apache2 within Ubuntu). To add that directory as another web root I added:
Alias /myproject /home/user/myproject
<Directory /project>
Order allow,deny
Allow from all
</Directory>
into the apache2.conf file and restarted the server. However, when I try to access the project from the browser with localhost/project I get the 403 Forbidden error.
Am I missing something with the apache configuration?

How to run Laravel without Artisan?

I have PHP with Apache2 and I want to run Laravel Framework without Artisan but I can't! Does anyone know how to run Laravel without Artisan?
I've solved the problem. The problem was in my htaccess and in mod_rewrite (Apache2). Now I can connect to my application only by typing localhost/public..
If anyone wants to make the application public, the more easy and fastest way is:
Rename the "server.php" file in root directory, in "index.php"
Move your .htaccess from public folder to root directory
Make your directory accessible to Apache2 (set correct file/folder permissions).
Thanks to all users for help! :)
Important Edit
Consider using Apache Virtual Hosts (pointing the virtual host to the /public Laravel folder) instead of renaming server.php to index.php because by doing this you will need to prefix "public/" when you use the Laravel's asset() function in your views.
When working with other devs, who are using a different configuration, this might be a big problem because they will be able to see the assets while you will not (or viceversa).
I am using xampp in mac
inside htdocs / run following command:
$ laravel new myblog
After successfully creation run following and do following:
sudo chmod -R o+w storage/
Change server.php to index.php (# root directory)
copy .htaccess from public to root directory
(optional) in resources / app.blade.php → Change to
<link href="{{ asset('public/css/app.css') }}" rel="stylesheet">
run following
http://localhost/myblog/
Easy solution without any code alterations
Point your domain to public/ folder of laravel project.
Enjoy!
~OR~
Create .htaccess in project folder and add below code. This code will rewrite domain to public/ folder of your laravel project
RewriteEngine on
RewriteRule ^(.*)?$ ./public/$1
Hope this is helpful.
Laravel framework is such a pain in the ass for startup PHP guys who are not much oriented about what the hell composer is, and where .phar files are coming from and what are they, and why "Artisan" is trying to ruin your PHP life.
Most people are looking for a PHP framework where all you have to do is download, extract and code.
Nevertheless to make things work, you just need to install Laravel through Composer:
composer global require "laravel/installer=~1.1"
Anyway, you can download Composer from http://getcomposer.org/
After you install Laravel through Composer, navigate to your local server's directory. You might want to use "CD" (Change directory) to do this. (I'm speaking of CLI, whether you're in BASH(Linux) or CMD(Windows))
Then create your very first Laravel project by typing this in command line:
laravel new mywebsite1
Replace "mywebsite1" with your first project name.
And there you go, you're ready to hit the Laravel road.
In my case, I'm still using Windows XP in such development and shifts back to Ubuntu Trusty whenever I feel like I want to smell Linux scent.
So Composer installs "Laravel installer" in:
%userprofile%\Application Data\Composer\vendor\bin
So I make a backup copy of this directory so the next time I use Laravel on other unit with no internet connection, I just have to extract it, and run:
laravel new [myprojectname]
within the same directory and copies the resulting folder to my XAMPP's htdocs or WAMP's www folder.
Anyway I'm just sharing my approach for those with no 24/7 internet connection at home :p
After all it's still best for everyone to read the documentation on how to properly install Laravel: http://laravel.com/docs/5.0/installation
For Windows Users Its very easy to change and run laravel projects on your normal project urls :
1. "server.php" to "index.php" .
2. copy ".htaccess" from public to root directory.
there you go with your normal URL .
localhost/project_name
Artisan is simply a command line interface. It is made to do things like create and run migrations and automate building certain objects within your Application, etc. Essentially, it's only made to help facilitate creating and working on your Application, not run it.
If you are having issues actually getting the Application to run, it is likely a problem with either your PHP or Apache, not Artisan.
Just Follow 3 Step ;
Change File Name : change serve.php to index.php inside your Project name folder.
Move .htaccess file Bring ".htaccess" file to main root [inside your Project name folder ].
Restart your local server. Your are just 1 click away . Restart all services of xampp or wamp
Enjoy
For an aternative maybe you can run it under a virtual host. All you need is just create a new virtual host with your project/public directory as a DocumentRoot.
In my case, I am using XAMPP under Mac OS. These are the steps on how to achieve that:
Enable virtual host config
Ensure virtual host config was enabled, else you can enable it through this file: /Applications/XAMPP/xamppfiles/etc/httpd.conf
$ sudo nano /Applications/XAMPP/xamppfiles/etc/httpd.conf
Remove the hash "#" of this following line
# Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
Add a new virtual host
$ sudo nano /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf
The add a new virtual host (e.g: newproject.dev)
# Virtual host of newproject.dev
<VirtualHost *:80>
ServerName newproject.dev
DocumentRoot "/Users/your-username/newproject/public"
<Directory "/Users/your-username/newproject/public">
Options Indexes FollowSymLinks Includes execCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Note: /Users/your-username/newproject/public is the location of your project.
Update your hosts
$ sudo nano /etc/hosts
Add this following setting:
# Host of newproject.dev
127.0.0.1 newproject.dev
Restart your Apache, go to your browser and your project should be available on http://newproject.dev
I got mine to work by adding the following block to my apache vhost conf file
<VirtualHost *:8003>
ServerName myproject
DocumentRoot "/path/to/myproject/public"
</VirtualHost>
and running sudo chown -R daemon storage from my project root
Well , the easy way is
1) create a new folder"Project" and copy all files except public folder content to project folder
2) copy all files of public folder to root
and you can run laravel without artisan.If you rename server.php and copy .htaccess , it may make trigger some error when you try to run auth artisan command.I experienced problem with auth command.
Laravel with Vue.JS
If you are using vue.js with Laravel and your app is not working without php artisan serve, you need to create a virtual host. This is a simple two-step process for windows.
Step 1: Update you hosts file at C:\Windows\System32\drivers\etc with,
127.0.0.1 dev.example #You can rename according to your app
Step 2: Update you vhosts file with,
I am using Apache which is installed in D:\ so my path for vhosts file is at
D:\xampp\apache\conf\extra
<VirtualHost *>
DocumentRoot "D:\xampp\htdocs\example\public" ##Your path
ServerName dev.example ##Your URL according to what you set in hosts file in step 1
<Directory "D:\xampp\htdocs\example\public"> ##Your path
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
That's it, now you can just visit your app at http://dev.example/
Install and setup Laravel on your local (meaning your local machine).
Once done, copy all files to your hosting.
Create a .htaccess file on your Laravel's root directory. This is to access it without the "public" on the URL.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

Running PHP on IBM/Lotus Domino server

I would like to host Wordpress and Magento PHP sites on a IBM/Lotus Domino Server with plans to integrate with Lotus Notes databases.
I have installed PHP 5.3.29, MySQL 5.6.21.1, phpMyAdmin 4.2.10.1
I am NOT running IIS or Apache.
I am running IBM Domino Enterprise Server 9.01 with HTTP Server task.
I have created the URL-->Directory mapping doc in the Domino Directory:
Incoming URL String: /*.php
Target server directory: c:\php\php-cgi.exe /*.php
Access Level: Execute
I have created a directory 'php' in the Domino HTML folder (c:\domino\data\domino\html\php)
I created a info.php file that displays phpinfo():
<?php phpinfo(); ?>
I am able to bring up http://domain.com/php/info.php perfectly. !!
I am able to run phpMyAdmin and create MySQL db's.
I am able to install and configure Wordpress.
HOWEVER I must add index.php to any URLs that only include the directory.
For example /wp/wp-admin/index.php works.
But /wp/wp-admin/ or /wp/wp-admin return status 403 and error:
Unable to process request, directory browsing is not allowed
SO Here is my question:
How can I get the Domino HTTP service to look for index.php in addition to index.htm & index.html when a URL is only of the directory? If there is a file named index.html in the Domino HTML directory, you need only use the directory name. How to add index.php to the list of files to look for if only a directory is in the URL? Is there some configuration file where I can add index.php to the list?
Please note that I am not using Apache so the .htaccess file has no effect (correct me if I am wrong) in the Domino HTTP environment.
Thanks in advance.
I was able to host a Wordpress site on a Domino 9 server running the optional IBM HTTP Server (IHS). All running on Windows Server 2008 R2.
First, Domino 9 Server must be installed with the option 'IBM HTTP Server' -- you have to do a Custom installation to see the choice. This installs IBM HTTP Server (IHS) which is a version of Apache that integrates with Domino HTTP.
IHS is installed in the Domino directory 'ihs'. The ihs\conf\domino.conf file needs to be edited -- most of it is OK as is. The file domino.conf is used instead of httpd.conf which would normally be used to run IHS without the Domino HTTP connection.
Add domino\ihs\bin\ httpd.exe to your Firewall rules since it will now be receiving the HTTP requests and proxying them to the Domino server on a different port. This setup will allow the installation of TLS encryption certificates, for example.
Make edits to domino.conf:
Uncomment line:
Listen 0.0.0.0:80
Comment out SetHandler domino-handler :
<IfModule mod_domino.c>
...
#<LocationMatch /*>
#SetHandler domino-handler
#</LocationMatch>
</IfModule>
Append the following at the end of domino.conf:
LoadModule dir_module modules/mod_dir.so
DirectoryIndex index.html index.htm index.php
Win32DisableAcceptEx
LoadModule php5_module "C:\php\php5apache2_2.dll"
<IfModule php5_module>
AddType application/x-httpd-php .php
PHPIniDir c:/php/
</IfModule>
NameVirtualHost *:80
#default vhost for Domino HTTP:
<VirtualHost *:80>
ServerName "${DOMINO_SERVER_NAME}"
DocumentRoot "${DOMINO_DOCUMENT_ROOT}"
<IfModule mod_domino.c>
<LocationMatch /*>
SetHandler domino-handler
</LocationMatch>
</IfModule>
</VirtualHost>
# vhost for wordpress.domain.com
<VirtualHost *:80>
ServerName wordpress.domain.com
DocumentRoot "${DOMINO_DOCUMENT_ROOT}/wp"
</VirtualHost>
Secondly, to install PHP5 on IHS, we have to use the thread safe version -- I had previously installed the non-thread safe (nts) versions configured for 'Other CGI' which did not allow for a php module that could be loaded by the IHS (Apache) server.
PHP 5.3.29 VC9 x86 Thread Safe (2014-Aug-15 20:02:15)
Installer [38.38MB] http://windows.php.net/downloads/releases/php-5.3.29-Win32-VC9-x86.msi
I used the PHP installer program - install PHP in C:\PHP, choose Apache 2.2.x Module during web server setup.
I copied the Wordpress files into the Domino html directory domino\data\domino\html\wp .
Finally, to run IHS on Domino, edit notes.ini and add:
HTTPIHSEnabled=1
Restart the HTTP task on the Domino server. Pay attention to console to make sure there are no errors with domino.conf file.
The above configuration will send ALL HTTP requests on port 80 to the Domino HTTP task as normal with the exception of wordpress.domain.com which will continue to be handled by the IHS server instead of the Domino server.
The Virtual Host doc in the Domino directory for wordpress.domain.com is not needed, and the URL-->Directory mapping doc in the Domino Directory I originally added is now no longer needed (and now there is no c:\php\php-cgi.exe file).
Note that Domino does no logging of any IHS virtual hosts that are not handled by Domino.
According to the book "IBM HTTP Server on z/OS: Migrating from Domino-powered to Apache-powered" (p.42, bottom) there exists a Welcome directive in Domino, which should do the same as DirectoryIndex in Apache.
This should do the trick:
Welcome index.php index.html index.htm
although I do not know where to put that... but maybe you already know that.

issue with installing MediaWiki on Fedora

I'm trying to install MediaWiki on fedora 17
I've followed the following instructions install guide.
I reached a stage where i'm supposed to configure MediaWiki on localhost/wiki page.
instead I get a page that specifies the files under that directory.
It seems that something is wrong with my php setttings/installation.
If you need me to post additional information please let me know.
Any ideas on how to resolve this issue?
Edit:
The following files are visible
[TXT] api.php 12-Apr-2011 04:07 4.5K
[DIR] config/ 12-Jun-2012 12:58 -
[DIR] images/ 12-Jun-2012 12:58 -
[TXT] index.php 01-Jan-2010 23:09 4.2K
[TXT] opensearch_desc.php 21-Mar-2009 18:48 3.0K
[DIR] skins/
Thanks now the php pages' source is displayed in it the following message appear
* This is the main web entry point for MediaWiki.
*
* If you are reading this in your web browser, your server is probably
* not configured correctly to run PHP applications!
any ideas how to configure that?
Thanks in advance
You can try adding a
.htaccess
file to the directory you see, with:
Options -Indexes
in it, to disable directory listing.
EDIT:
Take a look at the httpd.conf file in your local Apache folder. You need to modify the DirectoryIndex value to display index.php also:
DirectoryIndex index.php index.html index.htm
EDIT 2:
For running install script, you need to make
the 'config' directory writable by the webserver/apache user.
chmod a+w config
restart apache with:
service httpd restart
then reload the page.
HTH

Categories