If you wanted to store the current time in a variable instead of calling NOW() inside a query use the PHP code below.
date ("Y-m-d H:i:s", time());
and wow look at all those caps in the title
If you wanted to store the current time in a variable instead of calling NOW() inside a query use the PHP code below.
date ("Y-m-d H:i:s", time());
and wow look at all those caps in the title
Basically I didn’t want to be tied to an internet connection to my linux dev box to do work anymore, so I found MAMP. Well I actually was pointed at MAMP by Chris but that’s besides the point. Normally when I am developing I run into some errors, and I like to see those errors. MAMP is for developing locally, however by default php errors are not displayed. Now why would I want to develop and not see any errors, come on MAMP team…think about that one!
If you need to setup xcache for use in your nginx + php5 setup this tutorials will show you how.
Installation
sudo apt-get updatesudo apt-get install php5-xcache
Configuration of xcache
sudo vim /etc/php5/conf.d/xcache.ini
and update the values for
If you don’t want admin access then set
xcache.admin.auth = Off
Finishing Up
sudo /etc/init.d/init-fastcgi stopsudo /etc/init.d/init-fastcgi startThis post will go over the steps you need to get nginx running with php5. I am going to use a list to show the steps to take, please leave a comment if you see something that needs to be corrected or just want to leave feedback.
Installation
sudo apt-get updatesudo apt-get install nginx
sudo apt-get install php5-cgi php5-mysql
sudo apt-get install lighttpd
sudo update-rc.d -f lighttpd removeConfiguration of nginx,startup scripts,fastcgi
sudo vim /usr/bin/php-fastcgi
#!/bin/bash
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 10005 -u www-data -g www-data -f /usr/bin/php-cgi
Make sure to set www-data to the user and group that you want php running as.
sudo chmod +x /usr/bin/php-fastcgi
sudo vim /etc/init.d/init-fastcgi
and enter the following
#!/bin/bash
PHP_SCRIPT=/usr/bin/php-fastcgi
RETVAL=0
case "$1" in
start)
$PHP_SCRIPT
RETVAL=$?
;;
stop)
killall -9 php-cgi
RETVAL=$?
;;
restart)
killall -9 php-cgi
$PHP_SCRIPT
RETVAL=$?
;;
*)
echo "Usage: php-fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
sudo chmod +x /etc/init.d/init-fastcgi
sudo update-rc.d init-fastcgi defaults
sudo vim /etc/nginx/fastcgi.conf
and enter
#fastcgi.conf
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#To use Nginx + Virtual Host + PHP you should ommit the SCRIPT_NAME
#variable in order for PHP to choose the correct DOCUMENT_ROOT
#fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
#fastcgi_param REDIRECT_STATUS 200;
sudo vim /etc/nginx/sites-enabled/default
location ~ .*\.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass 127.0.0.1:10005;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/xxx/public_html/domian/public/$fastcgi_script_name;
}
index index.html index.htm index.php;
sudo /etc/init.d/nginx restart
sudo /etc/init.d/init-fastcgi start