How to Install WordPress with HHVM and Nginx on CentOS 7

How to Install WordPress with HHVM and Nginx on CentOS 7 HHVM (HipHop Virtual Machine) is an open source virtual machine for executing programs written in PHP and Hack language. HHVM has been developed by Facebook, it provides most features of the current PHP 7 version. To run HHVM on your server, you can use

How to install PHP 7.1 as PHP-FPM & FastCGI for ISPConfig 3.1 on Debian 8 (Jessie)

How to install PHP 7.1 as PHP-FPM & FastCGI for ISPConfig 3.1 on Debian 8 (Jessie) The final version of PHP 7.1 is available for download on Github and the PHP mirrors now. PHP 7.1 is the next generation of the PHP programming language, it is up to 2 times faster than PHP 5.6 and

How to Install ownCloud 9.1 with Nginx and MariaDB on CentOS 7

How to Install ownCloud 9.1 with Nginx and MariaDB on CentOS 7 OwnCloud is a server software for data synchronization and file sharing with an easy to use web-based frontend that is available under an open source license. OwnCloud can be installed on a Linux or Windows web server, is easy to configure and has

Install Orangescrum on an Ubuntu 16.04 VPS

  Orangescrum is a free and open source project management and collaboration application, ideal for small and medium businesses. With this application, you can easily create and manage your projects, teams, documents, and tasks and communicate with the other team members on your important issues. Orangescrum comes with very useful features such as Interactive summary

Install MyBB on Ubuntu 16.04

In today’s article we will install MyBB on a Ubuntu 16.04 VPS. MyBB is a very popular open source, intuitive and extensible forum software developed using PHP and MySQL. With everything from forums to threads, posts to private messages, search to profiles, and reputation to warnings, MyBB features everything you need to run an efficient

How to Install PostgreSQL and phpPgAdmin on Ubuntu 16.04

  PostgreSQL or Postgres is a powerful high-performance object-relational database management system (ORDBMS) released under a flexible BSD-style license. PostgreSQL is well suited for large databases and has many advanced features. PostgreSQL is available for many operating systems including Linux, FreeBSD, Solaris, and Microsoft Windows. PhpPgAdmin is a PHP-based web application for managing PostgreSQL databases.

How to install SilverStripe CMS with Nginx on a Debian 8 VPS

  In this tutorial we are going to provide you with step-by-step instructions on how to install SilverStripe CMS with Nginx on a Debian VPS. SilverStripe is a content management system (CMS) that includes a programming framework used by website developers for creating and maintaining websites and web applications. Let’s start with the SilverStripe CMS

How to install Backdrop CMS with Nginx on an Ubuntu 16.04 VPS

In this tutorial we are going to provide you with step-by-step instructions on how to install Backdrop CMS with Nginx on an Ubuntu 16.04 VPS. Backdrop CMS is an open-source and easy to use Content Management System used to build attractive and professional websites. Make sure your package list and the OS packages are up

Install Open Web Analytics (OWA) on CentOS 7

In today’s article we will install Open Web Analytics (OWA) on a CentOS 7 VPS. Open Web Analytics (OWA) is an open source web analytics software that you can use to track and analyze how people use your websites and applications. It is written in PHP and uses a MySQL database. OWA is similar to

How to install Quick.Cart shopping cart on CentOS 7

Quick.Cart is a free and open source shopping cart script written in PHP. Quick.Cart is very simple, but yet powerful shopping card and it can be installed and run on almost all Linux distributions. It does not require an SQL database and it can be installed in less than 5 minutes. In this tutorial we

Use PHP in WordPress text widget

Ever wondered how to get php code working in the WordPress text widget? There are some plugins out there wich enable this simple functionality, but why using a plugin if it’s so easy to implement by yourself! You just have to insert the following code to your functions.php: // Add PHP functionality to text widget

How to choose a PHP framework

PHP is one of the most popular programming languages around the world, and the recent PHP 7 release made this server-side programming language better and more stable than ever.

PHP is widely used in major projects. Facebook, for example, utilizes PHP for maintaining and creating their internal systems. WordPress uses PHP to power its internals, which in return is powering more than 26% of the web. Currently, PHP powers more than 82% of websites (whose server-side programming languages the Web Technology Surveys site is able to track).

In this article, we'll look at three of the most popular PHP frameworks: Symfony, Laravel, and Yii. We'll examine how they compare to help you decide which one might be the best fit for your needs.

Why pick a PHP framework?
What's the point of using a framework instead of raw PHP to develop your application? A few benefits of using a framework include:

A PHP framework makes development faster. For example, you don't have to write complex queries to retrieve the data from the database. PHP frameworks provide CRUD operations (Create, Read, Update, and Delete).
Frameworks enable developers to scale systems easily.
Code maintenance is easier than with a vanilla PHP application. The application code is concise and easy to work with.
The MVC model ensures rapid development.
Frameworks are better in securing the web application from common security threats.
The don't repeat yourself (DRY) principle ensures that minimal code has maximum impact.

The above benefits are too significant to be ignored. Even though raw PHP can be used to create any application, the current development standards require tools and time-management skills to meet the market demand.

How to choose a PHP framework
Answering a few questions can help you choose a framework:

What are the features and functionality of the framework? (Does it offer what I need?)
What is the learning curve of the framework?
How scalable is the framework?
Is the framework actively developed and maintained by the core team?
Does the framework provide long-term support (LTS support) ?
Does the framework have a strong community support?

Symfony, Laravel, and Yii
Before diving into technical specifics, here's an overview of the contenders:

Symfony
Symfony is a set of reusable PHP components, enabling the developer to create scalable, high-performance applications. With 30 components from which to choose, the developer has the complete freedom to experiment and work in a RAD environment. Symfony APIs also enable easy integration with third-party applications, and it can be used with popular front-end frameworks, such as AngularJS.

Many popular projects, including Drupal and phpBB, also use a Symfony framework. In fact, Laravel, the most popular PHP framework, is build off of Symfony.

Laravel
Laravel, which is known as the “PHP framework for Web Artisans,” offers an excellent community and wins as the most popular framework. (One of the leading Laravel developers on Livecoding.tv is Sfiskell.)

In May 2015 Laravel announced that version 5.1 will offer long-term support for two years. Version 5.2 rolled out in December 2015. Many hosting companies provide Laravel support and offer hosting solutions for Laravel applications. Check out the Built with Laravel site to see great example projects.

Yii
Created by Qiang Xue in 2008, Yii is a secure, fast, high-performance application/web-development framework. Yii utilizes the Composer dependency manager for PHP for handling different dependencies and installations (more on it later). Yii also is the fastest PHP framework, thanks to the lazy loading technique.

Another great feature of Yii is jQuery integration. The integration enables front-end developers to embrace the framework quickly, and it uses scaffolding to generate code. Similar to Symfony, Yii also utilizes components to enable rapid application development.

How they compare
All three frameworks are great for building Web 2.0 applications, but each framework serves a different purpose. Let's look at their features and how they stack up.

Templating engines
Templating engines minimize developer effort and provides better functionality in writing front-end code. Templating engines provide features such as automatic HTML escaping and filters, and fill the gap left by raw PHP.

Symfony Twig template system
Twig is a modern templating system for PHP. Symfony utilizes Twig to its advantage and enables developers to write clean, concise code and the ability to do more than with raw PHP. For example, it takes the following verbose code to write escaping:

Twig does the same with the following code:

{{ var }} {{ var|escape }} {{ var|e }} {# shortcut to escape a variable #}

See the Twig site to learn more about its features.

Laravel Blade templating system
Unlike other templating systems, Blade lets you use PHP code in the views. Also, Blade has zero overhead to application performance because the blade view files are stored in .blade.php extension. All the code in the view files is converted into raw PHP during processing.

Yii Default templating system
Yii doesn't utilize any third party templating system by default, but that doesn't mean it lacks templating system support. The choice of the templating system depends on the development team. Twig and Smarty are recommended. Symfony uses Twig, so if you have used Symfony in past, you might want to utilize Twig for your next Yii project.

There is no clear winner here. All three frameworks use templating engines for better front-end coding and maintenance. A small advantage to Yii is that the framework does not have a pre-defined templating system.

Framework differences
Every framework is created differently. Symfony works on reusable components and provides the best modularity. Symfony also utilizes the model and controller for developing a web application, which may look rusty for many new developers, but it works. Also, Symfony is a good example of the modular framework. You can use the 30 components provided by Symfony in your project in a modular fashion.

Yii uses an MVC framework. (Symfony does provide support for MVC, which is discussed in more detail in Is Symfony2 a MVC framework on the blog.sznapka.pl site.)

Symfony can be used for rapid development and complex projects. Even though there is a debate on which framework is better for complex projects, Symfony does showcase brilliant complexity handling compared to other frameworks. Yii also utilizes components, but is not as modular as Symfony. Laravel doesn't provide a modular approach as sharp as the other two frameworks.

If you are looking for a modular framework, go for Symfony. Otherwise, Laravel and Yii are both great choices.

Installation
The three frameworks provide multiple installation procedures. If you are using Composer for handling packages, you will be happy to know that all the frameworks can be installed via Composer.

For Symfony, the role of the Composer is more crucial. The idea of component handling is best done by using the Composer PHP dependency manager.

There are other ways of installing the respective frameworks. For example, you can install the frameworks using simple archive method.

After installation, Yii provides you with a web app and a basic template to work on. Symfony 2 also provides a demo app to get started.

Laravel is also easy to install using Composer create-project or via Laravel Installer. Check out the Laravel installation guide for details.

Rapid development
From the perspective of the company or the client, quickly getting the application to the market to meet consumer demand and beat competitors is important. Symfony stands out for being a robust framework with a strong community standing behind it. Laravel is growing rapidly, but still has a way to go before being considered the de facto choice for PHP development. On the other hand, if you have no knowledge of any PHP frameworks and want to get started as quickly as possible, consider Laravel. Laravel has an easy learning curve, and you'll find lots of tutorials online to help get you started. Yii takes performance to the next level, and provides code scaffolding for faster code generation and development.

Performance
The performance of any application only matters if it is a real-time application using critical data. How many web-based applications depend on high performance? Not many, but the performance of frameworks can play a crucial role in many projects.

Social networks are prime example of real-time events and one of our star streamers, jadson, built a mobile social network using Yii2. When it comes to choosing the best framework for coding a high-performance application, Yii stands out as the fastest PHP framework in our lot.

Laravel performance is highly debatable. It is slowest, but does that matter? You'll find online resources for speeding up performance, including a guide on GitHub for making your Laravel application faster.

Database support
Symfony 2 offers better database support. You can work with an array of databases, including NoSQL and DynamoDB. Yii and Laravel are also useful in this regard, but they support fewer databases than Symfony. The database supported by each framework is shown in Table 1.

Table 1

Framework
Laravel
Yii
Symfony 2

Database

SQLite
MySQL
PostgreSQL
Redis
Microsoft BI
MongoDB

MySQL
SQLite
Microsoft BI
Oracle
PostgreSQL
MongoDB

Microsoft BI
MongoDB
MySQL
NoSQL
PostgreSQL
CouchDB
DynamoDB
GemFire
GraphDB
MemBase
MemCacheDB
Oracle
Apache Jackrabbit

Community and resources
A big predictor for an open source framework's longevity is the strength of its community. All the three frameworks have solid communities, although Symfony's might be a bit more mature. Communities evolve, so predicting the dynamics of the communities in the future is challenging.

When it comes to learning material and documentation, Laravel stands out, although Symfony and Yii aren't lagging far behind:

Laravel documentation
Symfony documentation (3.0)
Yii documentation

Extendability
Frameworks are structures that can be extended with extensions or packages, improving their functionality and scope. When it comes to extensions, Laravel is the winner. Packalyst, a directory of Laravel packages, offers more than 9,000 packages. Yii and Symfony, on the other hand, offer around 2800 extensions and 2830 bundles, respectively. With three times the number of extensions, Laravel seems to be the best framework in this regard.

Similarities
We have looked at the differences between the frameworks. Now let's look at their similarities:

All three frameworks are full-stack PHP frameworks and offer the functionalities for creating web application, from front-end code writing to back-end data retrieval.
The projects are open source and their source code can be found on GitHub, making it easy for anyone to contribute:

Symfony
Laravel
Yii

The frameworks are well documented and supported by a large communities.
They each support ORM (Object Relationship Mapping). ORM is highly favored for writing OO code for your application.
They are robust, secure, and reliable for creating Web 2.0 applications.

Still stuck? Maybe these checklists will help you narrow down an option:

Symfony:

offers an LTS release,
comes with loads of features,
is currently the most stable framework,
is a component-based framework and offers extensive modularity,
and has a great community with lots of learning resources.

Yii:

comes with Ajax support,
is great for developing real-time applications as it offers faster operations,
is highly extensible.
error handling is spot on,
is good for creating Restful Web Services,
and has a great community with lots of learning resources.

Laravel:

is the most popular framework in 2015-2016,
supports Composer for package management,
does unit testing well,
offers tons of packages for extending framework functionality,
and has a great community with lots of learning resources.

Conclusion
In the battle of Symfony vs. Laravel vs. Yii, all three PHP frameworks are excellent options that provide a full-stack development environment for developers. For me, Laravel is a winner that is emerging as a star with no sign of stopping.

Still, Symfony and Yii are both excellent frameworks. Symfony is well-established and with a bigger, more mature community. Yii is a unique framework that is robust, secure, and gets the job done.

To see the frameworks in action, check out what developers are using them for on Livecoding.tv, which has channels for Symfony, Yii, and Laravel. The developers are also available on chat or Skype during streaming sessions. Follow the developers, ask them your questions, and get answers in real-time.

Additional resources

Symfony2 vs Yii2: Which development framework should you choose?
10 PHP Frameworks for Developers
It's Laravel 5.1 for Enterprise Development

How to Install Nginx, PHP and MySQL (LEMP Stack) on OpenSUSE Leap 42.1

How to Install Nginx, PHP and MySQL (LEMP Stack) on OpenSUSE Leap 42.1

LEMP or Linux, Engine-x, MySQL, and PHP is a collection of software installed on the Linux operating system to get your PHP based web applications up and running on the fast Nginx web server. The LEMP stack provides a fast and reliable basis for hosting web applications. LEMP is a collection of open source software which has a complete documentation set so you can easily learn more about the different applications and the way they fit together.

In this tutorial, I will show you how to install Nginx, MariaDB, and PHP-FPM on openSUSE leap 42.1. Then I will configure the OpenSUSE firewall with SuSEfirewall2 to allow access to the Nginx web server and show you how you can add a new virtual host configuration on the Nginx web server.

Finally, we will install phpMyAdmin as an easy to use database administration tool and secure it by changing the web directory and enabling HTTP authentication for the phpMyAdmin directory.

Prerequisite

OpenSUSE Leap 42.1.
Root privileges.
Understanding zypper command.

Step 1 – Install and Configure SuSEfirewall2
SuSEfirewall2 is a script which generates iptables rules based on the configuration file “/etc/sysconfig/SuSEfirewall2”. We will install and configure it to prevent network attacks on the server port.

Install SuSEfirewall2 with zypper:

zypper in SuSEfirewall2

When the installation is finished, we have to open some ports for the web applications and SSH. We will open port 22 for ssh service and port 80 and 443 for http and https. Go to the “/etc/sysconfig/” directory and edit the “SuSEfirewall2″ file:

cd /etc/sysconfig/
vim SuSEfirewall2

In line 253, add the port numbers of the services, separated by a white space:

FW_SERVICES_EXT_TCP=”22 80 443”

Save the file and exit.

Restart the SuSEfirewall2 and the SSH service, then test the port configuration by connecting with telnet to the server.

Restart SuSEfirewall2 and SSH service:

/sbin/rcSuSEfirewall2 restart
systemctl restart sshd

Testing ssh connection with telnet on port 22:

telnet 192.168.1.101 22

Step 2 – Install and Configure Nginx
Nginx or engine x is a high-performance HTTP- and proxy server with low memory consumption. It is used by large scale websites like Netflix, Pinterest, CloudFlare, Github etc. Nginx has an easy to learn configuration syntax and can act also as a load balancer with health checks and reverse proxy with caching features.

In this step, we will install nginx and add it to start at boot time. Install it with the “zypper in” command:

zypper in nginx

Start nginx and enable it to be started at boot time:

systemctl start nginx
systemctl enable nginx

Nginx is started now, but if you try to access it through the web browser, you will get a 403 forbidden error. This error occurs because there is no standard index document in the web root folder. To solve this problem, create a new index html in the root web directory “/srv/www/htdocs”. Go to the directory and create the index.html file:

cd /srv/www/htdocs/
echo “

This is Nginx OpenSUSE Leap 42.1

” > index.html

Open your web browser and type your server IP and you will get the index page:

http://192.168.1.101/

Step 3 – Install and Configure MariaDB
MariaDB is open source RDBMS (Relational Database management System) forked from MySQL under the GNU GPL license. In this tutorial, we will install MariaDB and configure the root password for the MariaDB shell.

Install MariaDB with the zypper command:

zypper in mariadb mariadb-client

Start MariaDB/MySQL and add it to boot startup with the systemctl command below:

systemctl start mysql
systemctl enable mysql

Next, configure the admin password for MariaDBb/MySQL with the mysqladmin command. Another option that you can use for this purpose is the “mysql_secure_installation”. In this step, I will use mysqladmin:

/usr/bin/mysqladmin -u root password 'aqwe123'

Note:

“aqwe123” is the new password for MariaDB/MySQL.

Then login to the mysql shell with user root and password aqwe123:

mysql -u root -p
TYPE PASSWORD 'aqwe123'

Now MariaDB/MySQL is installed and configured with our new password.

Step 4 – Install and Configure PHP-FPM
PHP-FPM or FastCGI Process Manager is an alternative for the older PHP FastCGI with provides additional features and speed improvements. PHP-FPM is well suited for small and large sites based on the PHP programming language.

In this step, we will install php5-fpm with some aditional extensions required by phpMyAdmin. Install php5-fom and the extensions with zypper:

zypper in php5 php5-mysql php5-fpm php5-gd php5-mbstring

When the installation has been completed, go to the php5-fpm directory and copy the configuration file:

cd /etc/php5/fpm/
cp php-fpm.conf.default php-fpm.conf

Edit the configuration with vim command:

vim php-fpm.conf

Uncomment the line 32 to enable php-fpm log, the default prefix is /var and if you have any problem with php5-fpm, you can check the log file “/var/log/php-fpm.log”.

error_log = log/php-fpm.log

In line 148 we will configure the owner of the nginx process to the Nginx user. Change user and group of process to nginx:

user = nginx
group = nginx

Line 159: configure php-fpm to run under a socket file, not the port. Change that line like this:

listen = /var/run/php-fpm.sock

And on line 170, change the permissions for the unix socket to the nginx user and group with mode 0660.

listen.owner = nginx
listen.group = nginx
listen.mode = 0660

Save the file and exit the editor.

Next, go the PHP cli directory and edit the php.ini file with vim:

cd /etc/php5/cli/
vim php.ini

Change the value of cgi.fix_pathinfo to zero for security reasons. line 178:

cgi.fix_pathinfo=0

save and exit.

Copy the php.ini to conf.d directory:

cp php.ini /etc/php5/conf.d/

The PHP-FPM Configuration is done at this stage, but we still need to configure Nginx. We have to setup Nginx to work with php-fpm.

Go to the nginx configuration directory and make a backup of the configuration file with the cp command:

cd /etc/nginx/
cp nginx.conf nginx.conf.backup

Edit nginx.conf with vim:

vim nginx.conf

Add index.php on line 48:

index index.php index.html index.htm;

Add the new php configuration section at line 68, this is the configuration for handling .php file requests.

location ~ .php$ {
root /srv/www/htdocs;
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

Save the file and exit.

Next, test the nginx configuration file syntax to ensure that there are no errors. Then start the php-fpm daemon and restart Nginx:

nginx -t
systemctl start php-fpm
systemctl restart nginx

To make sure the php-fpm and nginx is working properly, we will add a new php test file. Go the DocumentRoot directory and create a phpinfo file with the name info.php:

cd /srv/www/htdocs/
echo “” > info.php

Open your web browser type your server ipaddress:

http://192.168.1.101/info.php

Nginx and php-fpm are working now.

Step 5 – Configure a Nginx Virtualhost
In this step, I will show you how to add a virtual host configuration for a website. We will configure a new domain “www.example.com” and the webroot directory in “/srv/www/example/”. Please replace example and example.com with your own domain name.

GNginx nginx directory and create a new directory for the virtualhost configuration.

cd /etc/nginx/
mkdir vhosts.d/
cd vhosts.d/

Next, create new file example.conf for the domain name “example.com” virtualhost.

vim example.conf

paste virtualhost configuration below:

server {
server_name example.com;
return 301 $scheme://www.example.com$request_uri;
}
server {
listen 80;
root /srv/www/example;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ .php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

Save the file and exit.

Now create the directory for the site “example.com” in the /srv/www/ directory, and create a new index file.

mkdir -p /srv/www/example/
cd /srv/www/example/
echo “

This is www.example.com site.

” > index.html
echo “” > info.php

Now open your web browser and visit the domain:

example.com

You will be redirected to www domain, and now access the php file:

http://www.example.com/info.php

Step 6 – Install and Configure phpMyAdmin
PhpMyAdmin is a PHP based application to manage MySQL or MariaDB databases from a web browser. In this step, I will configure phpMyAdmin to run under php-fpm and then make PHPMyAdmin secure by restricting access the phpMyAdmin login page.

Install phpMyAdmin with the zypper command:

zypper in phpMyAdmin

The command will install all packages needed by phpMyAdmin, including apache2-utils that is required for creating the password file.

Now we have phpMyAdmin installed on the system. Next we will create a new htpasswd file with the htpasswd command.

create password file htpasswd:

htpasswd -c /etc/nginx/htpasswd megumi
TYPE YOUR PASSWORD for user megumi

Next, we have to configure Nginx to use HTTP basic authentication for the phpmyadmin directory. We will restrict access to the phpMyAdmin login page with auth_basic, and only users that are in the “htpasswd” file can log in to the phpMyAdmin.

Go to the Nginx configuration directory and edit the nginx.conf file:

cd /etc/nginx/
vim nginx.conf

Define the web root directory inside of the server section by adding a new line under line 40 (server_name):

server_name localhost;
root /srv/www/htdocs; #newline config

Then add the phpMyAdmin configuration for nginx at line 60:

location ~ ^/phpMyAdmin/.*.php$ {
auth_basic “Restricted Access”;
auth_basic_user_file /etc/nginx/htpasswd;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

Save the file and exit the editor.

Test the nginx configuration and restart nginx:

nginx -t
systemctl restart nginx

Next, open your web browser and visit the phpMyAdmin URL, you will be asked for a username and password for the login page.

http://192.168.1.101/phpMyAdmin/

Then log in with your MySQL username and password.

phpMyAdmin has been successfully installed and only the user in the htpasswd can log in.

Reference
http://nginx.org/en/docs/
https://www.howtoforge.com/basic-http-authentication-with-nginx
https://www.ruby-forum.com/topic/4411851

view as pdf | print

Share this page:
Tweet Follow

Install Habari with Nginx on Debian 8

In this tutorial we will cover the steps needed for installing Habari with Nginx on a Debian 8 VPS. Habari is a free and open source blog engine written in PHP that currently supports MySQL, SQLite and PostgreSQL for the database backend. It is a publishing platform and application framework with a modular, object-oriented core.