Archive

Posts Tagged ‘php’

debian 4 web server setup

November 7th, 2008

First post in awhile! I just had to get that out there. Well it has been an intense couple of weeks with college life really starting to kick in (the tests and lectures) and my work being the way it has. But I am back serving up cookbook recipies. Today’s is about setting up a debian based web server (for those of you with a vps or dedicated box). It is assumed that you are able to send mail directly from this box. Enjoy.

1) Install debian from floppies, full cd, or cd net install. Pretty self explanitory. I suggest doing it from floppies or cd net install, because we want to save as much disk space as possible for data.

2) Log in as root and run:

  • apt-get update
  • apt-get upgrade

If the system prompts you to reboot a process or the system, do as it says. Once you reboot all the core daemons and programs should be the latest (stable) versions.

3) Install the ssh server [apt-get install ssh] for remote command line access, so you don't have to be hunched over a server rack.

4) If you wish to have email functionality follow the instructions in this article on howtoforge.org.

5) various dependencies and apps (php, mysql, pcre for nginx): apt-get install php5-cli php5-cgi build-essential mysql-server mysql-client openssl libssl-dev libpcre3 libpcre3-dev bzip2 gzip
better lock down the mysql root user: mysqladmin -u root password NEWPASSWORD

6) For individual virtual host files under nginx:
mkdir /etc/nginx
mkdir /etc/nginx/sites-enabled

[Sample Virtual Host File] • [More on Virtual Hosts]

7) if ($operating_system == “ubuntu*”) {
grab the nginx .deb archive (check the other releases out on technokracy.net):
[i386] wget http://www.lizardking.biz/wp-content/uploads/2008/11/nginx_0613grrr-1_i386.deb
OR
[amd64] wget http://www.lizardking.biz/wp-content/uploads/2008/11/nginx_0613grrr-1_amd64.deb
unpack and setup nginx: dpkg -i nginx_*
}else if($operating_system == “debian*”){
command to grab nginx: apt-get install nginx
}

8) Setup lighttpd for spwan-fcgi
grab the archive and make it. but DO NOT make install!
wget http://www.lighttpd.net/download/lighttpd-1.4.20.tar.bz2
tar -xvjf lighttpd-*
cd lighttpd*
./configure --without-bzip2
make

Now copy what we need for spawn-fcgi: cp src/spawn-fcgi /usr/bin/spawn-fcgi
Open the config file: vi /usr/bin/php-fastcgi
And add: /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -u www-data -f /usr/bin/php5-cgi
-C controls how many fcgi instances of PHP5 are spawned, so you can put however many are appropriate for you in there. I only needed 5.

Open the startup file: vi /etc/init.d/init-fastcgi
Add the following:
#!/bin/bash
PHP_SCRIPT=/usr/bin/php-fastcgi
RETVAL=0
case "$1" in
start)
$PHP_SCRIPT
RETVAL=$?
;;
stop)
killall -9 php
RETVAL=$?
;;
restart)
killall -9 php
$PHP_SCRIPT
RETVAL=$?
;;
*)
echo "Usage: php-fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL

Now change some perms to make the files executable:
chmod 755 /etc/init.d/init-fastcgi
chmod 755 /usr/bin/php-fastcgi

Start your fcgi processes: /etc/init.d/init-fastcgi start
And add the script to startup: update-rc.d init-fastcgi defaults
Restart nginx and see if it works: /etc/init.d/nginx restart

#8 was based on: http://www.johnyerhot.com/2008/02/12/how-to-nginx-fcgi-php-mysql-ruby-on-rails-rewrite-vhosts/

[More on fcgi setups on the nginx wiki]

9) Install vsftpd
apt-get install vsftpd
Now open up the configuration file: vi /etc/vsftpd.conf
I am creating a single/few user system here, so whenever I add a new user, that user will have ftp permissions. Which would mean that I would edit the config file so that: local_enable=yes and chroot_local_user=YES.
Restart vsftpd: /etc/init.d/vsftpd restart

10) A great resource page on adding, editing, and deleting users can be found at http://www.ahinc.com/linux101/users.htm.

Linux, Server , , , ,

php and ajax adventures

April 26th, 2008

Today started out with a woeful surprise. Snow!?!? Yeah I know I’ve lived here in Minnesota for almost five years now, and I’ve never seen snow this late in April. I hadn’t coded in awhile, not for about two weeks. Desayuné, me lavé los dientes y me puse mis ropas en el cuerpo. After that I started up my laptop.

I had recieved an email from Scott VanderVeer Thursday night, asking me about The Source. The Source is an early scripting job that I did for the youth group at Trinity Presbyterian Church that I was more actively a part of in the past. This was before I become a more regular attendee and member of Emmanuel Mennonite Church. The Source kind of died out about 5-6 months ago. Maybe Scott can give it the new blood it needs to take off again. So the first half of the day was spent interspersed between giving Scott assistance on the finer points of DNS issues and PHP scripting, interspersed with various household chores.

After lunch was spent working on a contract coding job for these guys that call themselves, “Tribal Shaman” and “Zerja Sone”. They are working this upstart cracking/hacking network called XSSLink and Prohacks.org. I got called in to write the backend PHP/MySQL data processing and arrange the hosting, as they have other tasks at hand. Something about affiliates and investment return. I would have to say that the XSSLink backend is my craziest undertaking to date. “Tribal Shaman” wanted a completely Plug ‘n Play tracking method in Javascript as well as a monetized linking system at minimal cost. So I will be attempting to load balance across a couple free hosts. It will be risky but worth the payout.

And now as I write this at almost half past 11pm I feel my body asking to sleep. Which then got me thinking about this interesting venture called, Rockabye Baby!. The go by the logo, “Transform your favorite rock music into baby music.” They Green Day riff on the front page certainly sounds calming. Just imagine a couple years down the road, “Daddy … why do you have a different version of my lullaby music on your computer?” Which could turn into a valuable teaching moment about the world in general and what the artists are getting at when they offer up their work to the world.

Internet, Music, Software, Web ,