Complete: HTTPD+ PHP +MYSQL tutorial CENT OS 7

This how to will focus on the steps required to hosting multiple full domains or hosts on a web-server. This could be a virtual domain implementation for your corporate or home network. Maybe you’ve wanted to run web-packages and apply extra security on the applications and its sub-directories

Objectives:

  • Define packages required
  • Explain the steps of installation
  • Explain mode of security aspects.

Overview:

Apache: an open source implementation distributed freely under the GPL that will serve our web-pages

PHP: An opensource ,powerful, yet easy to use scripting language tool, that is extremely easy to setup

MySQL: An open source relational Database management system based on SQL (Structured Query Language) available on subscription under GPL. It provides rich Application programming interface (API) for many languages including C++, Java,

we will start by installing Apache and PHP with appropriate PHP, MySQL dependencies.

probably the first step if you have not already created a new directory, is to do it now;

sudo mkdir -p /var/www/serv.com/public_html

next is to grant permissions to the folder created; the -p flag suggests that the hierarchy of the parent directory is created automatically by this command

sudo chown -R apache:apache /var/www/serv/public_html

USE your favorite yum utility to  setup a virtual host, with username serv1. As our example access the file /etc/hosts using an editor maybe vi and add the following line:

172.32.0.1 serv1.com 

to make your website functional at this point, find at least the following data and insert your domain configuration:  enter into the apache configuration file itself.

sudo vi /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
 ServerAdmin webmaster@example.com
 DocumentRoot /var/www/serv.com/public_html
 ServerName www.serv.com
 ServerAlias serv.com
 ErrorLog /var/www/serv.com/error.log
 CustomLog /var/www/serv.com/requests.log
</VirtualHost>

If you need encryption for your domain (s) or if you have enabled ssl then you’ll have to check how ssl is running on your system

you can list virtual hosts available  with the command

# httpd -t -D DUMP_VHOSTS

reload configuration of your web server:

systemctl restart httpd

If you are running a firewall, add the following commands permanently to allow HTTP and HTTPS traffic. This will make apache work seamlessly work with PHP and its components:

sudo firewall-cmd --permanent --zone=public --add-service=http 
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

You can repeat these steps if you need to add other websites, though this may depend on where you’ve stored the website files. If it’s outside the web tree  or /usr/local, or …/htdocs, the owners of the folders should have read/write permissions. Anonymous apache users like wheel, www-data, nobody, (depending on the web-server release) should not be allowed to own the process for security reasons well documented.  it’s also strongly advised, that root should not own the webserver process. If it is in a production environment, it in-turn gives room for the webserver process to be accessible by its users.

Its a good idea now to create new users and give permissions for example: create two users to maintain the virtual domain and further give them read/write access to the folders.

Create two users under a group called SERV

First create group:

 groupadd SERV

Then create users that will maintain the website if any

usermod -a -G serv charles

usermod -a -G serv bob

chgrp -R SERV serv.com

chown -R charles serv.com

chown -R bob serv.com

chmod -R 755 serv.com

chmod g+s serv.com

Install PHP and MySQL

Use the yum command to install the MySQL libraries required to provide for separate environments and languages

$ yum install mysql mysql-server mysql-libs mysql-server

You may need to edit  the /etc/my.cnf

To start out the MySQL server use service:

$ service mysqld start

use chkconfig:

$ chkconfig --levels 235 mysqld on

Set the root user password for all local/virtual domains

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new-password');

SET PASSWORD FOR 'root'@'serv1.com' = PASSWORD('new-password');

SET PASSWORD FOR 'root'@'127.0.0.1' = PASSWORD('new-password');

Use yum system to install our PHP and its components. We’re going to include the php-mysql package as well:

sudo yum install php php-mysql 

restart the Apache web server in order for PHP to work without problems. You can do this by typing this:

sudo systemctl restart httpd.service

Install PHP Modules

To get advanced functionality of PHP, optionally we can install some additional modules. but that is beyond the discussion for this how to;

yum search php-*

The results are all optional components that you can install.

sudo yum install php-fpm

Testing PHP

open a blank file and put this valid php code.
sudo vi /var/www/html/info.php

<?php phpinfo(); ?>

Once you are done , via your browser’s URI type the below command
http://
your_server_IP_address/info.php

The page should look something like this:

Now you are ready to unpack your website into your virtual domain and apache is ready to serve its pages.

Install Sphinx Search Server from source

Introduction

Sphinx is an open source internet search engine that enables full-text searches. It’s noted for performing large data searches efficiently and the information to get indexed can generally be derived from various unique sources: (SQL databases, plain text files, HTML files, mailboxes, and the like.

Sphinx Search Server was written by Andrew Aksyonoff,  popular features of the Sphinx are high performance since it is designed in C++, an excellent and efficient tool with relevant ranking, abilities to develop search index.

To obtain the latest stable Sphinx Search Server version navigate to the official Sphinx downloads page http://sphinxsearch.com/downloads/release/for  prepared packages ready for install packages for different Linux distributions (Ubuntu, RHEL, Debian, etc.). However it’s preferable to install Sphinx server from source.

Some key features of Sphinx are:

  • High indexing and searching performance
  • Advanced indexing and querying tools
  • Advanced result set post-processing
  • Proven scalability up to billions of documents, terabytes of data, and thousands of queries per second
  • Easy integration with SQL and XML data sources, and SphinxQL, SphinxAPI, or SphinxSE search interfaces
  • Easy scaling with distributed searches

Prerequisites

  • A Ubuntu 14.04 Droplet.
  • Non-root privileges are required for this setup

Step 1 – Installing MySQL Server

Note: Check if you have Mysql server, otherwise skip this section and head to step 2

MySQL helps to store   sample data that  can be used to test Sphinx’s search abilities.

Update the package list.

sudo apt-get update

Then install MySQL server.

sudo apt-get install mysql-server

Enter a password for the root user when asked, and enter the same password again to confirm.

Step 2 – Installing Sphinx

In this section, we will install Sphinx.

To install Sphinx, run:

sudo apt-get install sphinxsearch

Now you have successfully installed Sphinx on your server. Before starting the Sphinx daemon, let’s configure it.

Step 3 – Creating the Test Database

In this section, we will set up a database using the example SQL file provided with the package.

Let’s import an example SQL file into the database.

Log in to the MySQL server shell.

mysql -u root -p

Enter the password for the MyQL root user when asked. Your prompt will change to mysql>.

Create a database named test.

CREATE DATABASE test;

Import the SQL file.

SOURCE /etc/sphinxsearch/example.sql;

Then exit the MySQL shell.

quit

Now you should have the test database filled with data.

Step 4 – Configuring Sphinx

In this section, we will configure the Sphinx configuration file.

Create the sphinx.conf file.

sudo nano /etc/sphinxsearch/sphinx.conf
Sphinx configuration consists of 3 main blocks that are essential to run. They are index, searchd, and source. Each of these blocks is described below, and at the end of this step, the entirety of sphinx.conf is included for you to paste into the file.

The source block contains the type of source, username and password to the MySQL server. The first column of the SQL query should be a unique id. The SQL query will run on every index and dump the data to Sphinx index file. Below are descriptions of each field and the source block itself.
  • sql_host: Hostname for the MySQL host. In our example, this is the localhost. This can be a domain or IP address.
  • sql_user: Username for the MySQL login. In our example, this is root.
  • sql_pass: Password for the MySQL user. In our example, this is the root MySQL user's password
  • sql_db: Name of the database that stores data. In our example, this is test.
  • sql_query: This is the query thats dumps data to index.
source src1{  type          = mysql   sql_host      = localhost  sql_user      = root  sql_pass      = password  sql_db        = test  sql_port      = 3306 # optional, default is 3306   sql_query     = \  SELECT id, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content \  FROM documents   sql_attr_uint     = group_id  sql_attr_timestamp    = date_added   sql_query_info        = SELECT * FROM documents WHERE id=$id} 

The index component contains the source and the path to store the data.
  • source: Name of the source block. In our example, this is src1.
  • path: This path to save the index.
  • charset_type: This is the charset of the index. You also set this to utf-8.
index test1{  source            = src1  path          = /var/lib/sphinxsearch/data/test1  docinfo           = extern  charset_type      = sbcs}

The searchd component contains the port and other variables to run the Sphinx daemon.
  • listen: This is the port which sphinx daemon will run. In our example, this is 9312.
  • query_log: This path to save the query log.
  • pid_file: This is path to PID file of Sphinx daemon.
  • max_matches: Maximum number matches to return per search term.
  • seamless_rotate: Prevents searchd stalls while rotating indexes with huge amounts of data to precache.
  • preopen_indexes: Whether to forcibly preopen all indexes on startup.
  • unlink_old: Whether to unlink old index copies on successful rotation.
searchd{  listen            = 9312   # Port to listen on  log           = /var/log/sphinxsearch/searchd.log  query_log     = /var/log/sphinxsearch/query.log  read_timeout      = 5  max_children      = 30  pid_file      = /var/run/sphinxsearch/searchd.pid  max_matches       = 1000  seamless_rotate       = 1  preopen_indexes       = 1  unlink_old        = 1  binlog_path       = /var/lib/sphinxsearch/data}

The full configuration to copy and paste is below. The only variable you need to change below is the sql_pass in the source block, which is highlighted.

source src1{  type          = mysql   sql_host      = localhost  sql_user      = root  sql_pass      = password # change this to your root users MySQL password  sql_db        = test  sql_port      = 3306   sql_query     = \  SELECT id, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content \  FROM documents   sql_attr_uint         = group_id  sql_attr_timestamp    = date_added   sql_query_info        = SELECT * FROM documents WHERE id=$id}index test1{  source            = src1  path              = /var/lib/sphinxsearch/data/test1  docinfo           = extern  charset_type      = sbcs}searchd{  listen            = 9312  log               = /var/log/sphinxsearch/searchd.log  query_log         = /var/log/sphinxsearch/query.log  read_timeout      = 5  max_children      = 30  pid_file          = /var/run/sphinxsearch/searchd.pid  max_matches       = 1000  seamless_rotate   = 1  preopen_indexes   = 1  unlink_old        = 1  binlog_path       = /var/lib/sphinxsearch/data}

Step 5 – Adding Data to the Index

In this section, we’ll add data to the Sphinx index.

Add data to index using the config we created earlier.

sudo indexer --all

You should get something that looks like the following.

Sphinx 2.0.4-id64-release (r3135)Copyright (c) 2001-2012, Andrew AksyonoffCopyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com) using config file ‘/etc/sphinxsearch/sphinx.conf’…indexing index ‘test1’…WARNING: collect_hits: mem_limit=0 kb too low, increasing to 25600 kbcollected 4 docs, 0.0 MBsorted 0.0 Mhits, 100.0% donetotal 4 docs, 193 bytestotal 0.005 sec, 33788 bytes/sec, 700.28 docs/sectotal 3 reads, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avgtotal 9 writes, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg

To keep the index up to date, lets create a cronjob.

Open crontab.

crontab -e

You may be asked which text editor you want to use. Choose whichever you prefer; in this tutorial, we’ve used nano.

Copy and paste the following at the end of the file, then save and close it.

@hourly /usr/bin/indexer --rotate --config /etc/sphinxsearch/sphinx.conf --all

The above cronjob will run on every hour and add new data to the index using the default config file.

Step 6 – Starting Sphinx

In this section, we’ll start the Sphinx daemon.

By default, the Sphinx daemon is tuned off. To enable Sphinx, first open /etc/default/sphinxsearch.

sudo nano /etc/default/sphinxsearch

Find the line START=no and set it to yes.

START=yes

Then, save and close the file.

Finally, start the Sphinx daemon.

sudo service sphinxsearch start

Step 7 – Testing Search

In this section, we will test our search. Enter the following command.

search this is my test document number

You should get something that looks like the following.

Sphinx 2.0.4-id64-release (r3135)Copyright (c) 2001-2012, Andrew AksyonoffCopyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com) using config file ‘/etc/sphinxsearch/sphinx.conf’…index ‘test1’: query ‘this is my test document number ‘: returned 2 matches of 2 total in 0.002 sec displaying matches:1. document=1, weight=7431, group_id=1, date_added=Tue Dec 16 09:49:04 2014id=1group_id=1group_id2=5date_added=2014-12-16 09:49:04title=test onecontent=this is my test document number one. also checking search within phrases.2. document=2, weight=7431, group_id=1, date_added=Tue Dec 16 09:49:04 2014id=2group_id=1group_id2=6date_added=2014-12-16 09:49:04title=test twocontent=this is my test document number two words:1. ‘this’: 4 documents, 4 hits2. ‘is’: 4 documents, 4 hits3. ‘my’: 2 documents, 2 hits4. ‘test’: 3 documents, 5 hits5. ‘document’: 2 documents, 2 hits6. ‘number’: 3 documents, 3 hits

Above you can find 2 matches from our test index for our search term. You can also find matches per word.

Installing Percona Server and the debugging tools in CentOS7/RHEL6.x

Installing Percona Server using downloaded rpm packages
  1. Download there required packages for your machine architecture from the source page. The easiest way is to download bundle which contains all the packages. Following example will download Percona Server 5.5.44-37.3 release packages for CentOS 6:
  1. wget https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-5.5.44-37.3/binary/redhat/6/x86_64/Percona-Server-5.5.44-37.3-r729fbe2-el6-x86_64-bundle.tar
  1. untar the bundle :
  1. tar xvf Percona-Server-5.5.44-37.3-r729fbe2-el6-x86_64-bundle.tar

After you untar the bundle you can confirm that the following packages are present:

$ ls *.rpm
Percona-Server-55-debuginfo-5.5.44-rel37.3.el6.x86_64.rpm
Percona-Server-client-55-5.5.44-rel37.3.el6.x86_64.rpm
Percona-Server-devel-55-5.5.44-rel37.3.el6.x86_64.rpm
Percona-Server-server-55-5.5.44-rel37.3.el6.x86_64.rpm
Percona-Server-shared-55-5.5.44-rel37.3.el6.x86_64.rpm
Percona-Server-test-55-5.5.44-rel37.3.el6.x86_64.rpm
  1. Now you can install Percona Server by running:
    rpm -ivh Percona-Server-server-55-5.5.44-rel37.3.el6.x86_64.rpm Percona-Server-client-55-5.5.44-rel37.3.el6.x86_64.rpm Percona-Server-shared-55-5.5.44-rel37.3.el6.x86_64.rpm

Then install the main Percona Server and all other packages required for debugging , testing, etc.) you should run:

rpm -ivh *.rpm

NB

During a manual compilation like this one , you need to resolve all the dependencies and missing packages yourself as it is not retrieved from a repository.

Running Percona Server

The default directory where Percona Server  stores data files is the /var/lib/mysql/. The main configuration file that will affect and handle the operation of the Percona Server  is the /etc/my.cnf. file

  1. Starting the service

Percona Server isn’t started automatically on RHEL and CentOS after it gets installed. You should start it by running:

service mysql start
  1. Confirming that service is running

You can check the service status by running:

service mysql status
  1. Stopping the service

You can stop the service by running:

service mysql stop
  1. Restarting the service

You can restart the service by running:

service mysql restart

Note

RHEL 7 and CentOS 7 come with systemd as the default system and service manager so you can invoke all the above commands with sytemctl instead of service. Currently both are supported.

Uninstalling Percona Server

To completely uninstall Percona Server you’ll need to remove all the installed packages and data files.

  1. Stop the Percona Server service
    service mysql stop
  1. Remove the packages
    yum remove Percona-Server*
  1. Remove the data and configuration files
    rm -rf /var/lib/mysql
    rm -f /etc/my.cnf

Warning*

This will remove all the packages and delete all the data files (databases, tables, logs, etc.), you might want to take a backup before doing this in case you need the data.

Configuring Barracuda NextGen Firewall for your Azure Cloud Integration using ARM

Azure Cloud integration enables the firewall to connect to get in touch to the Azure service fabric to rewrite Azure User Defined Routes monitor the IP Forwarding setting NIC of the respective firewall VM.  Azure User Defined Routing enables you permits you to use Firewall F-Series high availability cluster within the public subnet since the default gateway for all those VMs running at backend networks.

Enable IP forwarding for a firewall VMs and apply an Azure routing table to the backend networks. By using a management certificate with an Azure subscriber ID, the firewall VMs can alter the Azure routing table over the fly in the event the virtual server fails over from a VM to another. Azure route table rewriting has to be configured about the primary and secondary F-Series Firewall. In case a global HTTP proxy is configured, all REST API calls are sent via through proxy.

steps

For the firewall to be able to connect to the Azure backend, you must create and upload a management certificate. The certificate must be valid for at least two years.

  1. Log into the firewall via ssh.
  2. Create the certificate:
    1. openssl req x509 nodes days 1095 newkey rsa:2048 keyout arm.pem out arm.pem
  3. Answer the questions at the prompt. The Common Name is used to identify this certificate in the Azure web interface.
  4. Convert the certificate to CER, as required by Azure:
    1. openssl x509 inform pem in arm.pem outform der out arm.cer
  5. Extract the RSA key:
    1. openssl rsa in arm.pem out arm.key.pem

You now have three certificates: arm.pem, arm.key.pem and arm.cer.

Step 2. Create a custom Azure access control role for Cloud Integration

Create a custom role to use with Cloud Integration.

The role name must be unique.

  1. Launch Azure PowerShell.
  2. Create a new role by cloning an existing role. Clear all privileges and then add just the privileges needed for Cloud Integration. The subscription ID must be entered in the following format: "/subscriptions/abcdefg1234567891011212".
    1. # Create a custom role for NGF Cloud Integration. An existing role is cloned, all rights removed and then assigned proper privileges
    2. $role = GetAzureRmRoleDefinition “Virtual Machine Contributor”
    3. $role.Id = $null
    4. $role.Name = ‘NGF Role’
    5. $role.Description = “Barracuda NextGen Firewall Cloud Integration”
    6. $role.Actions.Clear()
    7.  
    8. # Add role definitions to the empty role
    9. $role.Actions.Add(“Microsoft.Compute/virtualMachines/*”)
    10. $role.Actions.Add(“Microsoft.Network/*”)
    11. $role.AssignableScopes.Clear()
    12. $role.AssignableScopes.Add(YOUR_SUBSCRIPTION_ID)
    13. $firewallRole = NewAzureRmRoleDefinition Role $role

Step 3. Upload the Azure management certificate via Azure PowerShell

The identifierURis must be unique.

  1. Launch Azure PowerShell.
  2. Execute the following commands to import arm.cer as a management certificate:
    1. LoginAzureRmAccount
    2. $cert = NewObject System.Security.Cryptography.X509Certificates.X509Certificate(“PATH_TO_CER_FILE”)
    3. $key = [System.Convert]::ToBase64String($cert.GetRawCertData())
    4. $app = NewAzureRmADApplication DisplayName “DISPLAY_NAME” HomePage http://localhost&#8221; IdentifierUris http://localhost&#8221; CertValue $key
    5. # write down the application ID ($app.ApplicationID is the “client ID” in NextGen Admin)
    6. NewAzureRmADServicePrincipal ApplicationId $app.ApplicationId
    7. # wait for the service principal to be created
    8. StartSleep Seconds 10
    9. # in the command below, you can use “-Scope” to restrict permissions to specific resource groups
    10. NewAzureRmRoleAssignment RoleDefinitionName $firewallRole.Name ServicePrincipalName $princ.ServicePrincipalNames[0]
Monitoring

Go to NETWORK > Azure UDR to see the UDR routing table for all subnets in the firewalls VNET. Routes using the firewall VM as the nexthop are marked with a green icon. During the UDR HA failover process this icon changes to red.

arm-udr_01

All activity is logged to the Box\Control\daemon log file

arm-udr_02

script for azure version 2.5
$pathToCERfile = 'PATH_TO\arm.cer'
$ADAppName = 'DOCNGF'
$roleDefName = 'Network Contributor' 
# Set the resource group the Azure Route Table is in 
$resourceGroupName = 'RESOURCE_GROUP_NAME'
# your subscription ID
$subscriptionid = 'YOURSUBSCRIPTIONID'
# the identifier must be unique
$identifier = 'http://localhost'
# the identifier and role name must both be unique
$identifier = 'http://localhost'
$roleName = 'NGF Role'
# Select the Azure subscription
Select-AzureRmSubscription -SubscriptionId $subscriptionID
# Create a custom role for NGF Cloud Integration. An existing role is cloned, all rights removed and then assigned proper privileges
$role = Get-AzureRmRoleDefinition "Virtual Machine Contributor"
$role.Id = $null
$role.Name = $roleName
$role.Description = "Barracuda NextGen Firewall Cloud Integration"
$role.Actions.Clear()
# Add role definitions to the empty role 
$role.Actions.Add("Microsoft.Compute/virtualMachines/*")
$role.Actions.Add("Microsoft.Network/*")
$role.AssignableScopes.Clear()
$role.AssignableScopes.Add($subscriptionID)
$firewallRole = New-AzureRmRoleDefinition -Role $role
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate($pathToCERfile)
$key = [System.Convert]::ToBase64String($cert.GetRawCertData())
$app = New-AzureRmADApplication -DisplayName $ADAppName -HomePage $identifier -IdentifierUris $identifier -CertValue $key
New-AzureRmADServicePrincipal -ApplicationId $app.ApplicationId -Verbose
#wait for the service principal to be created 
Start-Sleep -Seconds 10
New-AzureRmRoleAssignment -RoleDefinitionName $firewallRole -ServicePrincipalName $app.ApplicationId
script for  Azure PowerShell version 3.1
$pathToCERfile = 'PATH_TO\arm.cer'
$ADAppName = 'NGF'
# Set the resource group the Azure Route Table is in 
$resourceGroupName = 'RESOURCE_GROUP_NAME'
# your subscription ID
$subscriptionID = 'YOURSUBSCRIPTIONID'
# the identifier and role name must both be unique
$identifier = 'http://localhost'
$roleName = 'NGF Role'
# Select the Azure subscription
Select-AzureRmSubscription -SubscriptionId $subscriptionID
# Create a custom role for NGF Cloud Integration. An existing role is cloned, all rights removed and then assigned proper privileges
$role = Get-AzureRmRoleDefinition "Virtual Machine Contributor"
$role.Id = $null
$role.Name = $roleName
$role.Description = "Barracuda NextGen Firewall Cloud Integration"
$role.Actions.Clear()
# Add role definitions to the empty role 
$role.Actions.Add("Microsoft.Compute/virtualMachines/*")
$role.Actions.Add("Microsoft.Network/*")
$role.AssignableScopes.Clear()
$role.AssignableScopes.Add($subscriptionID)
$firewallRole = New-AzureRmRoleDefinition -Role $role
# convert and upload the authentication certificate 
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate($pathToCERfile)
$key = [System.Convert]::ToBase64String($cert.GetRawCertData())
$app = New-AzureRmADApplication -DisplayName $ADAppName -HomePage $identifier -IdentifierUris $identifier -CertValue $key
New-AzureRmADServicePrincipal -ApplicationId $app.ApplicationId -Verbose
#wait for the service principal to be created 
Start-Sleep -Seconds 10
New-AzureRmRoleAssignment -RoleDefinitionName $firewallRole.Name -ServicePrincipalName $princ.ServicePrincipalNames[0]

How to install Zimbra Collaboration Suite 8.6.0 On RHEL6/CentOS 7

Overview:

Zimbra Collaboration Suite (ZCS) is an enterprise-class cloud solution for both private and public with a redesigned browser-based interface. Zimbra provides the innovative messaging experience currently available on the market today, connecting users to their personal information, activity, and remote personal clouds retrieval. It is a groupware product that can be trusted where users can share folders, contacts, schedules with its rich additional web interface.

This post will show in brief  the steps to setup Zimbra 8.6. on RHEL 7 or CentOS 7.

 Prerequisites
  • CentOS 7 or a RHEL 6 server.
  •  root priviledges are required*
  • A fully qualified domain name ( FQDN ) for your Zimbra mail server mx record and ensure your domain is configured correctly.

1. Edit your /etc/hosts and hostname files

2. Allow  Zimbra ports TCP traffic to pass through iptables .

3.  Disabled SELINUX

[root@centos7 ~]# vim /etc/sysconfig/selinux

Change enforcing to disabled :

retrieve the tarball from the sourec website and extract its contents
tar xzf zcs-8.6.0_GA_1153.RHEL7_64.20141215151110.tgz
then change directory
cd zcs-8.6.0_GA_1153.RHEL7_64.20141215151110

install the ZCS script provided in the folder  and follow by answering carefully a terse set of questions and instructions using the next commands.

./install.sh --platform-override

Operations logged to /tmp/install.log.14668
Checking for existing installation...
    zimbra-ldap...NOT FOUND
    zimbra-logger...NOT FOUND
    zimbra-mta...NOT FOUND
    zimbra-dnscache...NOT FOUND
    zimbra-snmp...NOT FOUND
    zimbra-store...NOT FOUND
    zimbra-apache...NOT FOUND
    zimbra-spell...NOT FOUND
    zimbra-convertd...NOT FOUND
    zimbra-memcached...NOT FOUND
    zimbra-proxy...NOT FOUND
    zimbra-archiving...NOT FOUND
    zimbra-core...NOT FOUND


PLEASE READ THIS AGREEMENT CAREFULLY BEFORE USING THE SOFTWARE.
ZIMBRA, INC. ("ZIMBRA") WILL ONLY LICENSE THIS SOFTWARE TO YOU IF YOU
FIRST ACCEPT THE TERMS OF THIS AGREEMENT. BY DOWNLOADING OR INSTALLING
THE SOFTWARE, OR USING THE PRODUCT, YOU ARE CONSENTING TO BE BOUND BY
THIS AGREEMENT. IF YOU DO NOT AGREE TO ALL OF THE TERMS OF THIS
AGREEMENT, THEN DO NOT DOWNLOAD, INSTALL OR USE THE PRODUCT.

License Terms for the Zimbra Collaboration Suite:

http://www.zimbra.com/license/zimbra-public-eula-2-5.html

Do you agree with the terms of the software license agreement? [N] y



Checking for prerequisites...
     FOUND: NPTL
     FOUND: nmap-ncat-6.40-4
     FOUND: sudo-1.8.6p7-11
     FOUND: libidn-1.28-3
     FOUND: gmp-5.1.1-5
     FOUND: libaio-0.3.109-12
     FOUND: libstdc++-4.8.2-16.2
     FOUND: unzip-6.0-13
     FOUND: perl-core-5.16.3-283

Checking for suggested prerequisites...
     FOUND: perl-5.16.3
     FOUND: sysstat
     FOUND: sqlite
Prerequisite check complete.

Checking for installable packages

Found zimbra-core
Found zimbra-ldap
Found zimbra-logger
Found zimbra-mta
Found zimbra-dnscache
Found zimbra-snmp
Found zimbra-store
Found zimbra-apache
Found zimbra-spell
Found zimbra-memcached
Found zimbra-proxy


Select the packages to install

Install zimbra-ldap [Y]

Install zimbra-logger [Y]

Install zimbra-mta [Y]

Install zimbra-dnscache [Y] N

Install zimbra-snmp [Y]

Install zimbra-store [Y]

Install zimbra-apache [Y]

Install zimbra-spell [Y]

Install zimbra-memcached [Y]

Install zimbra-proxy [Y]
Checking required space for zimbra-core
Checking space for zimbra-store
Checking required packages for zimbra-store
zimbra-store package check complete.

Installing:
    zimbra-core
    zimbra-ldap
    zimbra-logger
    zimbra-mta
    zimbra-snmp
    zimbra-store
    zimbra-apache
    zimbra-spell
    zimbra-memcached
    zimbra-proxy

The system will be modified.  Continue? [N] Y

Removing /opt/zimbra
Removing zimbra crontab entry...done.
Cleaning up zimbra init scripts...done.
Cleaning up /etc/ld.so.conf...done.
Cleaning up /etc/security/limits.conf...done.

Finished removing Zimbra Collaboration Server.

Installing packages

    zimbra-core......zimbra-core-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-ldap......zimbra-ldap-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-logger......zimbra-logger-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-mta......zimbra-mta-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-snmp......zimbra-snmp-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-store......zimbra-store-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-apache......zimbra-apache-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-spell......zimbra-spell-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-memcached......zimbra-memcached-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
    zimbra-proxy......zimbra-proxy-8.6.0_GA_1153.RHEL7_64-20141215151110.x86_64.rpm...done
Operations logged to /tmp/zmsetup01032015-084819.log
Installing LDAP configuration database...done.
Setting defaults...No results returned for A lookup of centos7.unixmen.local
Checked nameservers:
        192.168.0.70
No results returned for AAAA lookup of centos7.unixmen.local
Checked nameservers:
        192.168.0.70


DNS ERROR resolving centos7.unixmen.local
It is suggested that the hostname be resolvable via DNS
Change hostname [Yes]
Please enter the logical hostname for this host [centos7.unixmen.local] mail.example.com
No results returned for A lookup of mail.example.com
Checked nameservers:
        192.168.0.70


DNS ERROR resolving mail.example.com
It is suggested that the hostname be resolvable via DNS
Re-Enter hostname [Yes]
Please enter the logical hostname for this host [centos7.unixmen.local] mail.example.local


DNS ERROR resolving MX for mail.example.local
It is suggested that the domain name have an MX record configured in DNS
Change domain name? [Yes]
Create domain: [mail.example.local] example.local
        MX: mail.example.local (192.168.0.70)

        Interface: 127.0.0.1
        Interface: ::1
        Interface: 192.168.0.70
done.
Checking for port conflicts

Main menu

   1) Common Configuration:
   2) zimbra-ldap:                             Enabled
   3) zimbra-logger:                           Enabled
   4) zimbra-mta:                              Enabled
   5) zimbra-snmp:                             Enabled
   6) zimbra-store:                            Enabled
        +Create Admin User:                    yes
        +Admin user to create:                 admin@example.local
******* +Admin Password                        UNSET
        +Anti-virus quarantine user:           virus-quarantine.fsbv7fj6r0@example.local
        +Enable automated spam training:       yes
        +Spam training user:                   spam.7xlmrmrh3@example.local
        +Non-spam(Ham) training user:          ham.rt_1on1o@example.local
        +SMTP host:                            mail.example.local
        +Web server HTTP port:                 8080
        +Web server HTTPS port:                8443
        +Web server mode:                      https
        +IMAP server port:                     7143
        +IMAP server SSL port:                 7993
        +POP server port:                      7110
        +POP server SSL port:                  7995
        +Use spell check server:               yes
        +Spell server URL:                     http://mail.example.local:7780/aspell.php
        +Enable version update checks:         TRUE
        +Enable version update notifications:  TRUE
        +Version update notification email:    admin@centos7.unixmen.local
        +Version update source email:          admin@centos7.unixmen.local
        +Install mailstore (service webapp):   yes
        +Install UI (zimbra,zimbraAdmin webapps): yes

   7) zimbra-spell:                            Enabled
   8) zimbra-proxy:                            Enabled
   9) Enable VMware HA:                        no
  10) Default Class of Service Configuration:
   s) Save config to file
   x) Expand menu
   q) Quit

Address unconfigured (**) items  (? - help) 6


Store configuration

   1) Status:                                  Enabled
   2) Create Admin User:                       yes
   3) Admin user to create:                    admin@example.local
** 4) Admin Password                           UNSET
   5) Anti-virus quarantine user:              virus-quarantine.fsbv7fj6r0@example.local
   6) Enable automated spam training:          yes
   7) Spam training user:                      spam.7xlmrmrh3@example.local
   8) Non-spam(Ham) training user:             ham.rt_1on1o@example.local
   9) SMTP host:                               mail.example.local
  10) Web server HTTP port:                    8080
  11) Web server HTTPS port:                   8443
  12) Web server mode:                         https
  13) IMAP server port:                        7143
  14) IMAP server SSL port:                    7993
  15) POP server port:                         7110
  16) POP server SSL port:                     7995
  17) Use spell check server:                  yes
  18) Spell server URL:                        http://mail.example.local:7780/aspell.php
  19) Enable version update checks:            TRUE
  20) Enable version update notifications:     TRUE
  21) Version update notification email:       admin@centos7.unixmen.local
  22) Version update source email:             admin@centos7.unixmen.local
  23) Install mailstore (service webapp):      yes
  24) Install UI (zimbra,zimbraAdmin webapps): yes

Select, or 'r' for previous menu [r] 4

Password for admin@example.local (min 6 characters): [SBmeBXtA] password

Store configuration

   1) Status:                                  Enabled
   2) Create Admin User:                       yes
   3) Admin user to create:                    admin@example.local
   4) Admin Password                           set
   5) Anti-virus quarantine user:              virus-quarantine.fsbv7fj6r0@example.local
   6) Enable automated spam training:          yes
   7) Spam training user:                      spam.7xlmrmrh3@example.local
   8) Non-spam(Ham) training user:             ham.rt_1on1o@example.local
   9) SMTP host:                               mail.example.local
  10) Web server HTTP port:                    8080
  11) Web server HTTPS port:                   8443
  12) Web server mode:                         https
  13) IMAP server port:                        7143
  14) IMAP server SSL port:                    7993
  15) POP server port:                         7110
  16) POP server SSL port:                     7995
  17) Use spell check server:                  yes
  18) Spell server URL:                        http://mail.example.local:7780/aspell.php
  19) Enable version update checks:            TRUE
  20) Enable version update notifications:     TRUE
  21) Version update notification email:       admin@centos7.unixmen.local
  22) Version update source email:             admin@centos7.unixmen.local
  23) Install mailstore (service webapp):      yes
  24) Install UI (zimbra,zimbraAdmin webapps): yes

Select, or 'r' for previous menu [r] 21

Version update destination address: [admin@centos7.unixmen.local] admin@example.local

Store configuration

   1) Status:                                  Enabled
   2) Create Admin User:                       yes
   3) Admin user to create:                    admin@example.local
   4) Admin Password                           set
   5) Anti-virus quarantine user:              virus-quarantine.fsbv7fj6r0@example.local
   6) Enable automated spam training:          yes
   7) Spam training user:                      spam.7xlmrmrh3@example.local
   8) Non-spam(Ham) training user:             ham.rt_1on1o@example.local
   9) SMTP host:                               mail.example.local
  10) Web server HTTP port:                    8080
  11) Web server HTTPS port:                   8443
  12) Web server mode:                         https
  13) IMAP server port:                        7143
  14) IMAP server SSL port:                    7993
  15) POP server port:                         7110
  16) POP server SSL port:                     7995
  17) Use spell check server:                  yes
  18) Spell server URL:                        http://mail.example.local:7780/aspell.php
  19) Enable version update checks:            TRUE
  20) Enable version update notifications:     TRUE
  21) Version update notification email:       admin@example.local
  22) Version update source email:             admin@centos7.unixmen.local
  23) Install mailstore (service webapp):      yes
  24) Install UI (zimbra,zimbraAdmin webapps): yes

Select, or 'r' for previous menu [r] 22

Version update source address: [admin@centos7.unixmen.local] admin@example.local

Store configuration

   1) Status:                                  Enabled
   2) Create Admin User:                       yes
   3) Admin user to create:                    admin@example.local
   4) Admin Password                           set
   5) Anti-virus quarantine user:              virus-quarantine.fsbv7fj6r0@example.local
   6) Enable automated spam training:          yes
   7) Spam training user:                      spam.7xlmrmrh3@example.local
   8) Non-spam(Ham) training user:             ham.rt_1on1o@example.local
   9) SMTP host:                               mail.example.local
  10) Web server HTTP port:                    8080
  11) Web server HTTPS port:                   8443
  12) Web server mode:                         https
  13) IMAP server port:                        7143
  14) IMAP server SSL port:                    7993
  15) POP server port:                         7110
  16) POP server SSL port:                     7995
  17) Use spell check server:                  yes
  18) Spell server URL:                        http://mail.example.local:7780/aspell.php
  19) Enable version update checks:            TRUE
  20) Enable version update notifications:     TRUE
  21) Version update notification email:       admin@example.local
  22) Version update source email:             admin@example.local
  23) Install mailstore (service webapp):      yes
  24) Install UI (zimbra,zimbraAdmin webapps): yes

Select, or 'r' for previous menu [r] r

Main menu

   1) Common Configuration:
   2) zimbra-ldap:                             Enabled
   3) zimbra-logger:                           Enabled
   4) zimbra-mta:                              Enabled
   5) zimbra-snmp:                             Enabled
   6) zimbra-store:                            Enabled
   7) zimbra-spell:                            Enabled
   8) zimbra-proxy:                            Enabled
   9) Enable VMware HA:                        no
  10) Default Class of Service Configuration:
   s) Save config to file
   x) Expand menu
   q) Quit

*** CONFIGURATION COMPLETE - press 'a' to apply
Select from menu, or press 'a' to apply config (? - help) a
Save configuration data to a file? [Yes]
Save config in file: [/opt/zimbra/config.23920]
Saving config in /opt/zimbra/config.23920...done.
The system will be modified - continue? [No] yes
Operations logged to /tmp/zmsetup01032015-084819.log
Setting local config values...done.
Initializing core config...Setting up CA...done.
Deploying CA to /opt/zimbra/conf/ca ...done.
Creating SSL zimbra-store certificate...done.
Creating new zimbra-ldap SSL certificate...done.
Creating new zimbra-mta SSL certificate...done.
Creating new zimbra-proxy SSL certificate...done.
Installing mailboxd SSL certificates...done.
Installing MTA SSL certificates...done.
Installing LDAP SSL certificate...done.
Installing Proxy SSL certificate...done.
Initializing ldap...done.
Setting replication password...done.
Setting Postfix password...done.
Setting amavis password...done.
Setting nginx password...done.
Setting BES searcher  password...done.
Creating server entry for mail.example.local...done.
Setting Zimbra IP Mode...done.
Saving CA in ldap ...done.
Saving SSL Certificate in ldap ...done.
Setting spell check URL...done.
Setting service ports on mail.example.local...done.
Setting zimbraFeatureTasksEnabled=TRUE...done.
Setting zimbraFeatureBriefcasesEnabled=TRUE...done.
Setting TimeZone Preference...done.
Initializing mta config...done.
Setting services on mail.example.local...done.
Adding mail.example.local to zimbraMailHostPool in default COS...done.
Creating domain example.local...done.
Setting default domain name...done.
Creating domain example.local...already exists.
Creating admin account admin@example.local...done.
Creating root alias...done.
Creating postmaster alias...done.
Creating user spam.7xlmrmrh3@example.local...done.
Creating user ham.rt_1on1o@example.local...done.
Creating user virus-quarantine.fsbv7fj6r0@example.local...done.
Setting spam training and Anti-virus quarantine accounts...done.
Initializing store sql database...done.
Setting zimbraSmtpHostname for mail.example.local...done.
Configuring SNMP...done.
Setting up syslog.conf...done.
Starting servers...done.
Installing common zimlets...
        com_zimbra_proxy_config...done.
        com_zimbra_mailarchive...done.
        com_zimbra_attachmail...done.
        com_zimbra_url...done.
        com_zimbra_phone...done.
        com_zimbra_date...done.
        com_zimbra_ymemoticons...done.
        com_zimbra_clientuploader...done.
        com_zimbra_srchhighlighter...done.
        com_zimbra_tooltip...done.
        com_zimbra_webex...done.
        com_zimbra_bulkprovision...done.
        com_zimbra_email...done.
        com_zimbra_adminversioncheck...done.
        com_zimbra_cert_manager...done.
        com_zimbra_viewmail...done.
        com_zimbra_attachcontacts...done.
Finished installing common zimlets.
Restarting mailboxd...done.
Creating galsync account for default domain...done.

You have the option of notifying Zimbra of your installation.
This helps us to track the uptake of the Zimbra Collaboration Server.
The only information that will be transmitted is:
        The VERSION of zcs installed (8.6.0_GA_1153_RHEL7_64)
        The ADMIN EMAIL ADDRESS created (admin@example.local)

Notify Zimbra of your installation? [Yes] no
Notification skipped
Setting up zimbra crontab...done.


Moving /tmp/zmsetup01032015-084819.log to /opt/zimbra/log


Configuration complete - press return to exit
 Last steps include Starting the zimbra service :

Now with the commands restart Crond service and enable it to start with system

#systemctl enable crond
#systemctl restart crond

Edit rsyslog.conf file and uncomment under UDP syslog reception

#vi /etc/rsyslog.conf
$modload imupd  # Uncomment this line
$UDPServerRun514 # Uncomment this line

Restart the rsyslogd  for the service to changes take effect and enable to start with system

#systemctl enable rsyslog
#systemctl restart rsyslog

Now run following command to Update /etc/rsyslog.conf

# /opt/zimbra/libexec/zmsyslogsetup

Now  update ssh key and restart Zimbra services

#su – zimbra
$ zmupdateauthkeys
Updating keys for your-domain.com
Fetching key for your-domain.com
Updating keys for your-domain.com
Updating /opt/zimbra/.ssh/authorized_keys
$zmcontrol restart
$zmcontrol status

Now open your web browser then Access your admin panel via browser :

https://<your_zimbra_domain.com>:7071

zimbra-admin-home

zimbra-admin-login-screen

or you can access directly through the IP:
https://192.168.0.70:7071

How to install, configure from source and connect Postgresql on fedora 22

PostgreSQL is a free and open source software developed for general purpose and object-relational database management system. Developed for Postgresql version 4.2 at Berkeley Computer Science department, University of California, it was initially designed to run on UNIX-like platforms.  Postgresql is designed to be portable  on various platforms such as Mac OS X, Solaris, and Windows.

It’s a source code that can be obtained under PostgreSQL license, a liberal open source license. You are free to use, modify and distribute PostgreSQL in any form. unlike most RDMS, it is developed to run under minimum maintenance and attendance efforts because of its stability.

It is often used as a back-end for web and mobile applications. You can also use it for DB mirroring or replication. PostgreSQL, or ‘Postgres’ as it is nicknamed, adopts the ANSI/ISO SQL standards together, with the revisions.
Pre- Check

Step 1: Download postgreSQL source code

From the postgreSQL download site, choose the mirror site that is located in your country.

# wget http://wwwmaster.postgresql.org/redir/198/f/source/v8.3.7/postgresql-8.3.7.tar.gz

Step 2: Install postgreSQL

# tar xvfz postgresql-8.3.7.tar.gz
# cd postgresql-8.3.7
# ./configure
checking for sgmlspl... no
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating src/Makefile.global
config.status: creating src/include/pg_config.h
config.status: creating src/interfaces/ecpg/include/ecpg_config.h
config.status: linking ./src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking ....
# make
make[3]: Leaving directory `/usr/save/postgresql-8.3.7/contrib/spi'
rm -rf ./testtablespace
# make install
make -C test/regress install
make[2]: Entering directory `/usr/save/postgresql-8.3.7/src/test/regress'
/bin/sh ../../../config/install-sh -c  pg_regress '/usr/local/pgsql/lib/pgxs/src/test/regress/pg_regress'
make[2]: Leaving directory `/usr/save/postgresql-8.3.7/src/test/regress'
make[1]: Leaving directory `/usr/save/postgresql-8.3.7/src'
make -C config install

PostgreSQL possible errors:

As you go along you may meet error messages  while performing postgreSQL installation.

# ./configure
checking for -lreadline... no
checking for -ledit... no

configure: error: readline library not found

check the config.log for details, to understand the package that is required or use –without-readline option during compilation to disable readline support.

PostgreSQL Installation Solution1:

Install the readline-devel and libtermcap-devel to solve the above issue.

# rpm -ivh libtermcap-devel-2.0.8-46.1.i386.rpm readline-devel-5.1-1.1.i386.rpm
warning: libtermcap-devel-2.0.8-46.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...                ########################################### [100%]
   1:libtermcap-devel       ########################################### [ 50%]
   2:readline-devel         ########################################### [100%]

Step 3: Verify the postgreSQL directory structure

Check the bin, doc, include, lib, man and share directories if they really were copied to the default /usr/local/pgsql path .

# ls -l /usr/local/pgsql/
total 24
drwxr-xr-x 2 root root 4096 Apr  8 23:25 bin
drwxr-xr-x 3 root root 4096 Apr  8 23:25 doc
drwxr-xr-x 6 root root 4096 Apr  8 23:25 include
drwxr-xr-x 3 root root 4096 Apr  8 23:25 lib
drwxr-xr-x 4 root root 4096 Apr  8 23:25 man
drwxr-xr-x 5 root root 4096 Apr  8 23:25 share

Step 4: Create postgreSQL user account

# adduser postgres
# passwd postgres

Changing password for user postgres.

New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

Step 5: Create postgreSQL data directory

Create and make postgres user as the owner use the main postgres directory.

# mkdir /usr/local/pgsql/data
# chown postgres:postgres /usr/local/pgsql/data
# ls -ld /usr/local/pgsql/data
drwxr-xr-x 2 postgres postgres 4096 Apr  8 23:26 /usr/local/pgsql/data

Step 6: Initialize postgreSQL data directory

Before you can start creating any postgreSQL database, the empty data directory created in the above step should be initialized using the initdb command as shown below.

# su – postgres

# /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/

The files belonging to this database system will be owned by user postgres

This user must also own the server process.

The database cluster will be initialized with locale en_US.UTF-8.
The default database encoding has accordingly been set to UTF8.
The default text search configuration will be set to "english".
fixing permissions on existing directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers/max_fsm_pages ... 32MB/204800
creating configuration files ... ok
creating template1 database in /usr/local/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

After successfully initializing,. You can now start the database server using:

/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data

or

/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

 

step by step configuration of open-resty-* modules and a simple lua text response

lua-nginx-module is a nginx module that makes it possible to handle http request directly
in nginx using Lua.
Installation
It’s possible to install lua-nginx-module by compiling it into nginx. However, I suggest you install OpenResty; the parent project of lua-nginx-module. This is nginx bundled with lua-nginx-module as well as other popular nginx/lua-nginx modules. Installing OpenResty You can run. /configure –help to see available options.

 ./configure \
 --prefix=/opt/resty \
 --conf-path=/opt/resty/nginx.conf \
 --with-cc-opt="-I/usr/local/include" \
 --with-ld-opt="-L/usr/local/lib" \
 --with-pcre-jit \
 --with-ipv6 \
 --with-http_postgres_module \
 --with-http_gunzip_module \
 --with-http_secure_link_module \
 --with-http_gzip_static_module \
 --without-http_redis_module \
 --without-http_redis2_module \
 --without-http_xss_module \
 --without-http_memc_module \
 --without-http_rds_json_module \
 --without-http_rds_csv_module \
 --without-lua_resty_memcached \
 --without-lua_resty_mysql \
 --without-http_ssi_module \
 --without-http_autoindex_module \
 --without-http_fastcgi_module \
 --without-http_uwsgi_module \
 --without-http_scgi_module \
 --without-http_memcached_module \
 --without-http_empty_gif_module

Change directory to /opt/resty/ and confirm if you can locate find nginx.conf and mime.types. Also confirm if the nginx binary is located at nginx/sbin/nginx. Run nginx with the –V verbose flag to see if there have been any errors in your configuration. We can start nginx with a -p and -c flags. The first overwrites the prefix path nginx was configured with. The second tells nginx to use a customized config file (instead of the standard configuration file). Below is a standard nginx config file:

worker_processes 1;
 daemon off;
 error_log /dev/stdout warn;
 events{
 worker_connections 32;
 }
 http {
 default_type text/html;
 access_log off;
 server {
 listen 3000;
 include 'src/proj1.conf';
 }
 }
 There's nothing special here, so let's look at src/proj1.conf:
 location / {
 content_by_lua_block {
 require("handler")()
 }
 }

you can executes Lua code located in a “handler” module/file. Here’s below is a handler.lua:

 local function process()
 ngx.say('the spice must flow')
 end
 return process

Now you can start nginx manually using the next command;

 # /opt/resty/nginx/sbin/nginx -c ~/code/proj1/develop.conf

You will notice that if you first run http://localhost:3000, a 500 error message is
encountered. If you troubleshoot with the command line we see the error.

 # the handler.lua, which we required, couldn't be found.

To resolve this error the lua_package_path directive must be altered in develop.conf which will add a directory to our search path.
Change your file as follows:

 ...
 lua_package_path '${prefix}../../src/?.lua;;';
 server {
 listen 3000;
 include 'src/proj1.conf';
 }
 }

we can change that with the -p flag for Lua to run while overlapping then nginx’s prefixsearch path First though, you’ll need to create some directories:

mkdir -p ~/code/proj1/test/nginx/logs

We can now launch nginx via:

 /opt/resty/nginx/sbin/nginx -c ~/code/proj1/develop.conf -p
 ~/code/proj1/test/nginx/

And reload our page to get a proper result. You can use any prefix prefix path you want and adjust your lua_package_path accordingly.

%d bloggers like this: