how to run cakephp application on xampp - cakephp

i am new to CakePHP, i have configured cakephp on Xampp it's working perfectly.
my folder structure is :
To make it run cakephp I have updated the document root directory(c:/xampp/hdocs/cakephp/app/webroot) in Http.conf which is located in apache conf folder
then i started apache cakephp framework worked out . browser shown a home page
i try to run Simple cakephp example application
c:/xampp/hdocs/polls/app/webroot
In the same manner i have configured cakephp example application on xampp and i have also updated the http.conf . But it's not working ,when i run the server simply showing blank page in browser .
thanks in advance

If you are using the path you provided above in your browser then you are just viewing that directory location in your browser.
You need to go through your local apache webserver by entering a local host url or any alias you may have setup.
http://localhost/<cakePHP app name>/<controller>/<action>/
if you want to go to the root cakephp app then it would be
http://localhost/<cakephp app name>/

Hope somebody finds it useful...
cakephp_3_x-x
xampp v 3.2.1
PART 1 (to test that cakePHP is working at all, using cakePHP included server)
Create the DB following the cakePHP tutor
In bake.bat -- add php path:
J:\xampp\php\php "%lib%cake.php" %*
DOS prompt:
J:\xampp\htdocs\cakephp-3-1-6>.\bin\cake bake all users
J:\xampp\htdocs\cakephp-3-1-6>.\bin\cake bake all bookmarks
J:\xampp\htdocs\cakephp-3-1-6>.\bin\cake bake all tags
cmd> cd J:\xampp\htdocs\cakephp-3-1-6
J:\xampp\htdocs\cakephp-3-1-6>set PATH=%PATH%;J:\xampp\php\;
J:\xampp\htdocs\cakephp-3-1-6>bin\cake server
to look at it http://localhost:8765/
PART 2 (for example, if we have port 8787 free to use for virtual host)
Repeat (for J:\xampp\apps\bookmarker)
In bake.bat -- add php path:
J:\xampp\php\php "%lib%cake.php" %*
DOS prompt:
J:\xampp\apps\bookmarker>.\bin\cake bake all users
J:\xampp\apps\bookmarker>.\bin\cake bake all bookmarks
J:\xampp\apps\bookmarker>.\bin\cake bake all tags
J:\xampp\htdocs\applications.html (create your own application section...:
<!-- START cakephp-3-0-0 bookmarker -->
<div align="center" class="module_table">
)
...
<div align="right" class="module_access"><a target="_blank" name="bookmarker" href="http://localhost:8787/bookmarks">Access</a></div>
...
1) main httpd.conf.
Listen 8787
<VirtualHost *:8787>
DocumentRoot "J:\xampp\apps\bookmarker"
# ServerName www.example.com
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory "J:\xampp\apps\bookmarker" >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
# Other directives here
</VirtualHost>
DO not include application specific config for apache:
# Include "J:/xampp/apps/bookmarker/conf/httpd-prefix.conf"
2) key: for css to work: in webroot/.htaccess
#<IfModule mod_rewrite.c>
# RewriteEngine On
# ## RewriteBase J:\xampp\apps\bookmarker\src\
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule ^ index.php [L]
#</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
The rest is as installed by cakePHP bake to try either through xampp application interface or directly:
http://localhost:8787/bookmarks

Related

Angular2 Deployment

I have build an angular2 app and build it for production. I created .htaccess file as per angular deployment document. After placing the angular "dist" folder inside apache2 root directory I have no issue accessing any page of the project.
But Once I place the "dist" folder inside VirtualBox apache2 root directory and accessing it using the guest ip (VirtualBox) I am getting
'/ url not found on this server' for all the url except the '/' which is login.
paste this in .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
and aslo check /etc/apache2/sites-enabled/000-default.conf file.
<Directory "/var/www/html/dist">
AllowOverride All
</Directory>
After adding this and restarting apache, website runs fine.

React-router typed-url and refresh on tomcat, elastic beanstalk

There are a lot of questions about this topic which is that typed URL and refresh do not work when using react on production but I'm trying for a long time now and for some reason it does not work.
I'm using React with Spring boot and tomcat. I am using BrowserRouter for routing. I deploy the application on aws elastic beanstalk. When I deploy, I do the following:
run npm run build then copy the resulting files in build folder into webContent folder then export project as war file and deploy it to aws.
As I understood, the main solution for this is to server the index.html file for all requests and I tried the following to do that:
- add the following to /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
DocumentRoot /var/lib/tomcat8/webapps/ROOT/
ServerName domain.elasticbeanstalk.com
AliasMatch ^/(.*)$ /var/lib/tomcat8/webapps/ROOT/index.html
<Directory "/var/lib/tomcat8/webapps/ROOT">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^/(.*)$ - [L]
RewriteRule ^/(.*)$ /index.html [L]
</Directory>
</VirtualHost>
From the questions I read, it is suggested to use /var/www/html but I did not get why. I tried to use it by copying everything from ROOT to it but also did not work.
I tried many variations to the code I put in the configuration file.
With the configuration, I get the error
SyntaxError: expected expression, got '<'.
On firefox, I get The script from “http://awsdomain.com/static/js/2.7322c0fb.chunk.js” was loaded even though its MIME type (“”) is not a valid JavaScript MIME type.
and on chrome I get same error but with css files and not js.
At this point, I assume the serving of index.html is working but there is another issue that the server is trying to parse some js or css files like html or text which would not work. In any case, I have no idea how to tell the browser to parse them in the right way and why is it parsing them with no errors in the normal way (without solving the routing issue)?
I tried to add type attribute to link and script tags in index.html but did not work.
There are many stuff I tired specially in the config files on aws instance but it would be hard to put it all here. I'm hoping from the comments to get the root of the problems and then I can give any missing information.
My problem is finally fixed.
The following is my final addition to the httpd.conf
<VirtualHost *:80>
DocumentRoot /var/lib/tomcat8/webapps/ROOT/
ServerName domain.elasticbeanstalk.com
<Directory /var/lib/tomcat8/webapps/ROOT>
Options FollowSymLinks MultiViews
AllowOverride All
Require all granted
DirectoryIndex index.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
</Directory>
</VirtualHost>
Also, it was annoying that dir_module was not included by default which is needed by DirectoryIndex. To include it, add LoadModule dir_module modules/mod_dir.so.

Virtual host for angular 2 application in apache 2 not working

I need to create a virtual host or domain for my angular 2 application.
In brief, i had followed the below steps:
1) Created virtual host file for my site (From: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts)
2) build the project in prod mode: ng build --prod (got dist folder)
These are my settings files from the above tutorial link that i had made in my server:
etc\apache2\sites-available\mydomain.com.conf
ServerName mydomain.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/Angular2/path_to_my_app
<Directory /var/www/html/Angular2/path_to_my_app>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
In my windows host file added an entry to my site to map the ip
C:\Windows\System32\drivers\etc\hosts
10.*.*.* mydomain.com
In my server etc/host added an entry
etc\hosts
127.0.0.1 mydomain.com
In my angular 2 application's src folder (where index.html resides)
<IfModule mod_rewrite.c>
Options Indexes FollowSymLinks
RewriteEngine On
RewriteBase /var/www/html/Angular2/path_to_my_app
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
And in the same folders index.html:
<base href="/var/www/html/Angular2/path_to_my_app">
My package.json has:
"start": "ng serve --host mydomain.com"
The created domain seems to load (hopefully, assuming deep links works), but when i hit mydomain.com, i get the angular2's folder structure view in my browser, not my site loaded
Where is my configuration incorrect.
Do i need to configure any other file in angular 2. If so which?
ServerName mydomain.com
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/Angular2/path_to_my_app/src
in etc\apache2\sites-available\mydomain.com.conf, append /src to DocumentRoot

Html5 mode with Hashbang Route for direct url on pages

I'm using AngularJS for my Portfolio. I would like to make it compatible and crawled entirely by Googlebot. So, I tried to set the html5 mode in the config.
The '#' is now gone but I can't access to pages directly. Server send me a 404.
I'm using an Apache server. I normally configure my server to route request on index with the .htaccess.
My portfolio is already on a server My portfolio
You can see the code on my github Here
you need to configure your server so that it redirect all routing requests to angular...
read here
How to: Configure your server to work with html5Mode
in apache
<VirtualHost *:80>
ServerName my-app
DocumentRoot /path/to/app
<Directory /path/to/app>
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]
</Directory>
</VirtualHost>

Configuring Apache to rewrite urls to index.html in root directory

My AngularJS application is using html5 mode for pretty urls. The urls on my local environment work but typing full urls directly into the browser causes my test server (set up on Heroku) to respond with 404 "Not Found" errors.
Examples:
1) Typing "localhost/log_in" or "localhost" directly into the browser results the login page.
2) Typing "localhost/fkjdlfdsaf" or any other url that begins with "localhost/" directly into my browser results in the login page.
3) Typing "myapplication.herokuapp.com" (test environment) directly into the browser also results in the login page.
4) Typing "myapplication.herokuapp.com/log_in" (test environment), however, incorrectly results in a 404 "Not Found" error.
It seems like the test environment server hasn't loaded [root dir]/index.html since the file contains scripts (including a route that serves the "login" page if the url doesn't match any other routes).
Can somebody tell me what I'm missing on my test server? I prefer solutions that modify the "httpd.conf" file over using a .htaccess file.
Snippet from httpd.conf on local server:
DocumentRoot "C:/Sites/myApplication"
<Directory "C:/Sites/myApplication">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]
</Directory>
To configure web servers on Heroku, I created two files, procfile.txt (see this and this) as well as apache_app.conf (see this).
procfile.txt (heroku):
web: vendor/bin/heroku-php-apache2 -C apache_app.conf
apache_app.conf:
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]

Resources