<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nginx Archives - ubuntu|dog</title>
	<atom:link href="https://ubuntudog.com/category/nginx/feed/" rel="self" type="application/rss+xml" />
	<link>https://ubuntudog.com/category/nginx/</link>
	<description>Knowledge is power</description>
	<lastBuildDate>Fri, 20 Dec 2024 22:24:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.1</generator>

<image>
	<url>https://media.ubuntudog.com/2019/11/cropped-favicon-32x32.png</url>
	<title>Nginx Archives - ubuntu|dog</title>
	<link>https://ubuntudog.com/category/nginx/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Password protect directories / folders with nginx</title>
		<link>https://ubuntudog.com/password-protect-directories-folders-with-nginx/</link>
		
		<dc:creator><![CDATA[dean]]></dc:creator>
		<pubDate>Mon, 09 Dec 2019 21:05:49 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<guid isPermaLink="false">https://ubuntudog.com/?p=218</guid>

					<description><![CDATA[<p>Overview On an Apache server, it&#8217;s possible to password protect a directory using .htaccess and .htpasswd files. However, .htaccess files are not supported on Nginx. You can still password protect your directories, but you need to use a basic_auth.conf file instead. Creating the file Log into your server via SSH. Navigate to your user&#8217;s directory. ... <a title="Password protect directories / folders with nginx" class="read-more" href="https://ubuntudog.com/password-protect-directories-folders-with-nginx/" aria-label="Read more about Password protect directories / folders with nginx">Read more</a></p>
<p>The post <a href="https://ubuntudog.com/password-protect-directories-folders-with-nginx/">Password protect directories / folders with nginx</a> appeared first on <a href="https://ubuntudog.com">ubuntu|dog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2>Overview</h2>
<p>On an Apache server, it&#8217;s possible to password protect a directory using .htaccess and .htpasswd files. However, .htaccess files are not supported on Nginx.</p>
<p>You can still password protect your directories, but you need to use a basic_auth.conf file instead.</p>
<h2>Creating the file</h2>
<ol>
<li>Log into your server via SSH.</li>
<li>Navigate to your user&#8217;s directory.</li>
<li>Make sure you have a /home/username/nginx/example.com directory.This doesn&#8217;t exist by default; you must create it by running the following:
<pre>sudo mkdir -p nginx/example.com</pre>
</li>
<li>In this /home/username/nginx/example.com directory, add a file named &#8216;<strong>basic_auth.conf</strong>&#8216; with the following:
<pre>location / {
        auth_basic "Restricted";
        auth_basic_user_file /home/username/nginx/example.com/.htpasswd;
}</pre>
<p>* The auth_basic parameter is just the title of the prompt the user sees when visiting this directory.<br />
* The auth_basic_user_file parameter specifies where the password file is. Note how its path is set to the /nginx directory.</p>
<p>In this example, the &#8216;location&#8217; directive password protects the entire domain since it&#8217;s pointing to &#8216;/&#8217;.<br />
If you want a subdirectory to be password protected, change the &#8216;location&#8217; directive as follows:</p>
<pre>location /subdirectory/</pre>
</li>
<li>Run the following to create the <strong>.htpasswd</strong> file:
<pre>sudo htpasswd -c /home/username/nginx/example.com/.htpasswd LOGIN</pre>
<p>* LOGIN is the username you want to be used to authenticate in the login prompt.</li>
<li>After typing that command, enter a password and confirm it when prompted:
<pre>New password: 

Re-type new password:</pre>
<p>Adding password for user LOGIN</li>
<li>Reload the nginx config file.
<pre>sudo service nginx reload</pre>
</li>
<li>In your browser, load the directory your /home/username/nginx/example.com/basic_auth.conf points to. *In the example above, this would be your domain&#8217;s root directory since the &#8216;location&#8217; directive points to /.</li>
<li>Enter a user/password when prompted to log in.<br />
* In this example, your username is LOGIN and the password is the one you created above.</li>
</ol>
<p>See also:</p>
<ul>
<li><a href="https://ubuntudog.com/update-timezone-in-ubuntu/">How to update timezone in Ubuntu</a></li>
<li><a href="https://ubuntudog.com/how-to-install-php-opcache/">How to install opcache in Ubuntu</a></li>
</ul>
<p>The post <a href="https://ubuntudog.com/password-protect-directories-folders-with-nginx/">Password protect directories / folders with nginx</a> appeared first on <a href="https://ubuntudog.com">ubuntu|dog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to install PHP opcache</title>
		<link>https://ubuntudog.com/how-to-install-php-opcache/</link>
		
		<dc:creator><![CDATA[dean]]></dc:creator>
		<pubDate>Sun, 08 Dec 2019 15:16:15 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<guid isPermaLink="false">https://ubuntudog.com/?p=214</guid>

					<description><![CDATA[<p>OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request. CMS frameworks such as WordPress, Joomla and Drupal, use a complex code and consume many processes. Several website speed enhancement plugins are available, heavily featured within the yield of ... <a title="How to install PHP opcache" class="read-more" href="https://ubuntudog.com/how-to-install-php-opcache/" aria-label="Read more about How to install PHP opcache">Read more</a></p>
<p>The post <a href="https://ubuntudog.com/how-to-install-php-opcache/">How to install PHP opcache</a> appeared first on <a href="https://ubuntudog.com">ubuntu|dog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.</p>
<p>CMS frameworks such as WordPress, Joomla and Drupal, use a complex code and consume many processes. Several website speed enhancement plugins are available, heavily featured within the yield of a typical search engine recommendation. Most of them do not explain how to enable opcode caching server-side – thankfully, it’s simple to implement.</p>
<p>A cursory search for ways to speed up websites will yield plugins and bolt on that only address part of the requirement. The Power Users amongst us need to know how to enable functionality server-side. This short guide will cover off the basics to get you started with OPcache on Ubuntu 18.04 with PHP 7.3 but approach is more or less the same for all Ubuntu versions.</p>
<p>For more detailed runtime options, take a look at the php.net site which has a page of all the <a href="https://www.php.net/manual/en/opcache.configuration.php">runtime options available</a>.</p>
<p>To get OPcache set up requires some changes in the php.ini file on your server.</p>
<p>Open php.ini in your favourite text editor<br />
To get started open your <strong>php.ini</strong> file. Depending on your configuration, this will be in one of two locations:</p>
<pre><strong>APACHE </strong>
sudo nano /etc/php/7.3/apache2/php.ini</pre>
<p>Or</p>
<pre><strong>NGINX </strong>
sudo nano /etc/php/7.3/fpm/php.ini</pre>
<p><strong>Enable OPcache</strong><br />
To enable the OPcache, change to the following lines of your php.ini file:</p>
<pre>;opcache.enable=0</pre>
<p>Change to:</p>
<pre>opcache.enable=1</pre>
<p>Note: Remember to uncomment this line and other configuration lines (remove the “;”) as well as change the “0″ to “1″ Otherwise your change won’t take effect.</p>
<p>Modify the amount of RAM the OPcache will use<br />
With OPcache, there is a trade-off between speed and the amount of RAM used. The more RAM you are willing to dedicate to storing opcode, the more opcode that can be stored. There is a diminishing return at some point, because some code will execute rarely, or your code base might not be that big. It is worth playing with this setting to see where you get the best performance-versus-RAM trade-off. This setting is in megabytes.</p>
<pre>;opcache.memory_consumption=64</pre>
<p>Change to:</p>
<pre>opcache.memory_consumption=128</pre>
<p>Boost the number of scripts that can be cached<br />
OPcache has a strange setting that requires you to not only adjust the amount of RAM but also define the number of scripts that can be cached. You have the option of tuning this parameter for your own application too, especially if you find that your hit rate is not close to 100 percent.</p>
<pre>;opcache.max_accelerated_files=2000</pre>
<p>Change to:</p>
<pre>opcache.max_accelerated_files=4000</pre>
<p>Change the revalidate frequency<br />
To make sure that the OPcache notices when you change your PHP code, you can set the revalidate frequency. Basically, this will tell the cache how often to check the timestamp on the files. This is measured in seconds.</p>
<pre>;opcache_revalidate_freq = 2</pre>
<p>Change to:</p>
<pre>opcache_revalidate_freq = 240</pre>
<p>Verify that the PHP OPcache mod is enabled<br />
Believe it or not, that converts most of the settings you will need to get started. PHP7 has its own module system (since 5.4), so make sure that OPcache is enabled.</p>
<pre>sudo phpenmod opcache</pre>
<p>Restart PHP<br />
You should now be all set to start using PHP 7’s OPcache. You just need to restart the appropriate service to get it going.</p>
<p>APACHE WEB SERVERS</p>
<pre>sudo service apache2 restart</pre>
<p>NGINX WEB SERVERS</p>
<pre>sudo service nginx restart</pre>
<p>The post <a href="https://ubuntudog.com/how-to-install-php-opcache/">How to install PHP opcache</a> appeared first on <a href="https://ubuntudog.com">ubuntu|dog</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
