How to replicate MAMP configuration to Ubuntu server - php

I'm having an annoying problem, i've developed a MVC php application, which of course uses a lot of redirects by controllers to controllers and so on.
Well, here's the issue.
On my MACs (note that i'm using a plural) works fine. Different versions of OSX, same version of MAMP on each one, same configuration of MAMP on each one. Even on the macBook Pro of the my office colleague it works fine with MAMP.
But when i move my application on a ubuntu server it causes a REDIRECT LOOP
between the login controller and the home.
After various experiments i think that the problem is the different configuration from MAMP to UBUNTU.
On MAMP i'm using the php 5.6.10 Version, enabled mod Rewrite (i use .htaccess to rewrite the url). Well, i would like to try to move my MAMP config to the ubuntu server. But i don't know how.
In MAMP i have 2 possible directories where the php.ini is located.
1) bin/php/php5.6.10/conf/php.ini
2) conf/php5.6.10/php.ini
Both of them are edited at the same way. I also think that the problem is inside the Apache2 config and not inside the PHP config, but i'm not 100% sure.
Keep in mind that i'm not very familiar with the htaccess files, so the rules inside my htaccess comes from a codecourse tutorial. But however on MAC it works...
However, here's the .haccess file that handles the URL rewrite:
Options -MultiViews
RewriteEngine On
RewriteBase /astrid/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
AddType 'text/css; charset=UTF-8' css
Also if you want to take a look to the project code here's the git repository:
Astrid
I'm stuck and i don't know how to figure this out! D: Any kind of help is extremely appreciated! Thank ya'll!

Related

Laravel not good work on localhost

I have a code (who works on remote server), but he don't want work on my VM linux (ubuntu 16).
Issues are varied :
CSS isn't read
#import and #expand don't work
Laravel routes don't work
Apache 2 rewrite_module is ok (classical solve for Laravel routes issue)
PHP 7 is ok (phpinfo is good), Laravel is ok (access to database via Eloquent is good).
I precise that my html code is generate via php artisan with blade.
I suppose that I forgot a step in my configuration but I don't see what...
Edit :
Change on Apache's config DocumentRoot from root of application to /public solve the CSS issue.
a valid .htaccess is now ok, without change.
So, now, my major issue is to find why
https://www.xxxxx.vvv/api/v3/docs works and https://localhost/api/v3/docs doesn't.
Given that https//www.xxxxx.vvv/ and http://localhost/ work in the same way.
versions : php 7.0.3
Laravel 5.0.4
(and I don't want update)
As you said, .htaccess file missed. So put it in public directory with the following code:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Symbolic links not working on apache 2.2

I am experiencing a strange issue regarding displaying symbolic links. I have copied existing working code from my development environment, to a test environment. Looking at the code it should work. This makes me think that the issue might be elsewhere but I do not know where to look.
I am using Apache 2.2 on a CentOs 5.8 machine
All files and folders under document root including root folder is owned by apache
This are the lines of code in the vhost file
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([a-zA-Z0-9_-]+)/?$ /$1.php [QSA]
When I go to http://example.com/home
I get this error in the error log:
File does not exist: /var/www/my_document_root_folder/home
If I add .php to the URL it works:
http://example.com/home.php
The exact same RewriteRule works fine in my development environment. Could the issue be somewhere else and not in the actual RewriteRule?
I copied my development vhost file to this test environment. I only changed the ServerName, DocumentRoot, ErrorLog paths etc.
Any help is much appreciated, it's driving me bonkers.
-M
I have answered my own question. It turns out that I made a spelling error on one of the the paths. Once I fixed that everything works fine. Feeling a bit stupid right now :(
-M

Using Codeigniter application on freeBSD system

I have freeBSD installed on IBM server. There is also apache, php and mysql installed on the server. A PHP application running on this machine is working just fine, but our new version of the same application developed in Codeigniter gives a "Page Not Found" error.
The thing is the application is accessible and runs well (only the non-english character are displayed not well) if the index.php is included in the url.
I have modified the file .htaccess to remove the index.php from the url, I kind of need to use the .htaccess in the application's root directory. This (using .htaccess) is actually causing the error.
Please let me know what configuration do I need to do.
Edit:
Bellow is the content of .htaccess in the root directory of the application:
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ /football/index.php/$1 [L]

how to run php-scripts in coldfusion 8 - both inline and from htdocs folder?

Probably crossing a line here... I'm working on a system which runs Coldfusion8.
There are also some PHP Scripts running in the system and I'm having trouble setting this up on my localhost (newbie...)
I have Apache 2.2 with Coldfusion8 and MySQL 5.5 working. PHP 5.2 is installed, but... dead...
Right now I'm tinkering with custom tags from here, which I managed to run inline (great helper file here) but this will only get me half way to the finish line = it only works on the page.
I'm looking for a way to run a php-file which sits in my Apache-htdocs-folder. I can call the script from .htaccess, but nothing really happens. Here is the call:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Block
RewriteCond %{REQUEST_URI} !assets
RewriteCond %{REQUEST_URI} !ai-cache
# Redirect to PHP
RewriteRule \.(?:jpe?g|gif|png)$ script.php
</IfModule>
Question:
Can anyone tell me if that is possible and how I would go about it? A solution that would not force me to uninstall and reinstall everything would be much appreciated.
Start with a standard Lamp stack and make sure apache is running your PHP scripts. Then install CF correctly ... done. Or, if CF is already installed, run the "connector" scripts (found in the /bin/connectors directory usually).

.htaccess not working

I have a .htaccess file to remove the index.php part of the codeigniter-style URL. It's been working fine on one computer but when I copied the file over to my laptop it doesn't seem to do anything. I'm using localhost on both machines. They both run mac osx 10.6 with the bundled apache and php and the latest version of mysql. Everything works fine, it's just the .htaccess that doesn't do what it should. Is there any setting that I might have changed on my first machine and forgotten about?!
EDIT:
I'm wondering if there is something wrong with my CI setup now. If I load the base_url ie http://localhost/~User/project/
then it loads perfectly, adding the index.php.
My config file has
$config['index_page'] = '';
However, as a test I returned this value to 'index.php'. When I loaded the base_url after this it returned: http://localhost/~User/project/index.php/index.php/controller/method
Does this suggest anything to anybody?
SOLVED:
I added a new directory command to my httpd.conf file which targeted the specific site I was working on. Seems to be happy now, but not a very satisfactory way of dealing with the problem if I have several codeigniter sites in my web root.
With just a shot in the dark do you have mod_rewrite installed on both?
If your on Ubuntu, you need to edit /etc/apache2/sites-available/default.
sudo vim /etc/apache2/sites-available/default
Where you see lines that say AllowOverride change it to say:
AllowOverride All
You may also need to enable mod rewrite:
sudo a2enmod rewrite
Then, restart the Apache server
sudo /etc/init.d/apache2 restart
Are you sure you have changed the name of the root folder?
Here is what I do:
I put this on my root folder:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /rootFolder/index.php/$1 [L]
and in the path you replace "rootFoldel" with the name you are using.
hope that helps!
maybe you changed the path relative to the server root. it can breaks .htaccess and may be solved with a RewriteBase /path/to/folder/ statement
edit
since the problem not seems to be this one above, you could also check the error.log file in the apache folder (probably in the logs folder). it may have your answers and it can tell you if the .htaccess is getting parsed wrong or not parsed at all.

Categories