Trending February 2024 # Setting Up Lemp – Nginx, Php 7.2 In Google Cloud # Suggested March 2024 # Top 2 Popular

You are reading the article Setting Up Lemp – Nginx, Php 7.2 In Google Cloud updated in February 2024 on the website Eastwest.edu.vn. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested March 2024 Setting Up Lemp – Nginx, Php 7.2 In Google Cloud

This page shows you how to get your WordPress website running on a virtual machine instance with Nginx, PHP 7.2, Cloud SQL

The installation is mostly done via command line so I assume you are comfortable using command line interface.

Prerequisites

Comfortable using LINUX command line interface

Your Compute Engine Instance running.

For setting up Compute Engine, see the Setting up Compute Engine Instance

Domain name is pointed to your virtual machine.

For setting up Cloud DNS, see the Setting up Google Cloud DNS for your domain

Install Nginx

Although you have just created your new instance, it is likely that some software packages are out of date. Let’s make sure that you are using the latest software packages.

sudo apt-get update

Once completed let’s update all the installed packages. You will be prompted with the selection to start the update. Hitting Y and Enter will begin the process.

sudo apt-get upgrade

Once the upgrade is completed you can proceed to install Nginx

sudo apt install nginx

Once complete, you can confirm that Nginx has been installed by issuing this command

nginx -v

Visit your domain in your browser, you will see the Nginx welcome page.

Now you can secure your instance by setting up firewall and Fail2ban.

Firewall

The firewall provides an additional layer of security to your instance by blocking inbound network traffic. The ufw (Uncomplicated Firewall) package is usually installed by default in Ubuntu 18.04 LTS, so we need to just add the rules which deny all incoming traffics and allow all outgoing traffics. We now add the ports for SSH (22), HTTP (80), HTTPS (443).

sudo ufw allow OpenSSH sudo ufw allow 'Nginx HTTP' sudo ufw allow 'Nginx HTTPS' sudo ufw enable Fail2ban

This works alongside with ufw and monitors intrusion attempts to your instance and blocks the offending host for a set period of time, so let’s install it now.

sudo apt-get install fail2ban sudo service fail2ban start

Next, open the Nginx configuration file, which can be found at /etc/nginx/nginx.conf

Start by setting the user to the username that you’re currently logged in with. This will make managing file permissions much easier in the future.

The worker_processes directive is the amount of CPU cores your instance. In my case, this is 1.

Lower the keepalive_timeout directive to 15.

Add the new client_max_body_size directive below the server_tokens and set the value to 64m.

In order for Nginx to correctly serve PHP you also need to ensure the fastcgi_param SCRIPT_FILENAME directive is set, otherwise, you will receive a blank white screen when accessing any PHP scripts. So open fastcgi_params file by issuing

sudo nano /etc/nginx/fastcgi_params

Add the following at the end of the file

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

That’s all, this is the basic Nginx configuration, hit CTRL+X followed by Y to save the changes. Ensure that the configuration file contains no errors and restart Nginx for the changes to take effect by issuing the following command

sudo nginx -t

If you get a successful message, then proceed with the following command

sudo service nginx restart

If everything worked out fine, you should still be able to see the Nginx welcome page when visiting your domain in the browser. However, unless visiting a known host the server should return a 444 response. So, we remove the default server blocks from Nginx.

sudo rm /etc/nginx/sites-available/default sudo rm /etc/nginx/sites-enabled/default

Now you need to add a catch all block to the Nginx configuration. Open the nginx.conf file

sudo nano /etc/nginx/nginx.conf

Find the line with include /etc/nginx/sites-enabled/*;

Below this line add the following

server { listen 80 default_server; listen [::]:80 default_server; server_name _; return 444; }

Hit CTRL+X followed by Y to save the changes and then test the Nginx configuration and restart Nginx.

sudo nginx -t sudo service nginx restart

Now when you visit the domain name you should receive an error.

Install PHP 7.2 sudo apt-get install php7.2-fpm php7.2-common php7.2-mysql php7.2-xml php7.2-xmlrpc php7.2-curl php7.2-gd php7.2-imagick php7.2-cli php7.2-dev php7.2-imap php7.2-mbstring php7.2-opcache php7.2-soap php7.2-zip -y

After the installation has completed, confirm that PHP has installed correctly with this command

php-fpm7.2 -v

Now that PHP 7.2.* has installed and you need to configure the user and group that the service will run under.

Change the following lines by replacing the www-data with your username.

user =

username

group =

username

listen.owner =

username

listen.group =

username

Now we configure PHP for WordPress by changing some values in php.ini.

sudo nano /etc/php/7.2/fpm/php.ini

Hit F6 for search inside the editor and update the following values

upload_max_filesize = 32M post_max_size = 48M memory_limit = 256M max_execution_time = 600 max_input_vars = 1000 max_input_time = 400

Hit CTRL+X and Y to save the configuration and check if the configuration is correct and restart PHP

sudo php-fpm7.2 -t sudo service php7.2-fpm restart

Now we have completed NGINX and PHP 7.2 in Ubuntu 18.04 LTS.

In the next post, we can configure Cloud SQL for the WordPress database.

You're reading Setting Up Lemp – Nginx, Php 7.2 In Google Cloud

Setting Up Marketing Campaign Tracking In Google Analytics

Setting up campaign tracking in Google Analytics to track campaign response

In this months poll I asked readers of this blog to see which campaign tracking techniques they or their company or clients tend to use. Later in this post I explain how to setup campaign tracking.

Around 100 people voted, thanks!, how you voted is shown below:

We asked readers to tick all that apply even if  you didn’t generally use a channel, like display or affiliates, but still knew how to tag, track and review it.

The results seem to confirm what I find when I meet people face-to-face which is that:

2. If segments are used, it’s most likely paid and natural search because these are important traffic drivers for most and the segment is automatically created for Google Analytics – the option is shown in our guide.

3. Email marketing and paid search are used relatively often.

How to setup Google Analytics Advanced Segments for campaign tracking

Advanced segments are one of the most powerful ways of using web analytics to review and improve the effectiveness of your online marketing. But I’ve found when training on the Google Analytics course for Econsultancy that surprisingly few know how to setup campaign tagging, particularly for some digital channels.

Advanced segments enable you to:

1. Compare relative performance of digital media channels. For example, resource volume and by ticking more than one box

2. Isolate a channel to review customer behaviour. If you only select one box you can understand where visitors arrive on the site and their forward paths – which content they consume, which routes to conversion they follow.

3. Review performance of an individual creative, ad placement or partner site. As well as showing the medium that visitors were referred from you can also setting up tracking for an individual ad or site where it’s placed.

4. Review performance of a specific search keyphrase or Adwords campaign. You can also drill-down into paid and natural search to see which phrases or groups of phrases are performing.

5. Offline campaigns can be tracked. If you use campaign or “vanity” URLs like chúng tôi then these can be tracked.

Introduction to campaign tracking

Defining a standard set of online marketing source codes is essential to determining the value of different referral sources such as ad campaigns or email campaigns.

Many companies will track AdWords because of it’s automated integration enabled from Google AdWords, but they may not track other codes or have a standard notation which needs to be defined and then added to all links involving media placements.

Google Analytics uses 5 standard dimensions for a campaign which need to be incorporated into the query string of the URL for each ad placement as this example shows:

The campaigns report in Google Analytics will then enable you to compare media.

The table explains each of these 5 dimensions which refers to this example:

Variable Explanation

Recommended The name of the marketing campaign, e.g. Spring Campaign.

Required Media channel (i.e. email, banner, CPC, etc).

What is the ‘distribution method’ that is used to get our message out to our clients?

Required Who are you partnering with to push your message. A publisher such as chúng tôi or for paid search, Google, Yahoo, Live Search, etc

Optional The version of the ad (used for A/B testing) or in AdWords. You can identify two versions of the same ad using this variable. This is not always used and is NOT included in the above example.

Optional This is not always used and is NOT included in the above example.

The Google URL builder can help with creating these links.

Note that in the major Fall 2008 upgrade to Google Analytics, Advanced segmentation provides some standard source codes for campaign types such as paid search.

Tracking offline campaigns in Google Analytics

Many companies will reference promotional URLs or so-called vanity URLs (we hate that term) in offline Print ad, Direct Mail and TV campaigns to make it easy for the customers to fulfil the offer.

Of course, they also want to track the effectiveness of different promotions.

Best practice in such offline or multichannel tracking has been explained well by Avinash in his post: Multichannel Analytics: Tracking Online Impact Of Offline Campaigns.

As with digital campaign tracking, offline campaign tracking should use standard codes for medium, source and campaign name.

What Is Php? Write Your First Php Program

What is PHP?

PHP is a server side scripting language. that is used to develop Static websites or Dynamic websites or Web applications. PHP stands for Hypertext Pre-processor, that earlier stood for Personal Home Pages.

PHP scripts can only be interpreted on a server that has PHP installed.

The client computers accessing the PHP scripts require a web browser only.

A PHP file contains PHP tags and ends with the extension “.php”.

In this tutorial, you will learn-

What is a Scripting Language?

A script is a set of programming instructions that is interpreted at runtime.

A scripting language is a language that interprets scripts at runtime. Scripts are usually embedded into other software environments.

The purpose of the scripts is usually to enhance the performance or perform routine tasks for an application.

Server side scripts are interpreted on the server while client side scripts are interpreted by the client application.

PHP is a server side script that is interpreted on the server while JavaScript is an example of a client side script that is interpreted by the client browser. Both PHP and JavaScript can be embedded into HTML pages.

Programming Language Vs Scripting Language

Programming language Scripting language

Has all the features needed to develop complete applications.

Mostly used for routine tasks

The code has to be compiled before it can be executed

The code is usually executed without compiling

Does not need to be embedded into other languages

Is usually embedded into other software environments.

What does PHP stand for?

PHP means – Personal Home Page, but it now stands for the recursive backronym PHP: Hypertext Preprocessor.

PHP code may be embedded into HTML code, or it can be used in combination with various web template systems, web content management system and web frameworks.

PHP Syntax

A PHP file can also contain tags such as HTML and client side scripts such as JavaScript.

Database management systems DBMS for database powered applications.

The flowchart diagram shown below illustrates the basic architecture of a PHP web application and how the server handles the requests.

Why use PHP?

You have obviously heard of a number of programming languages out there; you may be wondering why we would want to use PHP as our poison for the web programming. Below are some of the compelling reasons.

PHP is open source and free.

Short learning curve compared to other languages such as JSP, ASP etc.

Large community document

Most web hosting servers support PHP by default unlike other languages such as ASP that need IIS. This makes PHP a cost effective choice.

PHP is regular updated to keep abreast with the latest technology trends.

Other benefit that you get with PHP is that it’s a server side scripting language; this means you only need to install it on the server and client computers requesting for resources from the server do not need to have PHP installed; only a web browser would be enough.

PHP has in built support for working hand in hand with MySQL; this doesn’t mean you can’t use PHP with other database management systems. You can still use PHP with

Postgres

Oracle

MS SQL Server

ODBC etc.

PHP is cross platform; this means you can deploy your application on a number of different operating systems such as windows, Linux, Mac OS etc.

What is PHP used for & Market share

In terms of market share, there are over 20 million websites and application on the internet developed using PHP scripting language.

This may be attributed to the points raised above;

The diagram below shows some of the popular sites that use PHP

PHP vs chúng tôi VS JSP VS CFML

ASP – Active Server Pages, JSP – Java Server Pages, CFML – Cold Fusion Markup language The table below compares the various server side scripting languages with PHP

FEATURE PHP ASP JSP CFML

Learning curve

short

Longer than PHP

Longer than PHP

Longer than PHP

Web hosting

Supported by almost all hosting servers

Needs dedicated server

Fairly supported

Needs dedicated server

Open source

Yes

No

Yes

Both commercial and open source

Web services support

Built in

Uses the .NET framework

Uses add on libraries

Built in

Integration with HTML

Easy

Fairly complex

Fairly complex

Easy

MySQL support

Native

Needs third party drivers

Needs third party drivers

Current version has native support. Older versions use ODBC

Easily extended by other languages

Yes

No

Extended using Java classes and libraries.

Yes

PHP File Extensions

File extension and Tags In order for the server to identify our PHP files and scripts, we must save the file with the “.php” extension. Older PHP file extensions include

.phtml

.php3

.php4

.php5

.phps

PHP was designed to work with HTML, and as such, it can be embedded into the HTML code.

You can create PHP files without any html tags and that is called Pure PHP file .

The server interprets the PHP code and outputs the results as HTML code to the web browsers.

In order for the server to identify the PHP code from the HTML code, we must always enclose the PHP code in PHP tags.

A PHP tag starts with the less than symbol followed by the question mark and then the words “php”.

PHP is a case sensitive language, “VAR” is not the same as “var”.

The PHP tags themselves are not case-sensitive, but it is strongly recommended that we use lower case letter. The code below illustrates the above point.

We will be referring to the PHP lines of code as statements. PHP statements end with a semi colon (;). If you only have one statement, you can omit the semi colon. If you have more than one statement, then you must end each line with a semi colon. For the sake of consistency, it is recommended that you always end your statement(s) with a semi colon. PHP scripts are executed on the server. The output is returned in form of HTML.

PHP Hello world

The program shown below is a basic PHP application that outputs the words “Hello World!” When viewed in a web browser.

<?php echo "Hello world";

Output:

Hello world Summary

PHP stands for Hypertext pre-processor

PHP is a server side scripting language. This means that it is executed on the server. The client applications do not need to have PHP installed.

PHP files are saved with the “.php” file extension, and the PHP development code is enclosed in tags.

PHP is open source and cross platform

Exploring The Underlying Os In A Google Cloud Database Managed Service

Introduction

Databases take too long to complete tasks such as patching OS systems. With the help of Google Databases, the backup configuration is also possible with the additional benefit of having security. It helps new businesses to build their product as per the business requirements.

One of the most common queries a cloud database service provider gets is the underlying operating system(OS). Rather than considering it a concern, individuals asked this question out of curiosity. Let us explore the underlying OS in the Google Cloud Database managed services.

What Is a Cloud Database Service?

It can be defined as an organized and systematic collection of data and overseeing the assortment of information in an IT framework that lives on a public, private, or crossover distributed computing platform.

The identical database seems indistinguishable from users as well as applications. Whether through a cloud database or other platforms, contingent upon the specific data set software, the cloud can store organized, unorganized, or semi-structured information.

Features of Google Cloud Database Limit

Sufficient data for simple scaling at whatever point is required—likewise, viable administration of those data for ideal performance. The database can be accessed from any place in the world.

Safety

Multi-level security choices to safeguard resources such as data, OS components, and networks. An automated environment with all the tools makes all the data available without human intervention.

Network Framework

Many physical, statistical, and artificial components are used to make the cloud, such as switches, firewalls, load balancers, etc.

Support

The Google Cloud Database is made by seeking help from experts for establishment, upkeep, and backing. The easy-to-pay method empowers users to pay just for the services consumed.

Transmission Capacity

A reasonable measure of transfer speed for peak performance. The transmission capacity of Google Cloud Database makes it a reliable option for transferring data.

Variety of Services

Other than all the features mentioned above it provides other facilities. Subsequently, Google Cloud Database is a good option for firms, particularly when they require a broad list of services for their business.

Benefits of Google Cloud Database Less Expensive

Google empowers customers to get Google Cloud Database at the least expensive rates. The facilitating subscriptions are less costly than other platforms but offer the best features. The platform provides a pay-as-you-go option to the clientele where they can pay for the services separately.

Work from Anyplace

When the account configuration on the cloud database is done, it can be utilized anywhere. That implies the user can utilize the database across various gadgets. It is conceivable that Google provides online applications that permit users total access to cloud storage.

Not a Public Network

Google’s private network empowers users to have more command over the database capabilities, which is the main reason behind the smooth performance and better network efficiency.

Versatile

Clients are getting a more versatile platform over the private network. Google uses fiber-optic links to increase its range of networks, and having greater coverage is probable. The company continuously attempts to increase its network range to improve its services.

Security

Countless skilled security professionals work in the company, frequently looking after the networks and protecting the database put away on servers. Also, the company utilizes an algorithm that encodes every information on the cloud database, and it guarantees users that their data is protected from unapproved sources.

Better Backup Services

Google generally keeps a backup of clients’ information with in-built backup integration that is redundant. If a user’s data is lost, users don’t need to worry about it, which is a huge problem. The company usually has duplicate data of the users except if the data is erased strongly. This adds reliability, uprightness, and dependability for Google Cloud Database users.

Exploring the Underlying OS in a Google Cloud Database Managed Service Cloud SQL for SQL Server

With SQL Server, the user can utilize operating the cloud system. To get desired OS-relevant information, dynamic management views made with the SQL server can be used to get the desired results. The method that can be used to get the expected results. Below mentioned is one of the few examples:

select host platform as os_type, host_distribution as os, host release as version from sys.dm_os_host_info; Cloud SQL for PostgreSQL

With PostgreSQL, we can utilize the version data to get extra data on underlying operating systems. Some of the example is mentioned below −

select version(); Cloud SQL for MySQL

With MySQL, we can utilize show variables to get extra data on fundamental working frameworks. For examples −

SHOW VARIABLES LIKE 'version%'; Closure

Those mentioned above are all details regarding Google Cloud Database and the underlying OS in the database. You go through the guide above and can go through the guide to learn more about Google Cloud Database in detail. If you plan to use a cloud database for your firm, you should opt for Google Cloud Database.

How To Set Up Custom Calculated Metrics In Google Analytics

🚨 Note: All standard Universal Analytics properties will stop processing new hits on July 1, 2023. 360 Universal Analytics properties will stop processing new hits on October 1, 2023. That’s why it is recommended to start using Google Analytics 4.

Do you want to enhance your Google Analytics reports with custom calculated metrics that are specific to your online business?

In Google Analytics, you can use the Calculated Metrics feature to configure new, customized metrics using existing data.

Here’s an overview of what we’ll cover in this guide:

So let’s dive in!

Custom Calculated Metrics on YouTube

What are Calculated Metrics in Google Analytics?

Metrics are single data points, usually something you can count like pageviews or user sessions. Calculated Metrics are user-defined metrics that are computed from existing metrics.

For example, a Google Analytics report might include Pageviews across your site as a metric. The dimensions down the left side are properties that describe the metric (in this case, the page path). 

There are also some pre-existing calculated metrics. It is which you can combine data points with each other to describe a relationship.

A page’s bounce rate, for example, is one of these calculated metrics that is defined as the percentage of single page visits that occurred on a certain page.

So Google Analytics already has a lot of calculated metrics available to use in your reports, but sometimes you need something a little different—something specifically relevant to your website.

Luckily, you can include custom data like this in your reports by calculating your own metrics.

How to Create Custom Calculated Metrics?

Under your Reporting tab, you can find the bounce rate alongside other common calculated metrics such as pages per session, percent new sessions, and average session duration.

In this tutorial, however, we’re going to use Pageview metric along with the Users metric to build a new custom calculated metric for the number of pageviews per user.

Create Your First Metric?

Give your metric a name. Make sure to choose something descriptive and informative, since you will be able to query for this name via the Reporting API.

Next, select an appropriate Formatting Type. In many cases, Float is a good generic type since it is the most accommodating of different values. Integer, Currency, Time, and Percent are more specific but more restrictive.

Now you can write a Formula that will determine the relationship between existing metrics, resulting in your custom calculated metric.

Amazingly, this actually works retroactively. We can add or change calculated metrics, and Google Analytics will go back and reprocess existing data. This means that you’ll be able to find this metric even in older reports.

Using Custom Metrics in Reports 

So once you’ve built a custom metric, how can you use it in your report?

Custom calculated metrics are available in dashboards or widgets, but most of the time you’ll probably want to build your own custom report.

Give your report an informative title. If this report is focused around your custom metric, you may want to even use the same name.

Then, choose whatever metrics that you want to include in your report. Your custom metrics will likely be listed under Other.

In order to see what campaigns and backlinks are promoting the most engagement with your site, select the Source / Medium dimension for this example.

After you save your report, you’ll see your new custom metric represented across relevant dimensions in your report. In this case, we have the number of pages visited per user that came through a given source.

Summary

Calculated metrics can enhance your reports by introducing custom data that is relevant to your specific website. With calculated metrics, you can customize your Google Analytics property to perfectly suit your business needs or your website.

Not all calculated metrics will make sense for your or your clients’ websites. But if you want to find custom calculated metrics that can improve your implementation, we have a Calculated Metrics Guide that you can download for free! This guide includes different examples of custom calculated metrics that you can assess and use for your own Google Analytics reporting.

Working Of Exit Function In Php With Examples

Introduction to PHP exit

Whenever there is a need to terminate the current script along with a message in PHP, we make use of an inbuilt function called exit function in PHP, though exit function is used to terminate the current script, it does not interrupt the object destructors and shut down functions from being executed and exit function takes one parameter namely message where message represents the message that is to be displayed during the termination of the current script by the exit function or this message can also be a status number during the termination of the script by the exit function.

Start Your Free Software Development Course

Syntax:

exit(message)

where,

The message represents the message that is to be displayed during the termination of the current script by the exit function or this message can also be a status number during the termination of the script by the exit function.

Working of exit Function in PHP

Whenever there is a need to terminate the current script along with a message in PHP, we make use of an inbuilt function called exit function in PHP.

Though the exit function is used to terminate the current script, it does not interrupt the object destructors and shut down functions from being executed.

The exit function takes one parameter namely message.

The parameter message represents the message that is to be displayed during the termination of the current script by the exit function or this message can also be a status number during the termination of the script by the exit function.

Examples of PHP exit

Lets us discuss a few examples.

Example #1

PHP program to illustrate the working of exit function where we try to connect to a website through PHP program and if unable to connect, exit the script along with an error message by making use of exit function:

Code:

<?php #a variable called website is used to store the URL of the website that is to be connected. #fopen function is used in read mode to read the contents of the website fopen($website,”r”) #in case if the program is unable to connect to the website and read the contents of the website, the current script is terminated along with an error message using exit function or exit(“Unable to connect to the website: $website “);

Output:

In the above program, a variable called website is used to store the URL of the website that is to be connected. Then fopen function is used to open the website in read mode to read the contents of the website. In case the program fails to connect to the website or fails

Example #2

PHP program to illustrate the working of exit function where we try to connect to a website through PHP program and if unable to connect, exit the script along with an error message by making use of exit function:

Code:

<?php #a variable called website is used to store the URL of the website that is to be connected. #fopen function is used in read mode to read the contents of the website fopen($website,”r”) #in case if the program is unable to connect to the website and read the contents of the website, the current script is terminated along with an error message using exit function or exit(“Unable to connect to the website: $website “);

Output:

In the above program, a variable called website is used to store the URL of the website that is to be connected. Then fopen function is used to open the website in read mode to read the contents of the website. In case the program fails to connect to the website or fails to read the contents of the website, then an error message is displayed while terminating the script by making use of the exit function which is displayed as the output on the screen.

Example #3

PHP program to illustrate the working of exit function where we try to open a file by specifying the path to the location of the file through PHP program and if unable to open the file, exit the script along with an error message by making use of exit function:

Code:

<?php #a variable called filepath is used to store the path to the location of the file that is to be opened. $filepath = “C:/Users/admin/Desktop/check”; #fopen function is used in read mode to read the contents of the file present at the location specified fopen($filepath, “r”) #in case if the program is unable to open the file present at the location specified and read the contents of the file, the current script is terminated along with an error message using exit function or exit(“Unable to open the file present at the location $filepath”);

Output:

In the above program, a variable called filepath is used to store the path to the location of the file to be opened. Then fopen function is used to open the file in read mode to read the contents of the file from the path that specifies the location of the file. In case the program fails to open the file present at the location specified by the path of the file, the program terminates displaying an error message by making use of the exit function which is displayed as the output on the screen. The output is shown in the snapshot above.

Conclusion

In this article, we have learnt the concept of exit function in PHP through definition, syntax, working of exit function through programming examples, and their outputs.

Recommended Articles

This is a guide to PHP exit. Here we discuss the introduction, syntax, and working of the exit function in PHP along with examples and code implementation. You may also have a look at the following articles to learn more –

Update the detailed information about Setting Up Lemp – Nginx, Php 7.2 In Google Cloud on the Eastwest.edu.vn website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!