Stackscript not working properly - copy and paste code is ok


I have a stackscript I am working on, and if I copy and paste the lines one by one it works flawlessly but if I run it as a script the patching of php with php-fpm (see below) doesn't seem to work - no errors, it looks like it is fine (as in the output says patched okay) but when it tries to configure php it says unknown option –with-fpm.

i'm stumped - surely if it works copying and pasting line by line it must work as a script?

Script is below:


apt-get update
apt-get -y install locales
dpkg-reconfigure locales
apt-get -y upgrade

echo "console-setup console-setup/charmap select UTF-8" | debconf-set-selections

# General requirements etc
apt-get -y install wget build-essential libpcre3 libpcre3-dev libssl-dev libtool libltdl3-dev libgd2-xpm-dev libmcrypt-dev libxml2-dev libmysqlclient15-dev flex m4 gawk automake autoconf bison make libbz2-dev libpcre3-dev libssl-dev zlib1g-dev re2c libssl-dev libcurl3 libcurl4-openssl-dev unzip

# Build nginx from source
cd /usr/src
tar -zxf nginx-0.7.65.tar.gz
cd nginx-0.7.65
./configure --sbin-path=/usr/local/sbin --conf-path=/etc/nginx/nginx.conf --user=www-data --group=www-data --with-http_ssl_module --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-client-body-temp-path=/var/tmp/nginx/client
make && make install

mkdir /var/www
mkdir /var/tmp/nginx
mv /usr/local/nginx/html/* /var/www/

mv nginx.init.d.txt /etc/init.d/nginx
chmod +x /etc/init.d/nginx

mkdir /etc/nginx/sites-available
mkdir /etc/nginx/sites-enabled

mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old
mv nginx.conf.txt /etc/nginx/nginx.conf

mv nginx.default.txt /etc/nginx/sites-available/default
ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
/usr/sbin/update-rc.d -f nginx defaults

cd /usr/src
tar -xvzf libevent-1.4.13-stable.tar.gz 
cd libevent-1.4.13-stable
make && make install
echo "/usr/local/lib" > /etc/
cd ..

tar -xvzf php-5.2.12.tar.gz
cat php-fpm-0.6~5.2.patch | patch -d php-5.2.12 -p1

gunzip suhosin-patch-5.2.12-0.9.7.patch.gz
cat suhosin-patch-5.2.12-0.9.7.patch | patch -d php-5.2.12 -p1

cd php-5.2.12
./buildconf --force
./configure --enable-fastcgi --with-fpm --with-libevent=shared,/usr/local/lib --with-mcrypt --with-zlib --enable-mbstring --with-openssl --with-mysql --with-mysql-sock --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf --with-config-file-path=/etc/php --with-curl --with-fpm-user=www-data --with-fpm-group=www-data
make all install
update-rc.d -f php-fpm defaults

mkdir /etc/php
cp php.ini-recommended /etc/php/php.ini
cd ..

3 Replies

Strangely if I add a pause like so:

    cd /usr/src/php-5.2.12
    read -sn 1 -p "Press any key to continue..."
    ./buildconf --force

it seems to work fine.

Excellent :)

However, I still have the problem it prompting me to save a PHP script.

Still working on it….

Will make it public when I am done, should be under stackscripts for ubuntu.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct