How to run a cakephp app on an apache server? [UBUNTU] - php

On 16.04 Ubuntu, I want to run a cakephp app on the localhost to make some modifications. How can I do that?
Installed application has files in 3 different directories:
opt
etc
usr
I know apache files run on var/www/html but how can I move those installed files there to run the application? As far as I know, index.php is the start file of php projects but for cakephp, there is a default.ctp file for the main program page, of course there are other index.php files for other pages, and I am really stuck with that.
Thanks in advance.

Copy your CakePHP project to a subfolder in Apache document root, eg /var/www/html/myproject. Make sure you have mod_rewrite enabled. Then you should be able to access your project at http://localhost/myproject.
More info: CakePHP Installation
As for files located in etc, opt and usr, it depends what they are. If you can share what you have there, please do it, as it will help to decide what to do with them.

I suggest using virtual hosts to run your project.
https://support.rackspace.com/how-to/set-up-apache-virtual-hosts-on-ubuntu/
Enjoy...

Related

Yii Project Setup on Remote Server

I've inherited an application written using the Yii PHP framework. I've uploaded all the project files to a remote server, but I don't have SSH access or shell-exec permission.
Is it possible to make the application work in these circumstances?
If so, what files do I need to edit and in what way please?
Yes, it should be portable, all you need is just copy all project contents (including dependencies) to the destination folder and make proper configuration for a web-server.
The only one issue here is #app/runtime and #app/web/assets folders -- the should be accessible to write for web-process (the second is only if you are using AssetManager).
You can solve this issue in config, using runtimePath and assetManager['basePath'] parameters.

Using laravel in a subdirectory, without root access

A year ago, I decided to go with codeigniter instead of laravel, because codeigniter prooved to be easier to setup. I am now preparing for my next project and it seems as if codeigniter is now obsolete (at least most of the people seem to recommend laravel over codeigniter).
Now to my problem: I use a virtual ubuntu machine for developing web apps so I have a dev environment similar to the production environment (this helps me to avoid some problems (especially case-sensitivity...;)))
I installed composer and laravel and created a new laravel project named "quickstart" in /var/www/quickstart. I then followed their "getting started guide" (here: Guide). So far everything worked.
But here come the problems:
I have two other web applications in /var/www, so when I enter the ip of the machine I see the 3 directories.
Issue 1:
Normaly I'd expect that as soon as if I click on the "quickstart"-Directory in my browser, the webapp would get displayed, but I have to click a second time on "public", and then the webapp is displayed.
Issue 2: Of course, the links on the page are wrong too, because they reeer to (for example) "/task", which can't be found on the server.
The problem is that I'm not really experienced with apache configuration. I suspect it has something to do with VirtualHosts, but AFAIK you need to have root access to configure virtual hosts, and I do not have root rights on the dev environment.
Could you point out a way to me how I can make laravel work in a subdirectory in a way that I can just move the files and folders to my hoster as soon as I have finished the project? I'd like to then change only one file, and not all paths and URLs in all files ;)
Regards,
Christian
Thanks to Bogdan, I was able to figure it out. My hoster allows symlinks, so I did it like so:
I put the laravel installation in
/srv/web/quickstart
(quickstart is the name of the project). I then created the following symlink:
ln -s /srv/web/quickstart/public /srv/web/www/public
The document root of the apache is configured to
/srv/web/www/public
After that I just got a blank page. That was because I forgot to set the correct permissions on the storage-folder. So I set the following permissions
chmod -R 777 /srv/web/quickstart/storage
This is fine for a development environment. For production I'd recommend to only allow the webserver-user to write into that directory.
And voilà: Everything works!
Thank you for your help bogdan.
Christian

Rendering code using Apache/SVN on Ubuntu

I'm not sure if I'm missing the point here...
Our devs want the following...
On a LAMP server with SVN/WebDAV they want the root Apache directory to be a repository that they can all work on. However, setting the default Apache directory to a repo doesn't work as the files aren't stored as html/php files, instead in the SVN db structure to handle changes/revisions/etc.
Is there any way to do this? or would we have to have a separate repo that they copy files to/from the web root when developing?
You have to setup a separate svn repository and Hook Scripts. This hook scripts can checkout the code on every code change to your apache root. This is quite common an also used for automatic testing etc.

How to run different web apps on different port in same server?

I want to run different web app on different ports on same server, I have a apache php server running on a Linux machine. How can I achieve this ? and when I Google I stumble upon 'tomcat', what is this ? I am a noob, so please forgive if that is a stupid question.
Check the apache manual for the VirtualHost directive. It'll explain everything.
One thing to remember (it caught me out first time) - if you use virtual hosts, you have to define a virtual host for the default page too.
Don't worry about Tomcat at the moment. If you don't know what it is, you don't need it yet.
Step 1: Install the Tomcat files
Download Tomcat 4.1 or 5.5, and unzip it into an appropriate directory. I usually put it in /usr/local, so it ends up in a directory called /usr/local/apache-tomcat-5.5.17 (5.5.17 being the current version as of this writing), and make a symlink named /usr/local/tomcat to that directory. When later versions come out, I can unzip them and relink, leaving the older version in case things don’t work out (which rarely if ever happens, but I’m paranoid).
Step 2: Make directories for each instance
For each instance of Tomcat you’re going to run, you’ll need a directory that will be CATALINA_BASE. For example, you might make them /var/tomcat/serverA and /var/tomcat/serverB.
In each of these directories you need the following subdirectories: conf, logs, temp, webapps, and work.
Put a server.xml and web.xml file in the conf directory. You can get these from the conf directory of the directory where you put the tomcat installation files, although of course you should tighten up your server.xml a bit.
The webapps directory is where you’ll put the web applications you want to run on the particular instance of Tomcat.
I like to have the Tomcat manager webapp installed on each instance, so I can play with the webapps, and see how many active sessions there are. See my instructions for configuring the Tomcat manager webapp.

How to create a symbolic link in the www directory?

I'm not even sure this is the right way to do this, but I am looking for some advice. I am developing on a Mac, but using VMWare to run this project in Windows.
I am using WAMPserver 2.2A. My directories look like this:
C:\Users\John Doe\Development\project-web\
C:\wamp\www\
What I would like, is to develop my project in project-web, but have a symlink in www so I can run it in the browser with apache. This is what I tried:
mklink project "C:\Users\John Doe\Development\project-web\"
I ran into some permissions errors when trying to approach it this way. I feel like this would be better than storing the project in \www\ but I might be wrong.
Any advice would be great!
Apache generally doesn't follow symlinks by default, as they can be trivially used to break out of the document root. I'd suggest looking into using an Apache Alias instead to create a virtual Apache folder that maps to your development directory

Categories