‏إظهار الرسائل ذات التسميات cPanel. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات cPanel. إظهار كافة الرسائل

2015/04/15

طريقة تثبيت PageSpeed Module ,Apache, Nginx

السلام عليكم ورحمة الله وبركاته

طريقة اضافة موديل PageSpeed المقدم من شركة جوجل لتسريع الويب سيرفر سواء كان Apache او Nginx
مع الاباتشى اسمه mod_pagespeed
مع الnginx اسمه ngx_pagespeed


1- طريقة اضافته مع الاباتشى :

رمز PHP:

yum install at
rpm -U mod-pagespeed-*.rpm


2- طريقة الاضافة مع Nginx :

رمز PHP:

yum install gcc-c++ pcre-dev pcre-devel zlib-devel make


تركيب الموديول فقط

رمز PHP:

  cd ~
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-1.6.29.5-beta.zip
unzip release-1.6.29.5-beta.zip
cd ngx_pagespeed-release-1.6.29.5-beta/
wget https://dl.google.com/dl/page-speed/psol/1.6.29.5.tar.gz
tar -xzvf 1.6.29.5.tar.gz


تركيب الموديول مع الدعم وبتتأكد الاول من احدث نسخة اصدرت من nginx

رمز PHP:

 cd ~
wget http://nginx.org/download/nginx-1.4.1.tar.gz
tar -xvzf nginx-1.4.1.tar.gz
cd nginx-1.4.1/
./configure --add-module=$HOME/ngx_pagespeed-release-1.6.29.5-beta
make
make install


ملفات الكونفج الخاصة بالموديول
* بالاباتشى تكون بالمسار التالى

رمز PHP:

/etc/httpd/conf.d/pagespeed.conf


اما بالنسبة ل nginx فبيكون فى الملف المعتاد للكونفج بالمسار

رمز PHP:

/usr/local/nginx/conf/nginx.conf


الموديول يفعل تلقائيا مع الاباتشى بمجرد التركيب ...
اما بالنسبة ل nginx فيجب اضافة بعض السطور فى كل جزء به

رمز PHP:

server


اضافة الكود التالى فى كل جزء به server بملف الكونفج الخاص ب nginx

رمز PHP:

pagespeed on;

# تأكيد مسار الكاشx.
pagespeed FileCachePath /var/ngx_pagespeed_cache;

location ~ ".pagespeed.([a-z].)?[a-z]{2}.[^.]{10}.[^.]+" {
add_header "" "";
}
location ~ "^/ngx_pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; }
location /ngx_pagespeed_message { allow 127.0.0.1; deny all; }


لتفعيل الموديول mod_pagespeed .. من ملف pagespeed.conf
بأوله نجعل الخيار

رمز PHP:

ModPagespeed on


من الممكن ايضا تعطيله من كونفج الاباتشى نفسه ولكن ليس باستخدام on او off

رمز PHP:

ModPagespeed unplugged


بالنسبة ل nginx للتفعيل او ايقافه من ملف nginx.conf
فى اى بلوك يخص http او server نضيف

رمز PHP:

pagespeed on;


بكده يكون انتهى التركيب وطريقة التحكم الاساسية بالموديول ... الخطوة القادمة فقط لمن لدية خبرة كافية للتعديل على الويب سيرفر ( حتى مايعطل شىء )

امكانيات الموديول كثيرة وله اختيارات عديدة ايضا .. فى ملف http.conf على سبيل المثال

رمز PHP:

ModPagespeed On
ModPagespeedInheritVHostConfig on
ModPagespeedFileCachePath "/var/cache/mod_pagespeed/"
ModPagespeedEnableFilters combine_css,combine_javascript

AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com
ModPagespeedMapRewriteDomain cdn.example1.com *example.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example2.org
ModPagespeedMapRewriteDomain cdn.example2.org *example.org
# الغاء الدمج ل css هنا
ModPagespeedDisableFilters combine_css
</VirtualHost>


الخيارات المفعلة بشكل عام للمودويول .. والتحكم بها بشكل خاص ب virtual hosts

ايضا نفس الطريقة بال nginx

رمز PHP:

http {
pagespeed On;
pagespeed FileCachePath "/var/cache/ngx_pagespeed/";
pagespeed EnableFilters combine_css,combine_javascript;

server {
listen 80;
server_name www.example1.com;
root /www/example1;
pagespeed MapRewriteDomain cdn.example1.com *example.com;
}

server {
listen 80;
server_name www.example2.org;
root /www/example2;
pagespeed MapRewriteDomain cdn.example2.org *example.org;
# هنا ايضا تعطيل دمج ال css لهذا الموقع فقط
pagespeed DisableFilters combine_css;
}

server {
listen 80;
server_name www.example3.org;
root /www/example3;

# لاحظ هنا تعطيل الموديول لهذا الموقع
pagespeed off;
}


لكم تحياتى

2015/04/09

How to configure Apache reverse proxy



Apache's reverse proxy is an act of an Apache webserver providing content from other webserver transparently. This is useful in many instances such as caching and mirroring, but it's mostly used to serve websites that are hosted behind NAT or a firewall. A reverse proxy server routes connection addressed to the internal server, and the client sees the reverse proxy server itself as the origin server.


For example, Apache can be configured to serve URL's such as http://www.example.com/webapp to actually get the content from http://192.168.0.10/myapp, which is hosted from an internal network. This happens transparently and the user initially requesting http://www.example.com/webapp need not to be aware of what happens in the background.




Enable proxy modules




Apache require 2 modules enabled for this reverse proxy to work. These modules are proxy and proxy_http. To enable them, run the following command at the terminal.
sudo a2enmod proxy_http

That will enable both proxy and proxy_http, as proxy module is actually a dependency to the proxy_http module. This is confirmed by the output of the above command.
Considering dependency proxy for proxy_http:
Enabling module proxy.
Enabling module proxy_http.

Once the module is enabled, you can start configuring the reverse proxy settings.


Configure reverse proxy




From the previous example, we would like our public facing webserver at http://www.example.com to host our internal site of http://192.168.0.10/myapp to be available as http://www.example.com/webapp

You'll need to add the following lines to your Apache's configuration file.
For Ubuntu, the file could be /etc/apache2/sites-enabled/000-default

ProxyRequests Off

ProxyPass /webapp http://192.168.0.10/myapp
ProxyPassReverse /webapp http://192.168.0.10/myapp


Restart Apache




For the changes to take effect, the Apache webserver need to be re-started. Run the following command at the terminal to do that.
sudo /etc/init.d/apache2 restart