CakePHP3.1.6 dispatch( Request::createFromGlobals(), new Response() ); - php

I'm trying to uses Vagrant and VirtualBox to enhance the develop environment on my laptop. So I download the box of CentOS7.1 and installed PHP 7.0.1,apache 2.4.18,mysql 5.6.28. My friend reminded me to add intl extension for using CakePHP3.1.6.
While I finished all the install and configure things I add an test html file to the virtual machine. Then I access the virtual machine with 192.168.33.10 which is wrote in Vagrantfile. The html works perfectly fine. I put the CakePHP3.1.6 on the virtual machine but I cannot access properly.The page show me
dispatch( Request::createFromGlobals(), new Response() );
and nothing more. I don't know which I missed. Please help.

Check for php5.conf and php5.load symbolic links on /etc/apache2/mods-enabled, you can create them by using the following commands
cd /etc/apache2/mods-enabled
ln -s ../mods-available/php5.conf
ln -s ../mods-available/php5.load

Related

How to use a specific version of composer?

I am using a shared host which comes with an old version of composer. Unfortunately, it's an old version its not able to install something properly. My shared host provider said I can simply install a new version to my shared root directory.
So I did that by adding a php.ini file and then running the following command
php -r "readfile('https://getcomposer.org/installer');" | php -c php.ini
That seemed to work and when I run the command to check the version it only shows me the new version when I run php composer.phar -V. But when I run composer -V, it shows me the old version.
How can I override the main composer for my shared directory? And by the way, I did this in my root directory as I have multiple domains so was hoping I could get this to work in all domains.
I managed to find a solution. I just needed to create an alias and it seems to be working now
echo alias composer="composer.phar" >> .bashrc

"localhost" always shows "welcome to Nginx" Ubuntu?

I am running Ubuntu 16. I am fairly new to web design but I have set up a LAMP server on my Ubuntu machine and installed WordPress site. I wanted to try to mess around with PHP so I tried to install myphp.
I managed to do this and I realized that I had to install nginx also.
I did this, but my local host always diverts to a message "welcome to Nginx"
I tried to edit the configuration files but could not get it to work?
Is there a guide for installing Nginx and myphp to see phpMyAdmin, after you have already set up a WordPress site?
Like I said I am running Ubuntu 16.04.
You may need to delete the index.html file from the web root. The index.php file should remain.
On Ubuntu+nginx go to html directory using following command
cd /var/www/html/
then find out following index.nginx-debian.html and delete it or edit it as you want
To edit these file open into you editor or use Ubuntu default editor nano.
sudo nano /var/www/html/index.nginx-debian.html
To delete these file run following command.
sudo rm -rf /var/www/html/index.nginx-debian.html
these is the defautl nginx welcome page that why it appear after install, for more information check nginx default configuration file using following command.
sudo nano /etc/nginx/sites-available/default
Thanks

localhost does not work after installing macports

I have installed macports and updated my path:
via docs:
http://guide.macports.org/#installing.shell.postflight
but now if I test any of the sites in my Sites folder, I get a 404.
so for instance if I go to localhost/~carey/test.php which is just a php_info, I get a 404
If I go to:
localhost/
I get the It Works! page
Am I missing a step to configure Macports to run apache from my Sites directory?
If I run $env from the command line I get:
TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/rs/943jh19j31j3ld55yxqgf2mm0000gn/T/
Apple_PubSub_Socket_Render=/tmp/launch-NehzDd/Render
TERM_PROGRAM_VERSION=326
TERM_SESSION_ID=A329EAC2-AE9F-4460-BB1B-B35981BAE0ED
USER=carey
SSH_AUTH_SOCK=/tmp/launch-CgUaVv/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0:0
PATH=/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
__CHECKFIX1436934=1
PWD=/Users/carey
LANG=en_US.UTF-8
SHLVL=1
HOME=/Users/carey
LOGNAME=carey
SECURITYSESSIONID=186b0
_=/usr/bin/env
and I can run any macport install, but I cannot configure the terminal to connect to my localhost in the browser.
So I think I have macports installed correctly, but I dont know how to make it run out of the /opt directory.
I also think this is relative to establishing the env variables, so apache knows to look to the /opt dir, but I don't know how to change it.
I am running Mavericks.
UPDATE
Following the docs recommended by eborisch here:
https://trac.macports.org/wiki/howto/MAMP
I have been able to setup the localhost directory, but still an issue.
Since I have multiple users on the machine, I had to comment out this line in httpd.conf:
Include conf/extra/httpd-userdir.conf
and added this to the httpd-userdir.conf file:
#
# Include user configurations
#
Include /private/etc/apache2/users/*.conf
which connects my Sites folder to the localhost.
I also needed to add this to the httpd.conf file to parse php files as php:
AddType application/x-httpd-php .php
Now, I have a file in my Sites dir called test.php, which has <?php phpinfo() ?>
and if I run localhost/~carey/test.php in the browser it works. phpinfo() returns that I am running php5.5.10 out of the /opt/ dir. So, all seems well. The problem is if I try to run any sites from folders in this directory. It just displays the directory tree, rather than treating it like a site.
For instance if I run,
localhost/~carey/mysite
it just returns:
Index of /~carey/mysite
Parent Directory
2005/
2006/
index.php
../
If I run
localhost/~carey/mysite/index.php
it runs that file correctly (ie looks correct in the browser)
Seems like an .htaccess issue, but not sure how I would resolve that globally for each folder in the Sites directory
any suggestions?
Probably better served on https://lists.macosforge.org/mailman/listinfo/macports-users/ the macports mailing list. But some basics:
Is the osx web server running? (Web sharing under the sharing control panel?) If so, turn it off, or configure the two to use different ports.
Is the macports apache2 installed? (sudo port install apache2)
Is it running? (sudo port load apache2)
Have you edited its configuration (/opt/local/apache2/conf/httpd.conf)?
See https://trac.macports.org/wiki/howto/MAMP for instructions on getting things up and running.

Where do I find DocumentRoot on Ubuntu after installing PHP, MySQL and Apache2?

I am new to Ubuntu Linux (version 13.10). I am following this tutorial to install MySQL, PHP, and Apache2.
It installed successfully, but I don't know where to write PHP files that execute when you navigate to the URL localhost/example.php.
I am looking at this link, but I am afraid that maybe it will not work and have to reinstall Ubuntu again.
In a newer version should be in a different path: /var/www/html
With a series of commands you can find:
ls /etc/apache2/sites-available/
That answers with something like
000-default.conf default-ssl.conf
In this case you need the second file default-ssl.conf; with
grep -n -e "DocumentRoot" /etc/apache2/sites-available/default-ssl.conf
you can obtain:
5: DocumentRoot /var/www/html
That means you can find (and change) DocumentRoot definition in the 5-th lines of the file /etc/apache2/sites-available/default-ssl.conf.
As a simple Google search would have showed you, it's (by default), /var/www/.
In the Ubuntu default config, that is defined in the default virtual host, the config file for that is /etc/apache2/sites-available/default
The default location of document root is /var/www. This, assuming you haven't touched the HTTPd configuration.
By the way, if you simply need a development server for PHP scripts, you can use the one emebedded in PHP > 5.4. Just cd to the project directory and launch:
php -S localhost:8008
In vscode (I'm sure in other editors as well) you can right click the file and copy path and copy relative path.
http://127.0.0.1:8000/site.php
Works for me.

Running git pull from a php script

I was trying the Perfect Workflow, with Git, GitHub, and SSH, and i have everything set up, except running the command git pull from php.
When i run exec('git pull') i get:
Could not create directory '/.ssh'. Host key verification failed.
fatal: The remote end hung up unexpectedly
If i run it in the terminal (as root) it works just fine, but i need this hook to work from the Post-Receive URL (Github).
If i do exec('whoami') i get apache.
It's a (dv) from mediatemple with CentOS.
If you want apache (the user) to be able to pull from git, you'll have to create an ssh key for apache, then add that to the read only keys on github.
The flow is something like this (tweak to your needs)
usermod -s /bin/bash apache
su apache
cd ~
ssh-keygen # work through the keygen dance (added a dash)
Upload (tilde here refers to apache's homedir) ~/.ssh/id_rsa.pub to github and give apache access to whichever repos it needs to pull from.
Then you can test on the server by again su'ing to apache and running the git pull
su apache
cd ~/working-copy
git clone my-project
Once that's working you should be able to run a git pull through PHP.

Categories