How to Stop and Disable Firewalld on CentOS 7

Firewalld is a complete firewall solution that has been made available by default on all CentOS 7 servers, including Liquid Web Core Managed CentOS 7, and Liquid Web Self Managed CentOS 7. On occasion, perhaps for testing, disabling or stopping firewalld may be necessary. Follow the instructions below to disable firewalld and stop firewalld.

It is highly recommended that you have another firewall protecting your network or server before, or immediately after, disabling firewalld.

Pre-Flight Check
These instructions are intended specifically for stopping and disabling firewalld CentOS 7.
I’ll be working from a Liquid Web Self Managed CentOS 7 server, and I’ll be logged in as root.

Disable Firewalld
To disable firewalld, run the following command as root:

systemctl disable firewalld

Stop Firewalld
To stop firewalld, run the following command as root:

systemctl stop firewalld

Check the Status of Firewalld
And finally, to check the status of firewalld, run the following command as root:

systemctl status firewalld

Wait, you actually wanted to Start and Enable Firewalld on CentOS 7? Then hit our tutorial on: How to Start and Enable Firewalld on CentOS 7!

Continue Reading

How To Upgrade to PHP 7 on CentOS 7

Introduction

PHP 7, which was released on December 3, 2015, promises substantial speed improvements over previous versions of the language, along with new features like scalar type hinting. This guide explains how to quickly upgrade an Apache or Nginx web server running PHP 5.x (any release) to PHP 7, using community-provided packages.

Warning: As with most major-version language releases, it’s best to wait a little while before switching to PHP 7 in production. In the meanwhile, it’s a good time to test your applications for compatibility with the new release, perform benchmarks, and familiarize yourself with new language features.

 

Subscribing to the IUS Community Project Repository

Since PHP 7.x is not yet packaged in official repositories for the major distributions, we’ll have to rely on a third-party source. Several repositories offer PHP 7 RPM files. We’ll use the IUS repository.

IUS offers an installation script for subscribing to their repository and importing associated GPG keys. Make sure you’re in your home directory, and retrieve the script using curl:

cd ~
curl 'https://setup.ius.io/' -o setup-ius.sh

Run the script:

sudo bash setup-ius.sh

Upgrading mod_php with Apache

This section describes the upgrade process for a system using Apache as the web server and mod_php to execute PHP code. If, instead, you are running Nginx and PHP-FPM, skip ahead to the next section.

Begin by removing existing PHP packages. Press y and hit Enter to continue when prompted.

sudo yum remove php-cli mod_php php-common

Install the new PHP 7 packages from IUS. Again, press y and Enter when prompted.

sudo yum install mod_php70u php70u-cli php70u-mysqlnd

Finally, restart Apache to load the new version of mod_php:

sudo apachectl restart

You can check on the status of Apache, which is managed by the httpd systemd unit, using systemctl:

 
systemctl status httpd

Upgrading PHP-FPM with Nginx

This section describes the upgrade process for a system using Nginx as the web server and PHP-FPM to execute PHP code. If you have already upgraded an Apache-based system, skip ahead to the PHP Testing section.

Begin by removing existing PHP packages. Press y and hit Enter to continue when prompted.

sudo yum remove php-fpm php-cli php-common

Install the new PHP 7 packages from IUS. Again, press y and Enter when prompted.

sudo yum install php70u-fpm-nginx php70u-cli php70u-mysqlnd

Once the installation is finished, you’ll need to make a few configuration changes for both PHP-FPM and Nginx. As configured, PHP-FPM listens for connections on a local TCP socket, while Nginx expects a Unix domain socket, which maps to a path on the filesystem.

PHP-FPM can handle multiple pools of child processes. As configured, it provides a single pool called www, which is defined in /etc/php-fpm.d/www.conf. Open this file with nano (or your preferred text editor):

sudo nano /etc/php-fpm.d/www.conf

Look for the block containing listen = 127.0.0.1:9000, which tells PHP-FPM to listen on the loopback address at port 9000. Comment this line with a semicolon, and uncomment listen = /run/php-fpm/www.sock a few lines below.
/etc/php-fpm.d/www.conf

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific IPv4 address on
;                            a specific port;
;   '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses
;                            (IPv6 and IPv4-mapped) on a specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
;listen = 127.0.0.1:9000
; WARNING: If you switch to a unix socket, you have to grant your webserver user
;          access to that socket by setting listen.acl_users to the webserver user.
listen = /run/php-fpm/www.sock

Next, look for the block containing listen.acl_users values, and uncomment listen.acl_users = nginx:
/etc/php-fpm.d/www.conf

; When POSIX Access Control Lists are supported you can set them using
; these options, value is a comma separated list of user/group names.
; When set, listen.owner and listen.group are ignored
;listen.acl_users = apache,nginx
;listen.acl_users = apache
listen.acl_users = nginx
;listen.acl_groups =

Exit and save the file. In nano, you can accomplish this by pressing Ctrl-X to exit, y to confirm, and Enter to confirm the filename to overwrite.

Next, make sure that Nginx is using the correct socket path to handle PHP files. Start by opening /etc/nginx/conf.d/default.conf:

sudo nano /etc/nginx/conf.d/php-fpm.conf

php-fpm.conf defines an upstream, which can be referenced by other Nginx configuration directives. Inside of the upstream block, use a # to comment out server 127.0.0.1:9000;, and uncomment server unix:/run/php-fpm/www.sock;:
/etc/nginx/conf.d/php-fpm.conf

# PHP-FPM FastCGI server
# network or unix domain socket configuration

upstream php-fpm {
#server 127.0.0.1:9000;
server unix:/run/php-fpm/www.sock;
}

Exit and save the file, then open /etc/nginx/conf.d/default.conf:

sudo nano /etc/nginx/conf.d/default.conf

Look for a block beginning with location ~ \.php$ {. Within this block, look for the fastcgi_pass directive. Comment out or delete this line, and replace it with fastcgi_pass php-fpm, which will reference the upstream defined in php-fpm.conf:
/etc/nginx/conf.d/default.conf

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_pass php-fpm;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

Exit and save the file, then restart PHP-FPM and Nginx so that the new configuration directives take effect:

sudo systemctl restart php-fpm
sudo systemctl restart nginx

You can check on the status of each service using systemctl:

systemctl status php-fpm
systemctl status nginx

Testing PHP

With a web server configured and the new packages installed, we should be able to verify that PHP is up and running. Begin by checking the installed version of PHP at the command line:

php -v

Output

PHP 7.0.1 (cli) (built: Dec 18 2015 16:35:26) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies

You can also create a test file in the web server’s document root. Although its location depends on your server configuration, the document root is typically set to one of these directories:

/var/www/html
/var/www/
/usr/share/nginx/html

Using nano, open a new file called info.php in the document root. By default, on Apache, this would be:

sudo nano /var/www/html/info.php

On Nginx, you might instead use:

sudo nano /usr/share/nginx/html/info.php

Paste the following code:

info.php

<?php
phpinfo();

Exit the editor, saving info.php. Now, load the following address in your browser:

http://server_domain_name_or_IP/info.php

You should see the PHP 7 information page, which lists the running version and configuration. Once you’ve double-checked this, it’s safest to delete info.php:

sudo rm /var/www/html/info.php

You now have a working PHP 7 installation.

Continue Reading

Installing Active Directory on Windows Server 2012

Installing Active Directory on Windows Server 2012

This article will walk you through setting up the Active Directory Role on a Windows Server 2012. This article is intended to be used for those without an existing Active Directory Forest, it will not cover configuring a server to act as a Domain Controller for an existing Active Directory Forest.
Installing Active Directory

Open the Server Manager from the task bar.

From the Server Manager Dashboard, select Add roles and features.

This will launch the Roles and Features Wizard allowing for modifications to be performed on the Windows Server 2012 instance.

1

1- Select Role-based or features-based installation from the Installation Type screen and click Next.
Note: Roles are the major feature sets of the server, such as IIS, and features provide additional functionality for a given role.

2

1-The current server is selected by default. Click Next to proceed to the Server Roles tab.

3

1-From the Server Roles page place a check mark in the box next to Active Directory Domain Services. A notice will appear explaining additional roles services or features are also required to install domain services, click Add Features.

Note: There are other options including, Certificate services, federation services, lightweight directory services and rights management. Domain Services is the glue that holds this all together and needs to be installed prior to these other services.

4

1-Review and select optional features to install during the AD DS installation by placing a check in the box next to any desired features; Once done click Next.

5

1-Review the information on the AD DS tab and click Next.

6

1-Review the installation and click Install.

Note: The installation progress will be displayed on the screen. Once installed the AD DS role will be displayed on the ‘Server Manager’ landing page.

7

Configuring Active Directory

Once the AD DS role is installed the server will need to be configured for your domain.

1 If you have not done so already, Open the Server Manager from the task bar.

2 Open the Notifications Pane by selecting the Notifications icon from the top of the Server Manager. From the notification regarding configuring AD DS click Promote this server to a domain controller.

8

1-From the Deployment Configuration tab select Add a new forest from the radial options menu. Insert your root domain name into the Root domain name field.

9

1-  Review and select a Domain and Forest functional level. Once selected fill in a DSRM password in the provided password fields. The DSRM password is used when booting the Domain Controller into recovery mode.

Note: The selection made here will have lasting effects to features and server domain controller eligibility. For further information on Domain/Forest functional levels see official Microsoft documentation.

10

1-Review the warning on the DNS Options tab and select Next.

11

1-Confirm or enter a NetBIOS name and click Next.

12

1-Configure the location of the SYSVOL, Log files, and Database folders and click Next.

13

1-Review the configuration options and click Next.

22

1 The system will check to ensure all necessary prerequisites are installed on the system prior to moving forward. If the system passes these checks you will proceed by clicking Install.

Note: The server will automatically be rebooted once the installation completes.

15

After the server is done rebooting, reconnect via RDP. Congratulations on successfully installing and configuring a Active Directory Domain Services on Windows Server 2012.

Continue Reading

Configuring Volume Shadow Copies (VSS) on Windows Server 2012 R2

Volume Shadows Copies (also known as Volume Snapshot Service or VSS) is a technology developed by Microsoft to take restorable snapshots of a volume.

On Windows Server 2012 // 2012 R2 it’s quite easy to set up and restore operations are pretty straightforward.

Note: Volume Shadow Copies allow to restore previous states of the entire volume, you can’t restore previous states of single files and/or folders.

Open the File Explorer and right-click on the volume where you want to enable Volume Shadow Copies. Select Configure Shadow Copies:

1

2

Microsoft suggests to use a dedicated drive to store Volume Shadow Copies in case of high-load. Click Yes:

3

A first snapshot will be generated. Default VSS settings work as following:

Volume Shadow Copies will be stored in the same volume
Volume Shadow Copies will take a maximum amount of 10% of the local disk space
The system reserves a minimum of 300MB of disk space for the shadow copies
The system schedules two shadow copies per day (7.00 AM and 12.00 PM)

To modify these settings click Settings:

4

The option panels are quite explicative:

5

6

To restore a previous snapshot just select it and click Revert:

7

Continue Reading