Bitnami Nginx Stack

    The Bitnami Nginx Stack is an easy to install software platform that greatly simplifies the deployment of Open Source web stacks. It includes ready-to-run versions of Nginx, MySQL, PHP and other components. Bitnami Nginx Stack is distributed for free under the Apache 2.0 license.

    How do I download and install Nginx Stack?

    nginxstack-stack-110x117.png

    You can download Bitnami Nginx Stack for your platform at https://bitnami.com/stack/nginx. There are installers available for Windows, OS X and Linux operating systems. 

    Bitnami Nginx Stack can also be deployed as virtual machines. If you are using the virtual machine, please see our Virtual Appliances documentation for instructions on logging into the machine.

    The Stacks can be also deployed as AMIs in the Amazon cloud. Please take a look at our Amazon Cloud Images quick guide to see how to connect to the instance from your machine.

    Bitnami Nginx Stack is distributed free of charge under the Apache 2.0 license.

    Which components are installed with Nginx Stack?

    The Bitnami Nginx Stack ships the components listed below. If you want to know which specific version of each component is bundled in the stack you are downloading, check the README.txt file in the Stack installation directory. You can also find more information about each component using the links below.

    Main components:

    • Nginx Web server
    • MySQL database server
    • PHP-FPM
    • phpMyAdmin web application management tool for MySQL database

    Dependencies and additional components:

    • Varnish proxy cache server
    • ImageMagick tool
    • SQLite database
    • XDebug module
    • Memcache module
    • APC module
    • GD library
    • OpenSSL library
    • CURL library
    • OpenLDAP library
    • PEAR and PECL package manager tools

    What is the default installation directory?

    When using native installers the default installation directory depends on the platform and can be changed during the installation:

    win_platform.png On Windows: C:\BitNami\nginxstack-VERSION

    mac_platform.png On OS X: /Applications/nginxstack-VERSION

    linux_platform.png On Linux: /home/user/nginxstack-VERSION

    If you are using a virtual machine or the AMI, the default installation directory is "/opt/bitnami".

    How do I start and stop the servers?

    The Nginx Stack ships several servers that must be started before you will be able to work with them. By default, MySQL database, Nginx servers and PHP-FPM are started after the installation.

    Graphical tool

    The Nginx Stack include a graphical tool to manage the servers easily. You can find the "manager-osx" or "manager-linux" tool in your installation directory. Using this tool, you can Start, Stop or Restart the servers and check the log files. You can click on the icon to start it.

    nginx-manager-screen.pngmanager-osx.png

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Command line tool

    If you prefer, you can use the "ctlscript.sh" utility from the command line. This script is in the installation directory.

    linux_platform.png

    On Virtual Machines and Cloud images:

    $ sudo /opt/bitnami/ctlscript.sh start

    A native installer on Linux:

    $ cd ~/nginxstack-version
    $ ./ctlscript.sh start

    mac_platform.png

     On OS X: You can start the Manager tool from the installation directory or you can use the "ctlscript.sh" utility from a Terminal.

    host:~ user$ cd /Applications/nginxstack-version
    host:~ user$ ./ctlscript.sh start

     

    How can I run a command in the Nginx Stack?

    All of the Native Installers for Bitnami Stacks are completely self-contained and run independently of the rest of the software or libraries installed on your system. To work correctly, certain environment variables need to be set when you want to invoke commands to access different binaries. Note that in virtual machines or AMIs, the environment is already loaded for the "bitnami" user automatically and the below is not necessary.

    Bitnami console is a script to load the Stack environment. This console is useful to run any command included in the Stack: mysql, php, openssl, ruby, rake among others.

    linux_platform.pngOn Linux:

    $ cd ~/nginxstack-version
    $ ./use_nginxstack
    
    

     

    mac_platform.png

    On OS X:

    Open a Terminal and type the following:

    hostname:~ user$ cd /Applications/nginxstack-version
    hostname:~ user$ ./use_nginxstack 

    Note: If you are using Bitnami Cloud Hosting, a virtual machine or a Cloud image the Stack environment is loaded by default and you don't need to start the console.

     

    How can I check the PHP configuration with phpinfo?

    Once the installation or deployment finishes, you can access the welcome page from your browser. If you have installed the stack on a local machine as a regular user, you can access it at http://localhost:8080 on OS X and Linux. If not, you can specify the IP address of the server where you installed the Stack.

    You should see something similar to this page:

     

    There is a "docs" folder in the installation directory that contains some PHP examples. There is a "phpinfo.php" script file that shows the current PHP configuration and is typically used to check that PHP was installed correctly. In order to be able to access it, you first need to place it in a publicly accessible location. Copy the installdir/docs/phpinfo.php file into the installdir/nginx/html folder and go to your browser to check the enabled PHP modules. By accessing http://localhost:8080/phpinfo.php (or http://localhost:8080/phpinfo.php if running in port 8080). You should see something similar to this page:

     

    How can I create a custom PHP application?

    If you want your PHP application to be accessible at the root URL ( http://localhost/ ), you can simply copy your PHP files into the installdir/nginx/html folder. For an example, take a look at phpinfo.

    If you want to have several applications running on top of Nginx Stack, we suggest that you create the same structure that we use when installing Bitnami PHP applications. Nginx Stack ship a demo application with this structure that can help you get started. Simply copy the installdir/docs/demo folder into the installdir/apps directory and add the following line at the end of the installdir/nginx/conf/bitnami/bitnami-apps-prefix.conf file:

    include "installdir/apps/demo/conf/nginx-prefix.conf"
    

     

    Substitute installdir with the actual installation directory for your deployment.

    Once you are done with the above, restart the Nginx server. If you are running the stack in your desktop or laptop, you can use the bundled graphical Manager tool that is included in your installation directory.

    You should be able to access the demo application at http://localhost/demo or http://localhost:8080/demo. You should see a "Hello world" message in your browser.

    You can learn more about the Bitnami PHP application structure here.

     
     

    How can I install WordPress on top of Nginx Stack?

    In this section we are going to explain how to install WordPress on Nginx Stack. We are going to assume that you are using a Virtual Machine or a Cloud Image. In case of Native Installers the steps are similar to these. 

     
    Run the following command to get root privileges and go to your installation directory.
    sudo -s
    cd /opt/bitnami
     
    Copy the demo project to the apps folder and remove htdocs folder
    cp -r docs/demo/ apps/wordpress
    rm -rf apps/wordpress/htdocs
     
    Download the latest WordPress and extract the files in apps/wordpress, then rename apps/wordpress to apps/wordpress/htdocs.
    wget https://wordpress.org/latest.tar.gz
    tar xfvz latest.tar.gz -C apps/wordpress/
    mv apps/wordpress/wordpress/ apps/wordpress/htdocs
    
     
    Now substitute demo for wordpress in conf files and include application prefix file to Nginx prefixes file.
    sed -i 's/demo/wordpress/g' apps/wordpress/conf/nginx-prefix.conf apps/wordpress/conf/nginx-vhosts.conf
    echo -e 'include "/opt/bitnami/apps/wordpress/conf/nginx-prefix.conf";\n' >> /opt/bitnami/nginx/conf/bitnami/bitnami-apps-prefix.conf
    
     
    If you plan to use WordPress pretty permalinks, add this configuration snippet to your apps/wordpress/conf/nginx-app.conf before the location directive.
     
        if (!-e $request_filename)
        {
            rewrite ^/wordpress/(.+)$ /wordpress/index.php?q=$1 last;
        }
     
     
    Change ownership for WordPress app running the following command.
    chown -R bitnami apps/wordpress
    chown -R bitnami.daemon apps/wordpress/htdocs
     
     
    Create a database and user for WordPress 
    /opt/bitnami/mysql/bin/mysql -uroot -p
    ...
    create database bitnami_wordpress;
    grant all privileges on bitnami_wordpress.* to 'bn_wordpress'@'localhost' identified by 'WORDPRESS_PASSWORD';
    
     
    Keep in mind that  WORDPRESS_PASSWORD is the password that you are going to for WordPress database user.
     
    Now open in your browser http:/YOUR_DOMAIN/wordpress to see the web wizard. From here, simply follow the steps. You'll be asked for the database configuration and application credentials. For the database the credentials are those that you just specified in the previous command:
     
    Database Name: bitnami_wordpress
    
    User Name: bn_wordpress
    
    Password:  WORDPRESS_PASSWORD
    
    Database Host: localhost
    
    Table Prefix: wp_
     
    After adding this information you will have your WordPress site running!
     

    Screenshot from 2014-08-21 17:47:51.png

     

     

     

     

     

     

     

     

     

     
     

    How can I access phpMyAdmin?

    phpMyAdmin is a popular web-based management tools for the MySQL database.

    For security reasons, these applications are accessible only when using 127.0.0.1 as the hostname. To access them from a remote system, you must create an SSH tunnel that routes requests to the Apache Web server from 127.0.0.1. This implies that you must have an SSH private key and be able to connect to your server over SSH in order to access these applications remotely.
     

    IMPORTANT: Before following the steps below, ensure that your Apache and MySQL/PostgreSQL servers are running.

     

    NOTE: The steps below suggest using port 8888 for the SSH tunnel. If this port is already in use by another application on your local machine, replace it with any other port number greater than 1024 and modify the steps below accordingly. Similarly, if you have enabled Varnish, your stack's Apache Web server might be running on port 81. In this case, modify the steps below to use port 81 instead of port 80 for the tunnel endpoint.

     

    Follow the steps below for your platform.

    Bitnami Cloud Hosting

    On Windows:

    • Make sure you can log in to the server using PuTTY. Refer to these instructions for more information.
    • Open a new SSH session to the server and in the PuTTY settings for the new session, click "Connection → SSH → Tunnels" section and create a secure tunnel for the phpMyAdmin application by forwarding source port "8888" to destination port "localhost:80".
    • Click the "Add" button to add the secure tunnel configuration to the session.

    • Go back to the "Session" section and save your changes by clicking the "Save" button.
    • Click the "Open" button to open a new SSH session to the server.

    On Linux and Mac OS X:

    $ ssh -N -L 8888:127.0.0.1:80 -i bitnami-hosting.pem bitnami@xyz.bitnamiapp.com
    

    Remember to replace 'bitnami-hosting.pem' in the previous commands with the path to your private key file, and 'xyz.bitnamiapp.com' with the public IP address or hostname of your server. Note that if successful, this command will create an SSH tunnel but will not display any output on the server console.

    While the tunnel is active, you should be able to access phpMyAdmin and phpPgAdmin through the secure SSH tunnel you created, by browsing to http://127.0.0.1:8888/phpmyadmin and http://127.0.0.1:8888/phppgadmin respectively.

    To log in, use username 'root' for phpMyAdmin or 'postgres' for phpPgAdmin. For the application password, refer to the "Servers -> Manage Server" page of your Bitnami Cloud Hosting dashboard, under the "Application Password" section.

    Refer to this page for more information on obtaining application credentials.

    Microsoft Azure

    On Windows:

    • Make sure you can log in to the server using PuTTY. Refer to these instructions for more information.
    • Open a new SSH session to the server and in the PuTTY settings for the new session, click "Connection → SSH → Tunnels" section and create a secure tunnel for the phpMyAdmin application by forwarding source port "8888" to destination port "localhost:80".
    • Click the "Add" button to add the secure tunnel configuration to the session.

    • Go back to the "Session" section and save your changes by clicking the "Save" button.
    • Click the "Open" button to open a new SSH session to the server.

    On Linux and Mac OS X:

    $ ssh -N -L 8888:127.0.0.1:80 bitnami1@xyz.cloudapp.net
    

    Remember to replace 'bitnami1' with the SSH username from your credentials pair and 'xyz.cloudapp.net' with the public IP address or hostname of your server. Note that if successful, this command will create an SSH tunnel but will not display any output on the server console.

    While the tunnel is active, you should be able to access phpMyAdmin and phpPgAdmin through the secure SSH tunnel you created, by browsing to http://127.0.0.1:8888/phpmyadmin and http://127.0.0.1:8888/phppgadmin respectively.

    To log in, use username 'root' for phpMyAdmin or 'postgres' for phpPgAdmin and password 'bitnami'.

    Google Cloud Platform

    On Windows:

    • Make sure you can log in to the server using PuTTY. Refer to these instructions for more information.
    • Open a new SSH session to the server and in the PuTTY settings for the new session, click "Connection → SSH → Tunnels" section and create a secure tunnel for the phpMyAdmin application by forwarding source port "8888" to destination port "localhost:80".
    • Click the "Add" button to add the secure tunnel configuration to the session.

    • Go back to the "Session" section and save your changes by clicking the "Save" button.
    • Click the "Open" button to open a new SSH session to the server.

    On Linux and Mac OS X:

    $ ssh -N -L 8888:127.0.0.1:80 -i bitnami-gce-project-name.pem bitnami@100.101.102.103

    Remember to replace 'bitnami-gce-project-name.pem' in the previous commands with the path to your private key file, and '100.101.102.103' with the public IP address or hostname of your server. Note that if successful, this command will create an SSH tunnel but will not display any output on the server console.

    While the tunnel is active, you should be able to access phpMyAdmin and phpPgAdmin through the secure SSH tunnel you created, by browsing to http://127.0.0.1:8888/phpmyadmin and http://127.0.0.1:8888/phppgadmin respectively.

    To log in, use username 'root' for phpMyAdmin or 'postgres' for phpPgAdmin. For the application password, follow the steps below:

    • Browse to the Bitnami Launchpad for Google Cloud Platform dashboard and sign in if required using your Bitnami account.
    • Select the "Virtual Machines" menu item.
    • Select your Bitnami AMP Stack server from the resulting list.
    • Obtain credentials by selecting "Show" under "Credentials".

    Refer to this page for more information on obtaining application credentials.

    Virtual Machine

    On Windows:

    • Make sure you can log in to the server using PuTTY. Refer to these instructions for more information.
    • Open a new SSH session to the server and in the PuTTY settings for the new session, click "Connection → SSH → Tunnels" section and create a secure tunnel for the phpMyAdmin application by forwarding source port "8888" to destination port "localhost:80".
    • Click the "Add" button to add the secure tunnel configuration to the session.

    • Go back to the "Session" section and save your changes by clicking the "Save" button.
    • Click the "Open" button to open a new SSH session to the server.

    On Linux and Mac OS X:

    $ ssh -N -L 8888:127.0.0.1:80 bitnami@192.168.1.1
    

    Remember to replace '192.168.1.1' with the network IP address or hostname of your virtual server. Note that if successful, this command will create an SSH tunnel but will not display any output on the server console.

    While the tunnel is active, you should be able to access phpMyAdmin and phpPgAdmin through the secure SSH tunnel you created, by browsing to http://127.0.0.1:8888/phpmyadmin and http://127.0.0.1:8888/phppgadmin respectively.

    Alternative Approach: Allow Access from All Hosts

    Alternatively, if you are running the virtual machine in a secure environment, you can enable access to phpMyAdmin and phpPgAdmin from hosts other than 127.0.0.1 by editing the /opt/bitnami/apps/phpmyadmin/conf/httpd-app.conf file and modifying the Allow and Require directives as below:

      Default directive Modified directive
    Apache 2.2 Allow from 127.0.0.1 Allow from all
    Apache 2.4+ Require local Require all granted

    You can also use the example configuration file below if you wish:

     <IfDefine USE_PHP_FPM>
        <Proxy "unix:/opt/bitnami/php/var/run/phpmyadmin.sock|fcgi://phpmyadmin-fpm" timeout=300>
        </Proxy>
    </IfDefine>
    <Directory "/opt/bitnami/apps/phpmyadmin/htdocs">
    
    # AuthType Basic                                                                                                                                          
    # AuthName phpMyAdmin                                                                                                                                     
    # AuthUserFile "/opt/bitnami/apache2/users"                                                                                           
    # Require valid-user                                                                                                                                      
    AllowOverride None
    
    <IfModule php5_module>
            php_value upload_max_filesize 80M
    php_value post_max_size 80M
    </IfModule>
    
    <IfVersion < 2.3 >
    Order allow,deny
    Allow from all
    Satisfy all
    </IfVersion>
    <IfVersion >= 2.3>
    Require all granted
    </IfVersion>
    ErrorDocument 403 "For security reasons, this URL is only accesible using localhost (127.0.0.1) as the hostname"
    
    
        <IfDefine USE_PHP_FPM>
           <FilesMatch \.php$>
             SetHandler "proxy:fcgi://phpmyadmin-fpm/"
           </FilesMatch>
        </IfDefine>
    
    </Directory>
    

    Restart Apache to have the changes take effect:

    $ cd /opt/bitnami
    $ sudo ./ctlscript.sh restart apache
    

    You should now be able to access phpMyAdmin and phpPgAdmin by browsing to http://[virtual-machine-IP-address]/phpmyadmin and http://[virtual-machine-IP-address]/phppgadmin respectively.

    To log in, use username 'root' for phpMyAdmin or 'postgres' for phpPgAdmin. The default password is 'bitnami'.

    Native Installer

    You should be able to access phpMyAdmin directly, by browsing to http://127.0.0.1:8080/phpmyadmin or http://127.0.0.1/phpmyadmin.

    You should be able to access phpPgAdmin by browsing to http://127.0.0.1:8080/phppgadmin or http://127.0.0.1/phppgadmin.

    The username is 'root' for phpMyAdmin and 'postgres' for phpPgAdmin, and the password is the one specified by you during the installation process.

    Tabs end

     

    How to increase the upload size limit in Nginx Stack?

    You just need to add the  client_max_body_size directive inside the http section inside /opt/bitnami/nginx/conf/nginx.conf

    Note: For native installers you will need to replace /opt/bitnami with your Nginx Stack installation directory.

    For instance, to increse your upload size to 20MB you need to add the following line:

    client_max_body_size 20m;

    Also remember that you may want to increase the upload size limit for PHP. In this case, you can follow the steps described in Bitnami PHP Component : How to modify the allowed size for uploaded files?

    How to create a Virtual Host?

    You can configure the URL for the applications using Virtual Hosts. They would allow you to access the applications at "http://example.com/" or "http://prefix.example.com"  instead of "http://example.com/application". In this example we are going to configure WordPress to be accessible from "wordpress.example.com" 

    Note: For native installers you will need to replace /opt/bitnami with your current stack installation directory.

    1. Comment the line that includes the prefix configuration file in the /opt/bitnami/nginx/conf/bitnami/bitnami-apps-prefix.conf file:

    #Include "/opt/bitnami/apps/wordpress/conf/nginx-prefix.conf"
    

    2. Include the vhost configuration file for your application in the /opt/bitnami/nginx/conf/bitnami/bitnami-apps-vhosts.conf

    Include "/opt/bitnami/apps/wordpress/conf/nginx-vhosts.conf"
    

    3. Update the URL if it is necessary.

    In case the case of WordPress replace in /opt/bitnami/apps/wordpress/conf/nginx-app.conf the following

    rewrite ^/wordpress/(.+)$ /wordpress/index.php?q=$1 last;

    with

    rewrite ^/(.+)$ /index.php?q=$1 last;
    

    And then open your /opt/bitnami/apps/wordpress/htdocs/wp-config.php   and find the following comment:

    /* That's all, stop editing! Happy blogging. */

    You will need to add the following lines before this comment.

    define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');                   
    define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/'); 

    4. Restart the Nginx server:

    $ sudo /opt/bitnami/ctlscript.sh restart nginx
    
    Tag page (Edit tags)
    • No tags
    Page statistics
    24617 view(s), 41 edit(s) and 18135 character(s)

    Comments

    You must login to post a comment.