<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="http://makinuk.github.io/assets/xslt/atom.xslt" ?>
<?xml-stylesheet type="text/css" href="http://makinuk.github.io/assets/css/atom.css" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>http://makinuk.github.io/</id>
	<title>Mustafa AKIN</title>
	<updated>2022-04-05T13:24:02+00:00</updated>

	<subtitle>Sharing my knowledge with others in a manner that is easy to understand and consume.</subtitle>

	

	<link href="http://makinuk.github.io/atom.xml" rel="self" type="application/rss+xml" />
	<link href="http://makinuk.github.io/" rel="alternate" type="text/html" />

	<generator uri="http://jekyllrb.com" version="3.9.0">Jekyll</generator>

	
		<entry>
			<id>http://makinuk.github.io/kafka-notes/</id>
			<title>Kafka 2.7.0 Installatin on CentOS 8</title>
			<link href="http://makinuk.github.io/kafka-notes/" rel="alternate" type="text/html" title="Kafka 2.7.0 Installatin on CentOS 8" />
			<updated>2021-01-01T09:00:00+00:00</updated>

			
			<summary></summary>
			<content type="html" xml:base="http://makinuk.github.io/kafka-notes/">&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Apache Kafka is a popular distributed message broker designed to efficiently handle large volumes of real-time data. 
A Kafka cluster is not only highly scalable and fault-tolerant, but it also has a much higher throughput compared to other message brokers such as ActiveMQ and RabbitMQ. 
Though it is generally used as a publish/subscribe messaging system, a lot of organizations also use it for log aggregation because it offers persistent storage for published messages.&lt;/p&gt;

&lt;p&gt;A publish/subscribe messaging system allows one or more producers to publish messages without considering the number of consumers or how they will process the messages. 
Subscribed clients are notified automatically about updates and the creation of new messages. 
This system is more efficient and scalable than systems where clients poll periodically to determine if new messages are available.&lt;/p&gt;

&lt;p&gt;In this tutorial, you will install and use Apache Kafka 2.7.0 on CentOS 8.&lt;/p&gt;

&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;

&lt;p&gt;To follow along, you will need:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;One CentOS 8 server and a non-root user with sudo privileges.&lt;/li&gt;
  &lt;li&gt;At least 4GB of RAM on the server. Installations without this amount of RAM may cause the Kafka service to fail, with the Java virtual machine (JVM) throwing an “Out Of Memory” exception during startup.&lt;/li&gt;
  &lt;li&gt;OpenJDK 8 installed on your server. To install this version, follow these instructions on installing specific versions of OpenJDK. Kafka is written in Java, so it requires a JVM; however, its startup shell script has a version detection bug that causes it to fail to start with JVM versions above 8.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;step-1--creating-a-user-for-kafka-and-firewall-rules&quot;&gt;Step 1 — Creating a User for Kafka and Firewall rules&lt;/h2&gt;

&lt;h3 id=&quot;firewall-rules&quot;&gt;Firewall Rules&lt;/h3&gt;
&lt;p&gt;As mentioned above we have to open several ports to allow clients to connect to our Kafka cluster and to allow the nodes to communicate with each other. In CentOS 8 we have to add the corresponding firewall rules.&lt;/p&gt;

&lt;p&gt;Let’s start with the firewall rule for ZooKeeper. We have to open ports 2888, 3888 and 2181.&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;root@bari01&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;vi /etc/firewalld/services/zooKeeper.xml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We have to add the following content to the zooKeeper.xml file.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;service&amp;gt;
  &amp;lt;short&amp;gt;ZooKeeper&amp;lt;/short&amp;gt;
  &amp;lt;description&amp;gt;Firewall rule for ZooKeeper ports&amp;lt;/description&amp;gt;
  &amp;lt;port protocol=&quot;tcp&quot; port=&quot;2888&quot;/&amp;gt;
  &amp;lt;port protocol=&quot;tcp&quot; port=&quot;3888&quot;/&amp;gt;
  &amp;lt;port protocol=&quot;tcp&quot; port=&quot;2181&quot;/&amp;gt;
&amp;lt;/service&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For Kafka, we have to open port 9092.&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;vi /etc/firewalld/services/kafka.xml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We have to add the following content to the kafka.xml file.&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;service&amp;gt;
  &amp;lt;short&amp;gt;Kafka&amp;lt;/short&amp;gt;
  &amp;lt;description&amp;gt;Firewall rule for Kafka port&amp;lt;/description&amp;gt;
  &amp;lt;port protocol=&quot;tcp&quot; port=&quot;9092&quot;/&amp;gt;
&amp;lt;/service&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now we can activate the new firewall rules. Let’s first restart the firewalld service to enforce that all existing service specifications are reloaded.&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;systemctl restart firewalld
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;We can now permanently add the firewall rules for ZooKeeper and Kafka.&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;firewall-cmd &lt;span class=&quot;nt&quot;&gt;--permanent&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--add-service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;zooKeeper
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;firewall-cmd &lt;span class=&quot;nt&quot;&gt;--permanent&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--add-service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;kafka
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After activating the rules we have to restart firewalld.&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;systemctl restart firewalld
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;users&quot;&gt;Users&lt;/h3&gt;
&lt;p&gt;Since Kafka can handle requests over a network, you should create a dedicated user for it. This minimizes damage to your CentOS machine should the Kafka server be compromised. We will create a dedicated kafka user in this step, but you should create a different non-root user to perform other tasks on this server once you have finished setting up Kafka.&lt;/p&gt;

&lt;p&gt;Logged in as your non-root sudo user, create a user called kafka with the useradd command:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;useradd kafka &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The -m flag ensures that a home directory will be created for the user. This home directory, /home/kafka, will act as our workspace directory for executing commands in the sections below.&lt;/p&gt;

&lt;p&gt;Set the password using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;passwd&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;passwd kafka
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Add the kafka user to the wheel group with the adduser command, so that it has the privileges required to install Kafka’s dependencies:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;usermod &lt;span class=&quot;nt&quot;&gt;-aG&lt;/span&gt; wheel kafka
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Your kafka user is now ready. Log into this account using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;su&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;su &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; kafka
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now that we’ve created the Kafka-specific user, we can move on to downloading and extracting the Kafka binaries.&lt;/p&gt;

&lt;h2 id=&quot;step-2--downloading-and-extracting-the-kafka-binaries&quot;&gt;Step 2 — Downloading and Extracting the Kafka Binaries&lt;/h2&gt;
&lt;p&gt;Let’s download and extract the Kafka binaries into dedicated folders in our kafka user’s home directory.&lt;/p&gt;

&lt;p&gt;To start, create a directory in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/home/kafka&lt;/code&gt; called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Downloads&lt;/code&gt; to store your downloads:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; ~/Downloads
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Use curl to download the &lt;em&gt;Kafka&lt;/em&gt; binaries:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;curl &lt;span class=&quot;s2&quot;&gt;&quot;https://downloads.apache.org/kafka/2.7.0/kafka_2.13-2.7.0.tgz&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-o&lt;/span&gt; ~/Downloads/kafka.tgz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Create a directory called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kafka&lt;/code&gt; and change to this directory. This will be the base directory of the Kafka installation:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; ~/kafka &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ~/kafka
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Extract the archive you downloaded using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;tar&lt;/code&gt; command:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;tar&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-xvzf&lt;/span&gt; ~/Downloads/kafka.tgz &lt;span class=&quot;nt&quot;&gt;--strip&lt;/span&gt; 1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We specify the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--strip 1&lt;/code&gt; flag to ensure that the archive’s contents are extracted in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/kafka/&lt;/code&gt; itself and not in another directory (such as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/kafka/kafka_2.11-2.1.1/&lt;/code&gt;) inside of it.&lt;/p&gt;

&lt;p&gt;Now that we’ve downloaded and extracted the binaries successfully, we can move on configuring to Kafka to allow for topic deletion.&lt;/p&gt;

&lt;h2 id=&quot;step-3--configuring-the-kafka-server&quot;&gt;Step 3 — Configuring the Kafka Server&lt;/h2&gt;

&lt;p&gt;Kafka’s default behavior will not allow us to delete a topic, the category, group, or feed name to which messages can be published. To modify this, let’s edit the configuration file.&lt;/p&gt;

&lt;p&gt;Kafka’s configuration options are specified in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;server.properties&lt;/code&gt;. Open this file with vi or your favorite editor:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;vi ~/kafka/config/server.properties
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Let’s add a setting that will allow us to delete Kafka topics. Press i to insert text, and add the following to the bottom of the file:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;delete.topic.enable &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;When you are finished, press ESC to exit insert mode and :wq to write the changes to the file and quit. Now that we’ve configured Kafka, we can move on to creating systemd unit files for running and enabling it on startup.&lt;/p&gt;

&lt;h2 id=&quot;step-4--creating-systemd-unit-files-and-starting-the-kafka-server&quot;&gt;Step 4 — Creating Systemd Unit Files and Starting the Kafka Server&lt;/h2&gt;

&lt;p&gt;In this section, we will create systemd unit files for the Kafka service. This will help us perform common service actions such as starting, stopping, and restarting Kafka in a manner consistent with other Linux services.&lt;/p&gt;

&lt;p&gt;Zookeeper is a service that Kafka uses to manage its cluster state and configurations. It is commonly used in many distributed systems as an integral component. If you would like to know more about it, visit the official Zookeeper docs.&lt;/p&gt;

&lt;p&gt;Create the unit file for zookeeper:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;vi /etc/systemd/system/zookeeper.service
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Enter the following unit definition into the file:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Unit]
Requires=network.target remote-fs.target
After=network.target remote-fs.target

[Service]
Type=simple
User=kafka
ExecStart=/home/kafka/kafka/bin/zookeeper-server-start.sh /home/kafka/kafka/config/zookeeper.properties
ExecStop=/home/kafka/kafka/bin/zookeeper-server-stop.sh
Restart=on-abnormal

[Install]
WantedBy=multi-user.target
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[Unit]&lt;/code&gt; section specifies that Zookeeper requires networking and the filesystem to be ready before it can start.&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[Service]&lt;/code&gt; section specifies that systemd should use the zookeeper-server-start.sh and zookeeper-server-stop.sh shell files for starting and stopping the service. It also specifies that Zookeeper should be restarted automatically if it exits abnormally.&lt;/p&gt;

&lt;p&gt;Save and close the file when you are finished editing.&lt;/p&gt;

&lt;p&gt;Next, create the systemd service file for kafka:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;vi /etc/systemd/system/kafka.service
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Enter the following unit definition into the file:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[Unit]
Requires=zookeeper.service
After=zookeeper.service

[Service]
Type=simple
User=kafka
ExecStart=/bin/sh -c '/home/kafka/kafka/bin/kafka-server-start.sh /home/kafka/kafka/config/server.properties &amp;gt; /home/kafka/kafka/kafka.log 2&amp;gt;&amp;amp;1'
ExecStop=/home/kafka/kafka/bin/kafka-server-stop.sh
Restart=on-abnormal

[Install]
WantedBy=multi-user.target
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[Unit]&lt;/code&gt; section specifies that this unit file depends on zookeeper.service. This will ensure that zookeeper gets started automatically when the kafa service starts.&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[Service]&lt;/code&gt; section specifies that systemd should use the kafka-server-start.sh and kafka-server-stop.sh shell files for starting and stopping the service. It also specifies that Kafka should be restarted automatically if it exits abnormally.&lt;/p&gt;

&lt;p&gt;Save and close the file when you are finished editing.&lt;/p&gt;

&lt;p&gt;Now that the units have been defined, start Kafka with the following command:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl start kafka
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To ensure that the server has started successfully, check the journal logs for the kafka unit:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;journalctl &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt; kafka
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You now have a Kafka server listening on port &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;9092&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;While we have started the kafka service, if we were to reboot our server, it would not be started automatically. To enable kafka on server boot, run:&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;kafka
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Now that we’ve started and enabled the services, let’s check the installation.&lt;/p&gt;

&lt;h2 id=&quot;step-5--testing-the-installation&quot;&gt;Step 5 — Testing the Installation&lt;/h2&gt;

&lt;p&gt;Let’s publish and consume a “Hello World” message to make sure the Kafka server is behaving correctly. Publishing messages in Kafka requires:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;A producer&lt;/strong&gt;, which enables the publication of records and data to topics.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;A consumer&lt;/strong&gt;, which reads messages and data from topics.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;First, create a topic named &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TutorialTopic&lt;/code&gt; by typing:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;~/kafka/bin/kafka-topics.sh &lt;span class=&quot;nt&quot;&gt;--create&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--zookeeper&lt;/span&gt; localhost:2181 &lt;span class=&quot;nt&quot;&gt;--replication-factor&lt;/span&gt; 1 &lt;span class=&quot;nt&quot;&gt;--partitions&lt;/span&gt; 1 &lt;span class=&quot;nt&quot;&gt;--topic&lt;/span&gt; TutorialTopic
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You will see the following output:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
Created topic TutorialTopic.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can create a producer from the command line using the kafka-console-producer.sh script. It expects the Kafka server’s hostname, port, and a topic name as arguments.&lt;/p&gt;

&lt;p&gt;Publish the string “Hello, World” to the TutorialTopic topic by typing:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hello, World&quot;&lt;/span&gt; | ~/kafka/bin/kafka-console-producer.sh &lt;span class=&quot;nt&quot;&gt;--broker-list&lt;/span&gt; localhost:9092 &lt;span class=&quot;nt&quot;&gt;--topic&lt;/span&gt; TutorialTopic &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; /dev/null
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Next, you can create a Kafka consumer using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;kafka-console-consumer.sh&lt;/code&gt; script. It expects the ZooKeeper server’s hostname and port, along with a topic name as arguments.&lt;/p&gt;

&lt;p&gt;The following command consumes messages from TutorialTopic. Note the use of the –from-beginning flag, which allows the consumption of messages that were published before the consumer was started&lt;/p&gt;

&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;~/kafka/bin/kafka-console-consumer.sh &lt;span class=&quot;nt&quot;&gt;--bootstrap-server&lt;/span&gt; localhost:9092 &lt;span class=&quot;nt&quot;&gt;--topic&lt;/span&gt; TutorialTopic &lt;span class=&quot;nt&quot;&gt;--from-beginning&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If there are no configuration issues, you should see &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Hello, World&lt;/code&gt; in your terminal:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Hello, World
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The script will continue to run, waiting for more messages to be published to the topic. Feel free to open a new terminal and start a producer to publish a few more messages. You should be able to see them all in the consumer’s output.&lt;/p&gt;

&lt;p&gt;When you are done testing, press &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CTRL+C&lt;/code&gt; to stop the consumer script. Now that we have tested the installation, let’s move on to installing KafkaT.&lt;/p&gt;

&lt;h2 id=&quot;step-6--installing-kafkat-optional&quot;&gt;Step 6 — Installing KafkaT (Optional)&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/airbnb/kafkat&quot;&gt;KafkaT&lt;/a&gt; is a tool from Airbnb that makes it easier for you to view details about your Kafka cluster and perform certain administrative tasks from the command line. Because it is a Ruby gem, you will need Ruby to use it. You will also need ruby-devel and build-related packages such as make and gcc to be able to build the other gems it depends on. Install them using yum&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;ruby ruby-devel make gcc patch
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can now install KafkaT using the gem command:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;gem &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;kafkat
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;KafkaT uses .kafkatcfg as the configuration file to determine the installation and log directories of your Kafka server. It should also have an entry pointing KafkaT to your ZooKeeper instance.&lt;/p&gt;

&lt;p&gt;Create a new file called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.kafkatcfg&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ vi ~/.kafkatcfg
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Add the following lines to specify the required information about your Kafka server and Zookeeper instance:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;{
  &quot;kafka_path&quot;: &quot;~/kafka&quot;,
  &quot;log_path&quot;: &quot;/tmp/kafka-logs&quot;,
  &quot;zk_path&quot;: &quot;localhost:2181&quot;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Save and close the file when you are finished editing.&lt;/p&gt;

&lt;p&gt;You are now ready to use KafkaT. For a start, here’s how you would use it to view details about all Kafka partitions:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;kafkat partitions
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You will see the following output:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Topic                 Partition   Leader      Replicas        ISRs    
TutorialTopic         0             0         [0]             [0]
__consumer_offsets    0             0         [0]                           [0]
...
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You will see TutorialTopic, as well as __consumer_offsets, an internal topic used by Kafka for storing client-related information. You can safely ignore lines starting with __consumer_offsets.&lt;/p&gt;

&lt;p&gt;To learn more about KafkaT, refer to its &lt;a href=&quot;https://github.com/airbnb/kafkat&quot;&gt;GitHub repository&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;step-7--setting-up-a-multi-node-cluster-optional&quot;&gt;Step 7 — Setting Up a Multi-Node Cluster (Optional)&lt;/h2&gt;

&lt;p&gt;If you want to create a multi-broker cluster using more CentOS 8 machines, you should repeat Step 1, Step 4, and Step 5 on each of the new machines. Additionally, you should make the following changes in the server.properties file for each:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The value of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;broker.id&lt;/code&gt; property should be changed such that it is unique throughout the cluster. This property uniquely identifies each server in the cluster and can have any string as its value. For example, “server1”, “server2”, etc.&lt;/li&gt;
  &lt;li&gt;The value of the zookeeper.connect property should be changed such that all nodes point to the same ZooKeeper instance. This property specifies the Zookeeper instance’s address and follows the &amp;lt;HOSTNAME/IP_ADDRESS&amp;gt;:&lt;PORT&gt; format. For example, &quot;203.0.113.0:2181&quot;, &quot;203.0.113.1:2181&quot; etc.&lt;/PORT&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to have multiple ZooKeeper instances for your cluster, the value of the zookeeper.connect property on each node should be an identical, comma-separated string listing the IP addresses and port numbers of all the ZooKeeper instances.&lt;/p&gt;

&lt;hr /&gt;
&lt;h3 id=&quot;if-clustur-not-working-check-this-&quot;&gt;if clustur not working check this :&lt;/h3&gt;
&lt;blockquote&gt;
  &lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ERROR Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
kafka.common.InconsistentClusterIdException: The Cluster ID jvrDMiqjSWmPEMoAPD9iMQ doesn't match stored clusterId Some(DrtQg1zUTAW4VoYZjb_F7A) in meta.properties. The broker is trying to join the wrong cluster. Configured zookeeper.connect may be wrong.&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;The Kafka data directory (check config/server.properties for log.dirs property, it defaults to /tmp/kafka-logs) contains a file called meta.properties. It contains the cluster ID. Which should have matched the ID registered to ZK. Either edit the file to match ZK, edit ZK to match the file, or delete the file (it contains the cluster id and the broker id, the first is currently broken and the second is in the config file normally). After this minor surgery, Kafka will start with all your existing data, since you didn’t delete any data file.&lt;/p&gt;

  &lt;p&gt;Like this: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mv /tmp/kafka-logs/meta.properties /tmp/kafka-logs/meta.properties_old&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;step-8--restricting-the-kafka-user&quot;&gt;Step 8 — Restricting the Kafka User&lt;/h2&gt;
&lt;p&gt;Now that all of the installations are done, you can remove the kafka user’s admin privileges. Before you do so, log out and log back in as any other non-root sudo user. If you are still running the same shell session you started this tutorial with, simply type exit.&lt;/p&gt;

&lt;p&gt;Remove the kafka user from the sudo group:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;gpasswd &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; kafka wheel
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To further improve your Kafka server’s security, lock the kafka user’s password using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;passwd&lt;/code&gt; command. This makes sure that nobody can directly log into the server using this account:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;passwd kafka &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;At this point, only root or a sudo user can log in as kafka by typing in the following command:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;su - kafka
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In the future, if you want to unlock it, use passwd with the -u option:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;passwd kafka &lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;You have now successfully restricted the kafka user’s admin privileges.&lt;/p&gt;

</content>

			
				<category term="kafka" />
			
			

			<published>2021-01-01T09:00:00+00:00</published>
		</entry>
	
		<entry>
			<id>http://makinuk.github.io/jq-commandline/</id>
			<title>jq Command Line</title>
			<link href="http://makinuk.github.io/jq-commandline/" rel="alternate" type="text/html" title="jq Command Line" />
			<updated>2020-09-30T09:00:00+00:00</updated>

			
			<summary></summary>
			<content type="html" xml:base="http://makinuk.github.io/jq-commandline/">&lt;h1 id=&quot;jq&quot;&gt;./jq&lt;/h1&gt;
&lt;p&gt;jq is a lightweight and flexible command-line JSON processor.&lt;/p&gt;

&lt;h3 id=&quot;json-to-csv&quot;&gt;Json to CSV&lt;/h3&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;jq &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'.data[] | [.media.id, .media.name, .url] | @csv'&lt;/span&gt; ytblist.json &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; fileout2.csv
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;file-lists-as-json&quot;&gt;File lists as Json&lt;/h1&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#!/bin/bash

while getopts u:a:f: flag
do
    case &quot;${flag}&quot; in
        u) username=${OPTARG};;
        h) helper=${OPTARG};;
        f) folder=${OPTARG};;
    esac
done

find $folder -ls | jq -nR '
  # Return an object with useful information
  def gather:
    [splits(&quot; +&quot;)] as $in
    | { pathname: $in[-1], entrytype: $in[2][0:1], size: ($in[6] | tonumber) };

  reduce (inputs | gather) as $entry ({};
      ($entry.pathname | split(&quot;/&quot;) ) as $names
      | if ($entry|.entrytype == &quot;-&quot;) then
           ($names[0:-1] + [&quot;items&quot;]) as $p
           | setpath($p; getpath($p) + [{name: $names[-1], size: $entry.size}])
        else . end) '
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;parameters :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;-f&lt;/code&gt; foldername start folder name&lt;/li&gt;
&lt;/ul&gt;
</content>

			
				<category term="Json" />
			
			

			<published>2020-09-30T09:00:00+00:00</published>
		</entry>
	
		<entry>
			<id>http://makinuk.github.io/centos-firewall-cmd/</id>
			<title>CentOS Firewall Cmd</title>
			<link href="http://makinuk.github.io/centos-firewall-cmd/" rel="alternate" type="text/html" title="CentOS Firewall Cmd" />
			<updated>2017-08-26T09:00:00+00:00</updated>

			
			<summary></summary>
			<content type="html" xml:base="http://makinuk.github.io/centos-firewall-cmd/">&lt;h1 id=&quot;centos-firewall-configuration&quot;&gt;Centos Firewall Configuration&lt;/h1&gt;

&lt;h2 id=&quot;services&quot;&gt;Services&lt;/h2&gt;

&lt;h3 id=&quot;adding-a-service-to-specific-zones&quot;&gt;Adding a Service to specific Zones&lt;/h3&gt;

&lt;p&gt;The easiest method is to add the services or ports you need to the zones you are using. 
Again, you can get a list of the available services with the –get-services option:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;firewall-cmd --get-services
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;output&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;RH-Satellite-6 amanda-client amanda-k5-client bacula bacula-client ceph ceph-mon dhcp dhcpv6 dhcpv6-client dns docker-registry dropbox-lansync freeipa-ldap freeipa-ldaps freeipa-replication ftp high-availability http https imap imaps ipp ipp-client ipsec iscsi-target kadmin kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mosh mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio puppetmaster radius rpc-bind rsyncd samba samba-client sane smtp smtps snmp snmptrap squid ssh synergy syslog syslog-tls telnet tftp tftp-client tinc tor-socks transmission-client vdsm vnc-server wbem-https xmpp-bosh xmpp-client xmpp-local xmpp-server
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;You can get more details about each of these services by looking at their associated .xml file within the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/usr/lib/firewalld/services&lt;/code&gt; directory. For instance, the SSH service is defined like this:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For instance, if we are running a web server serving conventional HTTP traffic, we can allow this traffic for interfaces in our “public” zone for this session by typing:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --reload
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;adding-a-port-to-specific-zones&quot;&gt;Adding a Port to specific Zones&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo firewall-cmd --zone=public --permanent --add-port=9090/tcp
sudo firewall-cmd --reload
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>

			
				<category term="Centos7" />
			
			

			<published>2017-08-26T09:00:00+00:00</published>
		</entry>
	
		<entry>
			<id>http://makinuk.github.io/robocopy-example-commands/</id>
			<title>Robocopy Example Commands</title>
			<link href="http://makinuk.github.io/robocopy-example-commands/" rel="alternate" type="text/html" title="Robocopy Example Commands" />
			<updated>2017-03-21T10:00:00+00:00</updated>

			
			<summary></summary>
			<content type="html" xml:base="http://makinuk.github.io/robocopy-example-commands/">&lt;h2 id=&quot;robocopy-examples&quot;&gt;Robocopy Examples&lt;/h2&gt;

&lt;p&gt;Robocopy is a command that is used at the command line to make copies of files and folders. It is also known as Robust File Copy. It comes with windows vista, but was also part of the windows resource kit. It was made to be used for mirroring directories.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://technet.microsoft.com/en-us/library/cc733145(v=ws.11).aspx#Syntax&quot;&gt;Official Documentation&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;move-all-folders-and-files&quot;&gt;Move all folders and files&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;SET MoveDirSource=\\path\to\source\
SET MoveDirDestination=D:\path\to\target

MKDIR &quot;%MoveDirDestination%&quot;
FOR    %%i IN (&quot;%MoveDirSource%\*&quot;) DO           MOVE /Y &quot;%%i&quot; &quot;%MoveDirDestination%\%%~nxi&quot;
FOR /D %%i IN (&quot;%MoveDirSource%\*&quot;) DO ROBOCOPY /MOVE /E &quot;%%i&quot; &quot;%MoveDirDestination%\%%~nxi&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>

			
				<category term="Robocopy" />
			
			

			<published>2017-03-21T10:00:00+00:00</published>
		</entry>
	
		<entry>
			<id>http://makinuk.github.io/useful-poweshell-commands/</id>
			<title>Useful poweshell commands</title>
			<link href="http://makinuk.github.io/useful-poweshell-commands/" rel="alternate" type="text/html" title="Useful poweshell commands" />
			<updated>2017-03-21T09:00:00+00:00</updated>

			
			<summary></summary>
			<content type="html" xml:base="http://makinuk.github.io/useful-poweshell-commands/">&lt;h1 id=&quot;what-is-powershell&quot;&gt;What is PowerShell?&lt;/h1&gt;

&lt;p&gt;PowerShell is an automation platform and scripting language for Windows and Windows Server that allows you to simplify the management of your systems. 
Unlike other text-based shells, PowerShell harnesses the power of the .NET Framework, providing rich objects and a massive set of built-in functionality for taking control of your Windows environments.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.management/microsoft.powershell.management&quot;&gt;Official Documentation&lt;/a&gt;&lt;/p&gt;

&lt;h1 id=&quot;remove-prefix-from-folderfile-name&quot;&gt;Remove Prefix from folder/file name&lt;/h1&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Get-ChildItem UP-* | foreach {rename-item $_ $_.Name.Replace(&quot;UP-&quot;, &quot;&quot;)}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;find-working-process&quot;&gt;Find working process&lt;/h2&gt;

&lt;p&gt;Find working php files :&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Get-WmiObject win32_Process | where-object {$_.CommandLine -like &quot;*php*&quot;} | Select-Object ProcessId,CommandLine,ProcessName,CreationDate | Format-List
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Output :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ProcessId    : 7340
CommandLine  : &quot;C:\Program Files (x86)\JetBrains\PhpStorm 2016.2.2\bin\PhpStorm64.exe&quot;
ProcessName  : PhpStorm64.exe
CreationDate : 20170320114715.853150+180
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Find working php files and disylay on table list&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Get-WmiObject win32_Process | where-object {$_.CommandLine -like &quot;*php*&quot;} | Select-Object ProcessId,CommandLine,ProcessName,CreationDate | Format-Table -wrap
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Output :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ProcessId CommandLine                                                                                                                                                            ProcessName      CreationDate
--------- -----------                                                                                                                                                            -----------      ------------
     7340 &quot;C:\Program Files (x86)\JetBrains\PhpStorm 2016.2.2\bin\PhpStorm64.exe&quot;                                                                                                PhpStorm64.exe   20170320114715.8
                                                                                                                                                                                                  53150+180
     7772 &quot;C:\Program Files (x86)\JetBrains\PhpStorm 2016.2.2\bin\fsnotifier64.exe&quot;                                                                                              fsnotifier64.exe 20170320114736.5
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;kill-process-working-more-than-15-min&quot;&gt;Kill process working more than 15 min&lt;/h2&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; (Get-WmiObject win32_Process | where-object {$_.CommandLine -like '*download-file.php*' -and $_.ConvertToDateTime($_.CreationDate) -lt (Get-Date).AddMinutes(-15)}).Invokemethod(&quot;terminate&quot;, $null)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</content>

			
				<category term="PowerShell" />
			
			

			<published>2017-03-21T09:00:00+00:00</published>
		</entry>
	
		<entry>
			<id>http://makinuk.github.io/Capistrano-Configuration-for-deploy-with-gitlab/</id>
			<title>Capistrano configuration for deploy with gitlab</title>
			<link href="http://makinuk.github.io/Capistrano-Configuration-for-deploy-with-gitlab/" rel="alternate" type="text/html" title="Capistrano configuration for deploy with gitlab" />
			<updated>2017-03-11T10:45:35+00:00</updated>

			
			<summary></summary>
			<content type="html" xml:base="http://makinuk.github.io/Capistrano-Configuration-for-deploy-with-gitlab/">&lt;h2 id=&quot;capistano&quot;&gt;Capistano&lt;/h2&gt;

&lt;p&gt;Capistrano is written in Ruby, but it can easily be used to deploy any language.&lt;/p&gt;

&lt;p&gt;If your language or framework has special deployment requirements, Capistrano can easily be extended to support them.&lt;/p&gt;

&lt;h2 id=&quot;configure-server&quot;&gt;Configure Server&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;configure &lt;strong&gt;deploy&lt;/strong&gt; user&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-ssh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;sudo&lt;/span&gt; groupadd deployers
&lt;span class=&quot;k&quot;&gt;sudo&lt;/span&gt; adduser deploy
&lt;span class=&quot;k&quot;&gt;sudo&lt;/span&gt; usermod -a -G deployers deploy
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;to give the deployers group the permissions, run the following and edit the /etc/sudoers file: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;visudo&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Add the following line to after the groups:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-ssh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;err&quot;&gt;..&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;## Allows people in group wheel to run all commands&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;deploy&lt;/span&gt;      ALL=(ALL)NOPASSWD:/bin/chown, /bin/chmod,/bin/mkdir

&lt;span class=&quot;err&quot;&gt;..&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;generate ssh-key for deploy user&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-ssh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;sudo&lt;/span&gt; su - deploy
&lt;span class=&quot;k&quot;&gt;ssh&lt;/span&gt;-keygen -t rsa -b &lt;span class=&quot;m&quot;&gt;4096&lt;/span&gt; -C &quot;deploy@example.com&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;add new deploy key to gitlab on &lt;strong&gt;http://gitlabserver/admin/deploy_keys&lt;/strong&gt; from &lt;strong&gt;new server&lt;/strong&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cat ~/.ssh/id_rsa.pub&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;enable new deploy-key on gitlab project&lt;/li&gt;
  &lt;li&gt;copy &lt;strong&gt;gitlab-runner&lt;/strong&gt; key from gitlab-machine &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;su gitlab-runner -c &quot;cat ~/.ssh/id_rsa.pub&quot;&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;paste gitlab ssh-key to new server via &lt;strong&gt;deploy&lt;/strong&gt; user &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vi ~/.ssh/authorized_keys&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;change file mode &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chmod 644 ~/.ssh/authorized_keys&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;install git on new server &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yum -y install git&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;change project installation folder group &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chgrp -hR deployers /var/www&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;change project installation folder permission &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chmod 775 -R /var/www&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
  &lt;p&gt;first create capistrano config file with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cap install&lt;/code&gt; command on project root folder.&lt;/p&gt;
&lt;/blockquote&gt;

</content>

			
				<category term="Capistrano" />
			
			

			<published>2017-03-11T10:45:35+00:00</published>
		</entry>
	
		<entry>
			<id>http://makinuk.github.io/LEMP-CentOS-7-installation/</id>
			<title>LEMP-CentOS 7 Installation</title>
			<link href="http://makinuk.github.io/LEMP-CentOS-7-installation/" rel="alternate" type="text/html" title="LEMP-CentOS 7 Installation" />
			<updated>2017-03-11T09:45:35+00:00</updated>

			
			<summary></summary>
			<content type="html" xml:base="http://makinuk.github.io/LEMP-CentOS-7-installation/">&lt;h2 id=&quot;prepare-machine&quot;&gt;Prepare Machine&lt;/h2&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;epel-release
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum update
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;install-nginx&quot;&gt;Install Nginx&lt;/h2&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;nginx
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;firewall-cmd &lt;span class=&quot;nt&quot;&gt;--permanent&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--zone&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;public &lt;span class=&quot;nt&quot;&gt;--add-service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;http 
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;firewall-cmd &lt;span class=&quot;nt&quot;&gt;--permanent&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--zone&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;public &lt;span class=&quot;nt&quot;&gt;--add-service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;https
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;firewall-cmd &lt;span class=&quot;nt&quot;&gt;--reload&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;nginx
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl start nginx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;snmp-basic-configuration&quot;&gt;Snmp Basic Configuration&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;install snmp &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yum -y install net-snmp net-snmp-utils&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;keep orginal config file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cp /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.BAK&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;clear current config file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo &quot;&quot; &amp;gt; /etc/snmp/snmpd.conf&lt;/code&gt; and paste below text with changing SERVERHOST&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rocommunity  public  &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;SERVERHOST&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
rocommunity  public   127.0.0.1
syslocation  &lt;span class=&quot;s2&quot;&gt;&quot;HUS, DTM&quot;&lt;/span&gt;
syscontact  m.akin@medyatakip.com
 
disk /
disk /home
 
includeAllDisks 10%
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;Open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vi /etc/firewalld/services/snmp.xml&lt;/code&gt; and copy below text&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-xml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;service&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;short&amp;gt;&lt;/span&gt;SNMP&lt;span class=&quot;nt&quot;&gt;&amp;lt;/short&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;description&amp;gt;&lt;/span&gt;SNMP protocol&lt;span class=&quot;nt&quot;&gt;&amp;lt;/description&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;port&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;protocol=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;udp&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;port=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;161&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/service&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;reload fierwall  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;firewall-cmd --reload&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;dd the service to your public zone &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;firewall-cmd --zone=public --add-service snmp --permanent&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;again reload fierwall &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;firewall-cmd --reload&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;install-mariadb&quot;&gt;Install MariaDB&lt;/h2&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;mariadb-server mariadb &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;mariadb
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl start mariadb
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;mysql_secure_installation
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;install-php&quot;&gt;Install PHP&lt;/h2&gt;
&lt;h3 id=&quot;php-latest-stable-for-centos&quot;&gt;PHP Latest Stable For Centos&lt;/h3&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; php php-mysql php-fpm php-intl php-common php-opcache php-dom php-mcrypt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;php-7&quot;&gt;PHP 7&lt;/h3&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;rpm &lt;span class=&quot;nt&quot;&gt;-Uvh&lt;/span&gt; https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;yum &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; php70w php70w-mysql php70w-fpm php70w-intl php70w-common php70w-opcache php70w-dom php70w-mcrypt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl &lt;span class=&quot;nb&quot;&gt;enable &lt;/span&gt;php-fpm
&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl start php-fpm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;configure-php&quot;&gt;Configure PHP&lt;/h4&gt;
&lt;ul&gt;
  &lt;li&gt;Open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo vi /etc/php.ini&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;;cgi.fix_pathinfo=1&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cgi.fix_pathinfo=0&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;date.timezone =&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;date.timezone = &quot;Europe/Istanbul&quot;&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo vi /etc/php-fpm.d/www.conf&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Find the line that specifies the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;listen&lt;/code&gt; parameter, and change to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;listen = /var/run/php-fpm/php-fpm.sock&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;;listen.owner = nobody&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;listen.owner = nobody&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;;listen.group = nobody&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;listen.group = nobody&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user = apache&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user = nginx&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;group = apache&lt;/code&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;group = nginx&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;restart php-fpm &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo systemctl restart php-fpm&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;composer-install&quot;&gt;Composer Install&lt;/h2&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl &lt;span class=&quot;nt&quot;&gt;-sS&lt;/span&gt; https://getcomposer.org/installer | php
&lt;span class=&quot;nb&quot;&gt;chmod&lt;/span&gt; +x composer.phar
&lt;span class=&quot;nb&quot;&gt;mv &lt;/span&gt;composer.phar /usr/local/bin/composer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;configure-nginx-to-process-php-pages&quot;&gt;Configure Nginx to Process PHP Pages&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;open &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo vi /etc/nginx/conf.d/default.conf&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;add below nginx configuration&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;server &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    listen       80&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    server_name  domainname.com&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

    &lt;span class=&quot;c&quot;&gt;# note that these lines are originally from the &quot;location /&quot; block&lt;/span&gt;
    root   /var/www/public&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    index index.php index.html index.htm&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
 
    location / &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        try_files &lt;span class=&quot;nv&quot;&gt;$uri&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$uri&lt;/span&gt;/ &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;404&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    error_page 404 /404.html&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    error_page 500 502 503 504 /50x.html&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    location &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; /50x.html &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        root /usr/share/nginx/html&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    location ~ &lt;span class=&quot;se&quot;&gt;\.&lt;/span&gt;php&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        try_files &lt;span class=&quot;nv&quot;&gt;$uri&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;404&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        fastcgi_index index.php&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        fastcgi_param SCRIPT_FILENAME &lt;span class=&quot;nv&quot;&gt;$document_root$fastcgi_script_name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
        include fastcgi_params&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;blockquote&gt;
  &lt;p&gt;be careful about &lt;strong&gt;SELINUX&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
</content>

			
				<category term="Centos7" />
			
			

			<published>2017-03-11T09:45:35+00:00</published>
		</entry>
	
</feed>