Pinch: Nginx, PHP-FPM, APC & MariaDB CentOS Install Script

Pinch

Intelligent Stack Scripts for CentOS Linux

Pinch installs, secures and configures your very own Nginx, PHP-FPM, APC and MariaDB web-server in a matter of minutes. It’s so easy to install and streamlines your production environment.

Installation

Pinch is a pinch to install, simply execute the following commands to get started:

$ yum install -y git
$ git clone git://github.com/drewsymo/Pinch.git
$ cd Pinch/vanilla-lemp && bash install.sh

If you’re on Linode, you can simply rebuild your instance with the Pinch-installer stackscript.

Features

  • Installs a LEMP stack (PHP-FPM, MariaDB, APC, Nginx and Varnish Cache) via Yum
  • Configures Varnish Cache with Nginx out-of-the-box
  • Sets your hostname, timezone and installs essential tools
  • Uses GoogleDNS with Level3 tertiary resolver
  • Intelligentelly configures Nginx based on CPU cores
  • Sets Varnish memory allocation percentage based on total memory
  • Retrieves MariaDB server.cnf based on total memory
  • Sets MariaDB root password and removes testing user / tables
  • Creates a daily cron with email notifications for available Yum updates
  • Secures your system via the following methods:
    • Creates privledged sudo user
    • Disables SSH root logins
    • Disables UseDNS
    • Sets a non-standard SSH port
    • Enables SElinux
    • Customisable Firewall via iptables
    • Sets common network / kernel security parameters
    • Disables IPv6
    • Creates unprivledged www-data user for lemp components

Documentation

What are the PHP-FPM, Nginx, MariaDB and Varnish Locations?

The locations for each of the Pinch components are as follows:

  • Nginx: /etc/nginx
  • PHP-FPM: /etc/php-fpm.d/
  • MariaDB: /etc/my.cnf.d/
  • Varnish: /etc/varnish/ & /etc/sysconfig/varnish/

What is the Username and Password of my system?

Pinch creates a new privledged user for your system and disables root SSH logins for security. Additionally, it will set a root password for your MariaDB server.

  • Hostname Option: host.domain.com
  • Timezone Option: Australia/NSW
  • New SSH Port: 3636
  • New Root Username: sudoninja
  • New Root Password: sudoninjapassword
  • MariaDB Root Password: mariadbpassword

For example, you can now login using ssh -p 3636 sudoninja@x.x.x.x with the password sudoninjapassword.

You can adjust the defaults by modifying the parameters in the `install.sh` script, located in the `vanilla-lemp` folder.
Alternatively, if you are using the Linode stack-script, you will be prompted to enter these options on rebuild.

Don’t forgot to change your password by typing pwd sudoninja in your console

Debugging

To debug Pinch, simply cat or grep the Pinch installer log (/var/log/stackscript.log) for error messages, e.g.

grep "error" /var/log/stackscript.log

To jump to more specific sections, you can grep the individual functions, e.g.

grep "pinch_nginx" /var/log/stackscript.log

View the Project on GitHub

Incoming search terms:

  • http://firstcallmediagroup.com Steve Goldman

    Looks like a good script, wondering why for mysql you don’t use MariaDB though, less overhead and extremely stable

    • http://drewsymo.com Drew

      I’ve been looking into Maria for a little while now; I’m thinking I’ll include it in the script later on, along with version control variables.

      MariaDB is supported in Pinch by default now.

      Thanks!

  • http://linuxdo.blogspot.com Aatish

    Great Script. How about incorporating SPDY onto Nginx at compile-time?

    • http://drewsymo.com Drew

      SPDY looks amazing. Thanks for the suggestion, I’ll be adding it in shortly.

      SPDY support for Nginx has been enabled.

  • Rob Whittle

    Great script Drew, thanks for this.

    When installing MariaDB I ran into the problem described here:

    https://kb.askmonty.org/en/centos-5x6x-mysql-lib-conflicts-and-postfix/

    I found that adding yum remove mysql-lib* to the script before the install solved the problem.

    • http://drewsymo.com Drew

      Hi Rob,

      Thanks for letting me know,

      Just quickly, did you have a previous installation of MySQL lying around there?

      • http://plymdesign.com Chris

        I ran into the same issue when installing on Centos 6.4 64-bit. Before running Pinch, I checked for installed packages related to mysql, and found only mysql-libs. Removing it before Pinch did the trick.

        • http://drewsymo.com Drew

          Thanks Chris,

          I’ll put a yum remove on these components in the next update of Pinch.

          Thanks for using it!

  • manesh

    hi, great stuff. But the documentation is a bit limited. I can’t access with username root anymore. So how do I access to my server from now? Also is there a way of accessing the installed features like the (PHP-FPM, MariaDB, APC, Nginx and Varnish Cache)

    I’m new to this, if this could work that would be 100% what I need.

    • http://drewsymo.com Drew

      Hi Manesh,

      Thanks for the comment.

      I’ve updated the post with some more information on what Pinch sets as the default username / password, along with the installation location of its components (PHP-FPM, Varnish, MariaDB and Nginx)

      If you’ve installed Pinch using the vanilla-lemp method, you can login via SSH using:

      ssh -p 3636 sudoninja@x.x.x.x

      Where x.x.x.x is your server IP and the password is sudoninjapassword.