2014/12/14

Migrating WordPress MultiSite to a New URL

Migrating WordPress MultiSite to a New URL can be done with a combo of 2 excellent free plugins; WP Migrate DBand BackWPup  the former deals with the database and the latter deals with the files.


The key thing when updating the WordPress database to reflect a new hosting URL is making sure any data serialization stays intact, data serialization involves using the URL in data and if the URL is changed it breaks the data and doesn’t display it. Certain tools like WP Migrate DB take this into account when changing the URL whereas a blanket find and replace in a text editor or a database dump may put you in deep water.


This guide is based on a subfolder WordPress multisite installation,



Installation


Install both plugins in the originating URL and Network Activate them.



Migrating the Database with the New URL


Launch WP Migrate DB via the main admin Dashboard Settings > Migrate DB


wordpress-mutisite-migration


Add in your target URL and home directory webroot path. Take note not to include the webserving protocol in the URL – start with // and also don’t leave trailing slashes in either path.


The advanced options are not required but can be efficient in certain circumstances.


Click on Migrate DB and when done it will pop a gzipped archive in your download folder.



Migrating the Data


wordpress-mutisite-file-migration


Launch BackWPup via main network admin Dashboard and create a new job, just need the files, no need for the database. Save and run now, this plugin has a host of destination options, you can just do it to a local folder and then download when complete.


wordpress-mutisite-file-migration-download



Upload to new URL Destination


Upload both archives to the home directory of the new destination. Uncompress the archives:


Extract the data



tar -xvf files-archive.tar.gz

Remove any database it may have brought with it



rm *.sql

Change files ownership to correct user



chown -R realowner:realowner *

Extract the database



gunzip databasename.sql.gz

Assuming you have a new empty database setup, import the old database



mysql new_databasename < imported_database.sql

The above steps are all command line driven as root, if you don’t have shell access, this will have to be done with phpmyadmin and a ftp app.



 Fix .htaccess and wp-config


Fix up references to the URL in both .htaccess and wp-config


Add in new database connection in wp-config


.htaccess for modern WordPress should resemble



RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
RewriteRule . index.php [L]

 wp-config should include



/* Multisite */
define( 'WP_ALLOW_MULTISITE', false );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'mynewdomain.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
/* That's all, stop editing! Happy bloggin

Make sure and define ‘DOMAIN_CURRENT_SITE’ with the new URL.


That’s it.

Migrate WordPress Site from Local Development to Live Server and fix serialized data issues

There are a number of ways to migrate a local development WordPress site from a test to a live server, you can to this manually or via a plugin.



Migrating WordPress Manually


The manual way to migrate a WordPress site to a live server is in a few steps:




  • Copy the all the contents of the WordPress installation in your development webroot to your live production webroot in your server via FTP, cPanel or other transfer method.

  • Export/Dump your development MySQL database

  • Create a new MySQL database for your live environment

  • Import the development database into the blank live environment database

  • Change the URLs in the database from old to new

  • Update /wp-config.php file for new database, database username and password


If you have created your test site with a different URL then the finishing live site which is more than likely, (unless you are using Virtual Hosts and are swapping between local and remote IP addresses) you may run into issues with some data not being migrated to the live site.


This data may include WordPress widgets not showing, certain plugins or theme data is missing. The reason this data may not have made the migration trip is because it is lost as the data has been serialized in the database with the old URL and then can’t be unserialized as there is a new URL.



Serialized Data


So what is Serialized data?  Well it is data that has been written as an array in PHP and stored as a string in one field in a database as appose to numerous fields in a mysql database. This allows a developer an easy, quick and efficient set up but comes at the price of serializing and unserializing that data.


WordPress uses its own serialization functions, however the disadvantage of this approach is that the data is now not as easily transported to say a new URL as the URL is used as part of the serialization.



Temporarily Fixing Serialized Data Issues


To get you out of an immediate bind and show any missing data after a migration you can edit a function in a core WordPress file:


/public_html/wp-includes/functions.php


Comment out the function maybe_unserialize() on lines 230-234 and replace with:



function maybe_unserialize( $original ) {
if ( is_serialized( $original ) ) {
$fixed = preg_replace_callback(
'!(?<=^|;)s:(d+)(?=:"(.*?)";(?:}|a:|s:|b:|i:|o:|N;))!s',
'serialize_fix_callback',
$original );
return @unserialize( $fixed );
}
return $original;
}
function serialize_fix_callback($match) { return 's:' . strlen($match[2]); }

Obviously you will lose that when WordPress is upgraded and is not considered best practice so a permanent solution is required.



Permanent Fix for Serialized Data Issues


The better way to go out this is exporting a database which already references the new URL of the live environment and this is where WP-Migrate DB sorts out the problem. Install the plugin in your development site and export the database with the new URL and file path stated.


migrate-wordpress-database


Once this is done just import the exported database into the new live server.


Also is a script from /Search-Replace-DB which is a wizard you can use which changes the domain name whilst keeping serialized data intact.





WordPress Migration Plugins


migrate wordpress siteA couple of WordPress plugins that can deal with migrating a site from development to live server and deal with any data serialization issues are Duplicator and BackUp Buddy the former is free and the latter is a commercial plugin. One of the key benefits of BackUp Buddy is that it can migrate WordPress Multi-Site installations.


I use mostly Duplicator which I have found to be faultless in many site migrations and the plugin has been around for a while now.


You add the plugin to the the site you are migrating from and create a package from the plugin which includes all the WordPress content and the database, you upload that package to your new server and you need to have a blank MySQL database ready.


From there you need the credentials of the new database; name, username and password – after the package is uploaded go to the config file via a browser, fill in the blanks and you have a migrated site.


Here are the full Duplicator docs.

Change and Update WordPress URLS in Database When Site is Moved to new Host

After migrating a WordPress site to a new URL either live or to a production or development server, the new URL strings in the mysql database need to be changed and updated in the various mysql database tables.


This method just uses the whole mysql database rather than a WordPress export/import from within, and is best suited for a straight swap. So you would copy all the WordPress files/folders to the new destination, set the correct ownership to those files = then do the database switcheroo.



WordPress Database Switcheroo


Do a mysql database export of the old database on the old server, create a new blank database on the new server, import the old data either in phpmyadmin or mysql directly in the command line.


Make sure you have the new database selected, then run some sql updates and replacement commands on the tables notably, wp_options, wp_posts, wp_postmeta.


Use the code as below and swap in your old and new URLs, no trailing slashes. Also if necessary change the table prefix values where applicable (ie wp_ )



UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');



mysql-updates-wordpress
mysql-updates-wordpress

or via command line:



username@[~/Desktop]: mysql -u root -p databasename
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 892
Server version: 5.5.13 MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0

mysql> UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
Query OK, 0 rows affected (0.02 sec)
Rows matched: 964 Changed: 0 Warnings: 0

mysql> UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
Query OK, 0 rows affected (0.05 sec)
Rows matched: 964 Changed: 0 Warnings: 0

mysql> UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');g
Query OK, 0 rows affected (0.01 sec)
Rows matched: 686 Changed: 0 Warnings: 0

Finally update your WordPress config file to reflect the new database, “wp-config.php” should be in your web document root – change, databasename, username, password and host values:



define('DB_NAME', 'databasename');

/** MySQL database username */
define('DB_USER', 'username');

/** MySQL database password */
define('DB_PASSWORD', 'password');

/** MySQL hostname */
define('DB_HOST', 'localhost');

Now everything should link up perfectly.


djave has created a nice and easy script that takes the old and new URLs and hands you the sql code for the WordPress swap, nice!



Serialised Data


Sometimes issues may arise with a problem called serialized data which is when an array of PHP data is somewhat like encyrpted with the actual URL, so if the URL is changed the data is gone.


There are 2 brilliant tools that can handle serialized data and do a search and replace on the old and new databases for the URL and leave serialized data intact.




interconnectit


First up is a script you run via uploading it and browsing to it after migrating and importing your old database into the new – this will then make those necessary changes. Get it from here.




WP Migrate Pro


Second up is a plugin which you install on your original site and run from their doing a find replace on URL string and webroot, a new database dump is exported and thats the one you import into the new URL hosted database.

Find and replace text across a whole WordPress web site using phpMyAdmin

You can do a find and replace for text or html code on a post or page across a whole WordPress site by using the mysql database that the site stores all its data in.


First up you need to connect to the database, if you have a cPanel/Plesk style hosting typically you will have an option to connect to the database via phpmyadmin.



Connect to your WebHost


connect-to-phpmyadmin
Launch phpMyAdmin


 Select Your WordPress Database


select-wordpress-database
Select your WordPress database

If you have multiple databases and don’t know which one, check the database name in the wp-config.php file which is stored in your webroot; htdocs or public_html



Select the wp_posts table


select-wp-posts-table
Select the wp_posts table

To Search For a Text Query Only


Select SQL Tab and add in the Search Query SQL Code


input-search-string



SELECT * FROM wp_posts WHERE (post_content LIKE '%TEXT-TO-FIND-GOES-HERE%');

Click ‘Go’


search-for-text-mysql


To edit the post, click on edit and do what needs to be done – if you edit the text it will be updated in your WordPress post.



To Search and Replace For a Text String


Select SQL Tab and add in the Search and Replace SQL Code


find-and-replace-text-in-wordpress
Add in the find and replace SQL code

So here switch to the ‘SQL’ tab add in the code below and click on the ‘Go’ button.



UPDATE wp_posts SET post_content = REPLACE (  post_content,  'text to find here',  'text to replace here');

So with the SQL code you put your text between the single quotes for what you are finding and what you are replacing these are separated by the comma.



See the Results


phpmyadmin-shows-how-many-rows-are-affected
Shows you how many instances the find/replace occurred

Doing it via Command Line


This can also be easily done via the command line, you just need to start a mysql session:



mysql -u username -ppassword
use mywordpress_table;
UPDATE wp_posts SET post_content = REPLACE (  post_content,  'text to find here',  'text to replace here');

 

Doing it with a Plugin


phpMyAdmin and Command Line – fill you with dread? – never fear a plugin is always handy….


 

 

 

2014/09/28

Copying a YouTube Video to Another YouTube Account

I asked my students to create a YouTube video and create annotations (like sticky notes on the video) by editing their video within YouTube. Problem is, apparently on their GAFE (Google Apps for Education) account the option to add annotations was not working. This necessitated that we copy the videos to personal YouTube account.

Step 1:


Go to http://YouTube.com and go to the video manager

Step 2: 


Check the checkbox next to the video

Step 3: 


From the actions menu choose creative commons

Step 4:


Go to the video. Right click on the video to “copy the video URL”

Step 5:


Log out or open an incognito window (Chrome – command+shift+n)

Step 6:


Log into other YouTube account

Step 7:


Paste the URL of the video into the address bar (ie: go to the video logged in under new account)

Step 8:


Under the video is the option to “remix this video.” Note this only shows up if the video is under a creative commons license.

Step 9:


At the top left NAME the video something meaningful.

Note: you can use the Youtube.com/editor to actually edit this video, add music or text if you desire. If just wanting to make a copy, simply rename and publish.

Step 10:


Publish


Now the video is COPIED to the new YouTube account.

2014/09/20

Binary Details’ to check the supported GALAXY Specials options








The registered binaries do not meet the category
conditions for GALAXY Specials. The GALAXY Specials category can be
selected only if at least one binary supports GALAXY Specials.
You can go to ‘Binary>Advanced
Mode>Binary Details’ to check the supported GALAXY Specials options.


Recently Samsung seller office has done some changes, if you simply upload APK like Google play store it will throw error,

"The registered binaries do not meet the category conditions for GALAXY Specials. The GALAXY Specials category can be selected only if at least one binary supports GALAXY Specials. You can go to ‘Binary>Advanced Mode>Binary Details’ to check the supported GALAXY Specials options."

There is no option to disable Galaxy specials in seller office, so the simple and easy way to fix this problem is just add a permission in your manifest file i.e,

<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>

Thats all, now export your APK in release mode and upload it in Samsung seller office, a confirmation message appears, just confirm it.

Now APK will be successfully uploaded to Samsung app store.

2014/09/19

حل cgi-sys/defaultwebpage.cgi

Fix defaultwebpage redirection caching


Add the following to to /usr/local/apache/htdocs/index.html

Code:

<meta http-equiv="Pragma" content="no-cache" />


Ideally a better solution would be to modify either httpd.conf or the local .htaccess file such that this header would be sent as a header, but at least sending it as an http-equiv would be better than what we have now.

Problem:

When a domain isn't properly configured, the document in /usr/local/apache/htdocs/index.html redirects the browser to /cgi-sys/defaultwebpage.cgi -- which itself is a pretty bad idea to begin with... but even if you like that, what's really problematic is that this redirection is cached by the browser for that session.

This means that when the domain is fixed (often done immediately in response to seeing that page), the user still can't see the correct page content because the redirection to defaultwebpage.cgi is cached client-side. So when the user types in the site URL, it immediately redirects to defaultwebpage.cgi without checking the server for an updated homepage.

The typical user response in this type of situation is to hit "reload" on the browser to get an updated page -- and browsers are programmed to skip this session cache when a reload is requested. But the problem here is that the page that gets reloaded is defaultwebpage.cgi rather than the homepage URL -- remember that the homepage URL immediately redirects to defaultwebpage.cgi, so you can't hit "reload" before the redirect happens.

The only solution is to close down all browser windows or manually clear the page cache, neither of which is something that the average shared hosting user would even think to try. The result is a lot of needless confusion due to a somewhat poorly thought-out design.

And this is absolutely trivial to fix. Just instruct the browser to not cache the redirect page, and you're done.

Blank page after login to phpMyAdmin

The solution is simple for most of you...

go to WHM > Home > Account Information > List Accounts

Find the relevant account and press on the [+] to expand the action panel for this account.

Check the "[v] Synchronize MySQL password".

Add a new password and press on "Change".

If "Synchronize MySQL password" is missing then I guess it is automatically update the MySQL password with the new cPanel password.

2014/08/30

اعدادات DNS ومشاكلها ومشاكل توقف المواقع لدى البعض وعملها لدى آخرين وحلولها

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

الكثير من أصحاب المواقع يشتكون من عمل مواقعهم لدى بعض الزوار وعدم عملها عند البعض الآخر ، وأيضاً الكثير من أصحاب السيرفرات يعانون من هذه المشكلة عندما يقوم العميل بالاتصال بهم وابلاغهم بها ، وعندما يقوم بتصفح الموقع الخاص بالعميل والذي أخبره العميل أن به هذه المشكلة ، فإنه يجد أن الموقع يعمل ويقوم بتصفحه بشكل طبيعي وبدون أي مشاكل .

ولكن بالفعل هذه المشكلة قد تحدث رغم أن الموقع يعمل لديك ، وترجع لاسباب خاصة بضبط الـ DNS Zone و A Entry الخاصة بالموقع ، وأيضاً قد تحدث ولا يعمل الموقع لدى البعض نظراً لاختلاف مزود الخدمة الخاص بهم وطريقة اتصاله بالموقع أو السيرفر .

فى كل الاحوال ، موقع IntoDNS هو موقع يقوم بفحص الـ DNS للمواقع واعدادتها ، ويقوم بعرض الاخطاء اذا كان هناك أخطاء ويرشدك ببعض المقترحات لتلافي وحل هذه الاخطاء .

تستطيع زيارة الموقع من خلال الرابط : http://www.intodns.com ، ثم تقوم بادخال رابط موقعك بالمربع المسمى (Domain Name) ، ثم قم بالضغط على Report ، كما هو موضح بالصورة التالية :



- ملحوظة : جميع القيم الموجودة بالصور أو بالخطوات هي فقط أمثلة وليست هي التي ستظهر لك بالتحديد ، فالقيم التي ستظهر لك هي القيم الخاصة بموقعك أو سيرفرك ، وأيضاً القيم الموجودة بخطوات الاعداد هي مجرد أمثلة للتوضيح ، وما ستقوم بتنفيذه أو مراجعته على سيرفرك هي القيم الخاصة بك (سواء الموقع أو السيرفر) ، وسواء كانت هذه القيم نيم سيرفر أو ايبيهات .

بداية ً ، سيعرض لك الدي ان اس الذي قمت بوضعه فى لوحة تحكم الدومين الذي تستعلم عنه ، ويظهر لك هذه المعلومات فى صف يسمى بـ (Domain NS records) ، على سبيل المثال كما بالصورة التالية :



وفى الصورة يعرض لك أن الـ Name server الموجود بلوحة تحكم الدومين الذي تستعلم عنه هو: ns1.gulfhosted.com ويعمل هذا النيم سيرفر على الاي بي (11.22.33.44)

وأيضاً النيم سيرفر الاخر وهو ns2.gulfhosted.com ويعمل على الاي بي (11.22.33.45)

حتى الآن لا توجد أدنى مشكلة فهذا هو النيم سيرفر الموجود بالفعل بلوحة تحكم الدومين ، وأيضاً هذه هي الايبيهات الخاصة بالنيم سيرفر الموضح .

بعد ذلك يوجد لدينا بالاسفل صف يسمى بـ (NS records from your nameservers) ، وهنا يتم عرض النيم سيرفر الموجود بـ DNS Zone الخاص بالموقع من السيرفر ، والتي يمكنك الدخول اليها من خلال WHM :


رمز Code:

Main >> DNS Functions >> Edit DNS Zone


سيعرض لك كل المواقع الموجودة على السيرفر ، وليكن الموقع الذي تقوم بالاستعلام عنه هو (yoursite.com) ، فسوف تقوم بالضغط على yoursite.com الموجودة ضمن المواقع المعروضة أمامك ، ثم تقوم بالضغط على زر Edit ، ليعرض لك الـ DNS Zone الخاصة بالموقع yoursite.com ، والتي سوف تكون على سبيل المثال كما موجود بالصورة التالية :



ليس هذا هو ما نتحدث عنه الآن ولكن فقط عرضت لك ماهو الذي يعرضه الصف المسمى بـ (NS records from your nameservers) ، نعود الى ما يعرضه لك موقع IntoDNS عن هذا الصف كما ذكرنا وهو النيم سيرفر الموجود بـ DNS Zone الخاص بالموقع من السيرفر ، فاذا كانت لديك الاعدادت الخاصة بـ DNS على سيرفرك على ما يرام وموجود لديك النيم سيرفر الخاصة بسيرفرك وقمت باضافة A Entry لكل نيم سيرفر ، فسيقوم موقع Into DNS بعرض هذا الصف على سبيل المثال كما بالصورة التالية :



حيث ns1.gulfhosted.com هو النيم سيرفر الاول ويستخدم الاي بي 11.22.33.44 ، و ns2.gulfhosted.com هو النيم سيرفر الثاني ويستخدم الاي بي 11.22.33.45 ، وهما كما ذكرنا بالاعلى .

أما اذا كان الـ DNS Zone للنيم سيرفر الموجود بسيرفرك لا تعمل بشكل طبيعى ، فسوف تختلف الرسائل التي سيعرضها لك الموقع بحسب اختلاف الاعدادات الموجودة لديك ، والصور التالية توضح بعض الرسائل التى يعرضها الموقع :





أو أن الزون الخاصة بالموقع تحتوي على نيم سيرفر آخر يختلف عن النيم سيرفر وأيبيهات مختلفة تماماً عن أيبيهات سيرفرك وهو كما موضح بالصورة التالية :



وقد يحدث ذلك مثلاً فى حالات نقل الموقع من سيرفر الى سيرفر آخر بطريقة أو بأخرى ، وظل الموقع يستخدم النيم سيرفر الخاص بالسيرفر الذي كان مستضافاً لديه قبل أن تتم عملية النقل فى الزون الخاصة بالموقع .

وأيضاً من المعلومات التي يعرضها لك موقع IntoDNS هي (WWW A Record) والخاصة بتوجيه دومين موقعك الى اي بي السيرفر المستضاف عليه ، واذا لم تكن لديك الاعدادات بطريقة صحيحة فتظهر لك المعلومات كما هو موضح بالصورة التالية :



- إذا نأتي الآن لكيفية معالجة مثل هذه الامور ، فى البداية يجب عليك اعداد الـ DNS لسيرفرك بطريقة صحيحة ، واذا كنت قد قمت بذلك ، فيجب عليك مراجعته مرة أخرى والتأكد من اعداداته .

وسأوضح لك ذلك من خلال الخطوات التالية التي ستقوم بها على سيرفرك لمراجعة أو اعداد الـ DNS .

ستقوم بالدخول لسيرفرك من خلال الشل من خلال برنامج Putty واذا لم يكن لديك يمكنك تحميله من خلال الرابط (http://www.gulfhosted.com/putty.zip)

ستقوم بالدخول لملف wwwacct.conf من خلال الامر التالي :


رمز Code:

pico /etc/wwwacct.conf


ستجد الاعدادات كما هي موضحة بالاسفل ، ستقوم بعمل التعديلات اللازمة والخاصة بسيرفرك ، والموجودة بالاسفل باللون الأحمر :


رمز Code:

ADDR 11.22.33.44
CONTACTEMAIL server@gulfhosted.com
CONTACTPAGER
DEFMOD x3
ETHDEV venet0:0
HOMEDIR /home
HOMEMATCH home
HOST server.gulfhosted.com
LOGSTYLE combined
MINUID
NS ns1.gulfhosted.com
NS2 ns2.gulfhosted.com
NS3
NS4
NSTTL 86400
SCRIPTALIAS n
TTL 14400





- ADDR : وهو الاي بي الرئيسي للسيرفر
- CONTACTEMAIL : وهو الاميل الخاص بك والذي ستصلك عليه الرسائل من السيرفر
- HOST : وهو الهوست نيم الخاص بسيرفرك
- NS : وهو النيم سيرفر الاول المستخدم بالسيرفر
- NS2 : وهو النيم سيرفر الثاني المستخدم بالسيرفر

والصورة التالية توضح أكثر :



ستقوم بعمل التعديلات اللازمة والخاصة بك مما سبق ، بعدها ستقوم باغلاق الملف من خلال ضغط CTRL+X من الكيبورد ، بعدها اضغط Y ثم ENTER .

- نأتي لاعدادات ملف resolv.conf

نفذ الامر التالي لفتح الملف :


رمز Code:

pico /etc/resolv.conf


قم بعمل الاعدادات بالملف كما موضح بالاسفل مع استبدال القيم الموجودة باللون الاحمر بالقيم الخاصة بسيرفرك :


رمز Code:

domain gulfhosted.com
search gulfhosted.com
server.gulfhosted.com 127.0.0.1
ns1.gulfhosted.com 11.22.33.44
ns2.gulfhosted.com 11.22.33.45


- server.gulfhosted.com : استبدله بالهوست نيم الخاص بسيرفرك
- ns1.gulfhosted.com : النيم سيرفر الاول ، و 11.22.33.44 هو الاي بي المستخدم لهذا النيم سيرفر
- ns2.gulfhosted.com : النيم سيرفر الاول ، و 11.22.33.45 هو الاي بي المستخدم لهذا النيم سيرفر




والصورة التالية أيضاً للتوضيح :



بعد عمل اللازم احفظ ما قمت به من خلال ضغط CTRL+X من الكيبورد ، بعدها اضغط Y ثم ENTER .

- والآن اعداد nameserverips

نفذ الامر التالي لفتح الملف :


رمز Code:

pico /etc/nameserverips


قم بعمل الاعدادات بالملف كما هو موضح بالاسفل مع استبدال القيم الموجودة باللون الاحمر بالقيم الخاصة بسيرفرك :


رمز Code:

11.22.33.44=ns1.gulfhosted.com
11.22.33.45=ns2.gulfhosted.com





حيث ns1.gulfhosted.com : النيم سيرفر الاول ، و 11.22.33.44 هو الاي بي المستخدم لهذا النيم سيرفر
- ns2.gulfhosted.com : النيم سيرفر الاول ، و 11.22.33.45 هو الاي بي المستخدم لهذا النيم سيرفر .

الصورة التالية للتوضيح :



بعد عمل اللازم احفظ ما قمت به من خلال ضغط CTRL+X من الكيبورد ، بعدها اضغط Y ثم ENTER .

بعد ذلك قم بتغيير بتغيير الهوست نيم الى الهوست نيم الخاص بسيرفرك من خلال تنفيذ الامر التالي :

رمز Code:

hostname server.gulfhosted.com


حيث server.gulfhosted.com ستقوم باستبداله بالهوست نيم الخاص بسيرفرك .

بعد ذلك قم بتحديث الترخيص الخاص بالسي بانل ليقوم بقراءة الهوست نيم الذي قمت بتغييره ، وذلك من خلال تنفيذ الامر التالي :

رمز Code:

/usr/local/cpanel/cpkeyclt


قم بعمل ريستارت للنيمد من خلال تنفيذ الامر التالي :

رمز Code:

service named restart


هذا الجزء السابق كان هو الخاص بضبط اعدادات الـ DNS بسيرفرك ، وسنكمل بقية خطواتنا التالية لمعالجة الامر التي ذكرناها بأول الموضوع وضبط النيم سيرفر و DNS Zone واضافة A Entry لكل من الـ hostname و الـ nameserver .

قم بالدخول الى لوحة تحكم السيرفر WHM ، قم توجه الى اعداد (Basic cPanel/WHM Setup) ، من خلال :

رمز Code:

Main >> Server Configuration >> Basic cPanel/WHM Setup


أو من خلال الرابط : http://ip:2086/scripts/editsets مع استبدال ip بالاي بي الخاص بسيرفرك .

ستقوم الآن باضافة A Entry للنيم سيرفر المستخدم على سيرفرك ، توجه الى أسفل الصفحة التي قمت بالدخول اليها ، وقم بعمل ذلك كما هو موضح بالصورة التالية :



ستقوم بالضغط على Add an A entry for this nameserver الموجودة أمام النيم سيرفر الاول ، (وهو فى مثالنا هنا ns1.gulfhosted.com) ، بعد الضغط على هذا الزر ستظهر لك نافذة تسمى بـ Add Nameserver A Entry ، وسيكون موجود بها النيم سيرفر + الاي بي بجانبه ، واسفلها ستجد مربع ادخال به الاي بي الخاص بالنيم سيرفر ، اذا لم يكن هو الذي تستخدمه لهذا النيم سيرفر ، فقم بكتابة الاي بي الصحيح ، ثم اضغط على Add Entry كما هو موضح بالصورة التالية :



ستظهر لك رسالة بأنه تم اضافة A Entry للنيم سيرفر الموضح ، كرر نفس الخطوة بالرجوع الى Basic cPanel/WHM Setup ، وقم باضافة A Entry للنيم سيرفر الثاني .

بعد ذلك قم باضافة A Entry للهوست نيم الخاص بالسيرفر ، قم بتغيير الهوست نيم (مع أننا قم بتغييرها من خلال الشل ، ولكن زيادة فى التأكيد ولا يوجد هناك ضرر من ذلك ) ، قم بالدخول الى Change Hostname من خلال :


رمز Code:

Main >> Networking Setup >> Change Hostname


أو من خلال الرابط : http://ip:2086/scripts2/changehostname ، مع استبدال ip بالاي بي الخاص بسيرفرك .توجه الى أسفل الصفحة ، ستجد مربع اسمه Change Hostname وبه مربع ادخال يسمى بـ New hostname ستقوم بكتابة الهوست نيم لسيرفرك بداخل المربع ، ثم اضغط على زر Change ، والصورة التالية للتوضيح



ستظهر لك رسالة تفيدك بأنه تم تغيير الهوست نيم ، وبها زر بالاسفل وهو Add An A Entry for your hostname ، قم بالضغط عليه كما هو موضح بالصورة التالية :



سيتم تحويلك لصفحة اخرى وبها الهوست نيم وبجانبه الاي بي المستخدم للهوست نيم ، واسفلها ستجد مربع ادخال به الاي بي الخاص بالهوست نيم ، اذا لم يكن هو الاي بي الخاص بالهوست نيم (الاي بي الرئيسي الخاص بسيرفرك) ، فقم بكتابة الاي بي الصحيح ، ثم اضغط على Add Entry كما هو موضح بالصورة التالية :





ستظهر لك رسالة بأنه تم اضافة A Entry للهوست نيم .

- بعد ذلك نأتي الى DNS Zone والنيم سيرفر بها ، وهل هو موجود أم لا ؟ ، واذا كان موجود ، فهل هو النيم السيرفر الصحيح والايبيهات الموجودة فى الزون الخاص به هي الايبيهات الصحيحة الخاصة بذلك النيم سيرفر أم لا ؟ .

فى البداية توجه الى Edit DNS Zone من خلال :


رمز Code:

Main >> DNS Functions >> Edit DNS Zone


أو من خلال الرابط : http://ip:2086/scripts/editdnslist ، طبعاً مع استبدال ip بالاي بي الخاص بسيرفرك .ستجد أمامك قائمة بالمواقع الموجودة على سيرفرك ومن بينها أيضاً النيم سيرفر الخاص بسيرفرك وليكن على سبيل المثال كما ذكرنا هو ns1.gulfhosted.com و ns2.gulfhosted.com

كما هو موضح بالصورة التالية :



طبعاً الصورة مجرد مثال لا تحتوي على المواقع ، ولكنك ستجد المواقع وبينها ايضاً النيم سيرفر

قم باختيار النيم سيرفر الاول وليكن ns1.gulfhosted.com ثم اضغط بالاسفل على الزر Edit ليعرض لك القيم والمدخلات الخاصة بهذا النيم سيرفر ، وهي على سبيل المثال ستكون كما موضح بالصورة التالية :





لاحظ الصف المشار اليه بالسهم والذي يحتوي على اسم النيم سيرفر (ns1.gulfhosted.com) و نوع القيمة المدخلة (A Record) ، والاي بي المستخدم لها وهو الاي بي الخاص بهذا النيم سيرفر (11.22.33.44)

وبقية الاعدادات كما هي موضحة بالصورة السابقة

اذا كان هناك اختلاف فى الاي بي الموضح أمام القيمة A عن الاي بي الخاص بهذا النيم سيرفر ، فيجب عليك تعديله الى الاي بي الصحيح ، ثم احفظ ما قمت به من خلال الضغط على Save فى أسفل الصفحة .

وقم بالرجوع الى Edit DNS Zone مرة أخرى وكرر تلك الخطوة أيضاً مع النيم سيرفر الاخر .

والصورة التالية توضح أيضاً القيم والمدخلات الخاصة بالنيم سيرفر الآخر :



اذا كان هناك اختلاف أو أخطاء يمكنك اختصار ذلك بحذف النيم سيرفر من خلال Delete a DNS Zone ، واختيار النيم سيرفر والضغط على Delete ،سيتم تحويلك لصفحة للتأكيد على أنك تريد الحذف بالفعل ، قم بذلك بالضغط على Delete ، بعد ذلك اضافته من جديد ، وطريقة الاضافة سيتم توضيحها بالاسفل .

اذا قمت بالدخول الى Edit DNS Zone ولم تجد النيم سيرفر الخاص بسيرفرك ضمن قائمة الدومينات المعروضة أمامك ، فيجب عليك اضافة النيم سيرفر ، وستقوم بعمل ذلك من خلال الدخول الى Add a DNS Zone من خلال :

رمز Code:

Main >> DNS Functions >> Add a DNS Zone


أو من خلال الرابط : http://ip:2086/scripts2/adddns مع استبدال ip بالاي بي الخاص بسيرفرك .

سيظهر لك مربع اسمه Domain Selection ، وبه مربعين ادخال ، الاول يسمى Ip والاخر يسمى Domain ، قم بكتابة الاي بي الخاص بالنيم سيرفر فى المربع الاول (Ip) ، وبجانبه فى المربع الثاني (Domain) قم بكتابة النيم سيرفر ، ثم اذهب الى أسفل الصفحة وقم بالضغط على Add Zone

كما هو موضح بالصورة التالية :



ستظهر لك رسالة تفيد بأنه تم اضافة الزون بنجاح ، قم بعدها بالرجوع الى Add a DNS Zone وكرر نفس الخطوات لتقوم باضافة النيم سيرفر الآخر .

بعد ذلك قم بعمل ريستارت للنيمد :

رمز Code:

service named restart


والى هنا أكون قد انتهيت من الموضوع بشكل كامل ، وأرجو أن أكون وفقت فى ذكر أغلب الامور التي لها علاقة بتلك المشكلة .وأعتذر للجميع عن طول الموضوع ، ولكن كان لابد من ذلك لذكر معظم النقاط .

بالتوفيق للجميع

2014/08/11

cPanel Setup, Secure and Plugins Installer

cPanel Setup, Secure and Plugins Installer



Description



cPInstall is a small bash script created at first for UnderHost customer then released to public. Its purpose is to give access to install, optimize, secure any common cPanel plugin within one click. Useful for novice and helpful for advanced users




Features





  • Install cPanel without issue.

  • Install cPanel DNS Only.

  • Force cPanel update.

  • Register with CloudLinux Network.

  • Install CloudLinux on your system.

  • Install CSF Firewall.

  • Install htop Process Viewer.

  • Install logview plugin.

  • Change SSH port.

  • Fully update your system.

  • Secure your /tmp partition

  • Secure your /tmp partition on Virtuozzo VPS

  • Install Brute Force Detection

  • Disable Compilers

  • Enable Compilers

  • Install Fantastico Plugin

  • Install Softaculous Plugin

  • Install Clean Backup Plugin

  • Install Account DNS Check Plugin

  • Install cPnginx Admin Plugin

  • Remove cPnginx Admin Plugin

  • Install Ruby on Rails

  • Install FFMPEG

  • Install WHMSonic Plugin

  • Install Process Resource Monitor.

  • Install System Integrity Monitor

  • Install LiteSpeed Plugin

  • and much more...



.


How to use it


wget http://sourceforge.net/projects/cpanel-install/files/cpinstall.gz.tar/download
tar -xvf cpinstall.gz.tar


Start script with: sh cpinstall.sh


We are currently developing our own WHM Plugin instead to use bash script, cPInstall will probably only return to a cPanel install script and install our WHM Plugin where all other function and much more will be installed via WHM directly.


plugin


 

cpinstall1

2014/07/08

شرح طريقة استعادة السيرفر في حال انضرب النظام في السيرفر السي بنال

بسم الله الرحمن الرحيم
اليوم اقدم لكم شرح مهم جدا لكل شخص يعمل في الآستضافة المواقع ولديه سيرفر هذه الشرح يستخدم عندما ينضرب النظام التشغيل معك ويصير ما يشتغل ابداً فتقوم شركة السيرفرات تركب هاردسك جديد في سيرفرك وتنزل عليه نظام تشغيل من جديد وتركب الهاردسك الخربان وتخليه ثانوي ويصير معك في هذه الحالة 2 هاردات في السيرفر هارد اساسي وهارد ثانوي والهارد الثانوية الي انضرب النظام فيه


طبعا شرحي راح يكون شلون تنقل مواقع العملاء من الهاردسك القديم الخربان الى الهاردسك الجديد


لمعرفة التقسيمات الهاردات في السيرفر :


اكتب الآمر :


رمز Code:

fdisk -l

لمعرفة حجم الهاردسك :


رمز Code:

df -h

طبعا لما تتكلم مع الشركة المزوده للسيرفرات راح تقول لك مسار الهاردسك القديم المضروب او اطلب منهم ذلك ونفرض انه مسار الهاردسك الجديد اسمه


رمز Code:

/oldHD/

هذا يعني ان مسار ملفات مواقع عملائي هنا


رمز Code:

/oldHD/home

لو تروح للمسار الي فرضناه انه الهارد القديم نكتب :
<


رمز Code:

cd /oldHD/home

راح ندخل للهاردسك المضروب ولمعرفة الملفات التي بداخلة والأكونت الي فيه اكتب الأمر التالي :


 


رمز Code:

ls /oldHD/home

طبعا اذا كان سيرفرك في سوفت لير ما راح يرضون يسون عملية النسخ من الهارد القديم الى الجديد حتى لو قطعت تذكرة بـ 3 دولار راح يرفضون لذلك اتبع الطريقة التالية في نقل كافة ملفات عملاءك الى الهاردسك الجديد بواسطة الآمر rsync


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


الأوامر كتالي :


 


رمز Code:

rsync -vrplogDtH /oldHD/usr/local/apache/conf /usr/local/apache
rsync -vrplogDtH /oldHD/var/named /var
rsync -vrplogDtH /oldHD/home/* /home
rsync -vrplogDtH /oldHD/usr/local/cpanel /usr/local
rsync -vrplogDtH /oldHD/var/lib/mysql /var/lib
rsync -vrplogDtH /oldHD/var/cpanel /var
rsync -vrplogDtH /oldHD/usr/share/ssl /usr/share
rsync -vrplogDtH /oldHD/var/ssl /var
rsync -vrplogDtH /oldHD/usr/local/cpanel/3rdparty/mailman /usr/local/cpanel/3rdparty
rsync -vrplogDtH /oldHD/var/log/bandwidth /var/log
rsync -vrplogDtH /oldHD/usr/local/frontpage /usr/local
rsync -vrplogDtH /oldHD/var/spool/cron /var/spool
rsync -vrplogDtH /oldHD/root/.my.cnf /root
rsync -vrplogDtH /oldHD/etc/httpd/conf/httpd.conf /etc/httpd/conf
rsync -vrplogDtH /old/etc/sysconfig/network /etc/sysconfig

طبعا لازم تعرف من الشركة مسار الهاردسك الجديد والقديم عشان يكون سهل عليك تطبيق الشرح ولا تنسى تغير oldHD بمسار الهارسك الجديد


ملاحظة :
الآوامر التي ذكرتها لا تقوم بعملية نقل من الهارد المضروب الى الهارد الجديد ولكن تقوم بعملية نسخها لذلك يعني لا تخاف اذا حصل خطء راح تلقى الملفات موجوده في الهاردسك القديم
بعد ذلك نقل الملفات الهامة التي بداخل المسار etc


ندخل للهارد المضروب الى الملف التالي :


رمز Code:

cd /oldHD/etc

وبعد ذلك نطبق الآمر التالي :


رمز Code:

#rsync -vrplogDtH secondarymx domainalias valiases vfilters exim* proftpd* pure-ftpd* passwd* group* *domain* *named* wwwacct.conf cpupdate.conf quota.conf shadow* *rndc* ips* ipaddrpool* ssl hosts /etc

الحين بعد عملية النقل ما راح تشتغل مواقع العملاء لازم تسوي تحديث لكافة برامج السيرفر عشان تشتغل ولازم تركب الأباتشي من جديد وتحدث كل شيء عشان يرجع مواقع تشتغل


نطبق الآوامر التالية :


تحديث لوحة التحكم CPANEL


 


رمز PHP:

 /scripts/upcp --force

ترقية الآكزايم exim


رمز PHP:

 /scripts/exim4 --force

ترقية قواعد البيانات MYSQL


رمز PHP:

 /scripts/mysqlup --force

ترقية الأف تي بي FTP


رمز PHP:

 /scripts/ftpup --force

ترقية Syncup Cpanel RPM


رمز PHP:

 /scripts/sysup

امر اصلاح البريد


رمز PHP:

 /scripts/mailperm

امر اصلاح المساحات وبعض المشاكل


رمز PHP:

 /scripts/fixquotas

رمز PHP:

 /scripts/fixcommonproblems

رمز PHP:

 /scripts/fixeverything

رمز PHP:

 /scripts/fixndc

رمز PHP:

 /scripts/fixvaliases

بعد ذلك تحديث الأباتشي بواسطة الآمر :


رمز PHP:

 /scripts/easyapache

بعدها نسوي ريستارت للخدمات :


بعد تحديث البرامج نقوم بإعادة ريستارت لها :


 


رمز PHP:



 # /scripts/restartsrv httpd

# /etc/rc.d/init.d/cpanel restart

# /scripts/restartsrv mysql

# /scripts/restartsrv named

# /scripts/restartsrv exim

 


# service chkservd restart


# service xinetd restart

# /scripts/restartsrv_pureftpd

# /etc/init.d/crond restart


بعدها شوف مواقع راح تشوفها كلها شغالة بإذن الله

10 أوامر لينكس مفيد لمدراء السيرفرات عن طريق الشل

1. حفظ نتائج صفحات man بصيغة .pdf

رمز Code:

man -t awk | ps2pdf - awk.pdf


2. نسخ/تكرار إعداد الحزم المنصبة للـ RPMs من سيرفر إلى سيرفر آخر

رمز Code:

ssh root@remote.host "rpm -qa" | xargs yum -y install


3. كتابة هيدر (مثل برنامج الـ Word) على صفحات امتداد .pdf بشكل سريع من خلال الشل

رمز Code:

echo "This text gets stamped on the top of the pdf pages." | enscript -B -f Courier-Bold16 -o- | ps2pdf - | pdftk input.pdf stamp - output output.pdf


4. معرفة عدد المتصلين على قاعدة بيانات MySQL معينة

رمز Code:

mysql -u root -p -BNe "select host,count(host) from processlist group by host;" information_schema


5. ضغط ملف بشكل سريع إلى صيغة tar من خلال سيرفر آخر

رمز Code:

ssh user@host "tar -zcf - /path/to/dir" > dir.tar.gz


6. أمر سريع لمعرفة استخدامات موارد السيرفر tail a log over ssh

رمز Code:

ssh -t remotebox "tail -f /var/log/remote.log"


7. عمل Diagram سريع لتراخيص users/groups بشكل صورة /etc/group

رمز Code:

awk 'BEGIN{FS=":"; print "digraph{"}{split($4, a, ","); for (i in a) printf "\"%s\" [shape=box]\n\"%s\" -> \"%s\"\n", $1, a[i], $1}END{print "}"}' /etc/group|display


8. عمل كلمة مرور قوية لكن سهلة الحفظ



رمز Code:

read -s pass; echo $pass | md5sum | base64 | cut -c -16


9. هذا الأمر لتحديد الملفات على السيرفر التي تقع ما بين 500 ميجا : 1 جيجا

رمز Code:

find / -type f -size +500M -size -1G


10. هذا الأمر لخفض معدلات تحميل معالج السيرفر Limit CPU Usage

رمز Code:

sudo cpulimit -p pid -l 50


أتمنى أن تجدوا بعض الأوامر المفيدة لديكم,

أجمل تحية

الحماية من هجمات حجب الخدمة , how to stop DDos

اليكم شرح غاية بالاهمية و هو التصدي لهجمات حجب الخدمة

DDos Or Distributed Denial of Service


الأول خلونا نعرف حبة مصطلحات يمكن تنفعنا لو فهمنا معناها ..


KeepAlive : هو المسؤول عن أنه يكون فى إتصال أو أكثر لمدة ثانية مثلاً من نفس المستخدم



MaxKeepAliveRequest : هو أكبر عدد يمكن تحديده للإتصال على السرفر من إتصال ثابت بمعنى أوضح نفس الأيّ بي



KeepAliveTimeout : هو مقدار عدد الثواني بين اللى هيسمح بيها البوكس بين كل إتصال وإتصال من نفس الأيّ بيي


Timeout : هو مقدار الوقت المسموح بيه قبل عملية الكونكشن نفسها هى اللى الريسيف والسينت قبل ما يدي تايم أوت أو ميسمحش بعرض الصفحة


MinSpareServers : المسؤول عن عملية فحص دورية ويعرف عدد المنتظرين عملية الطلب , اللي هي السيند والريسيف أو الإتصال مع البوكس عموماً



MaxSpareServers: مرتبط باللى قبله ولو هو أكتر منو هيلغى عمليات إتصال كتيرة


دول اللى هنعوزهم النهاردة فى شرحنا ..

ندخل في الشغل..


دلوقت حسيت التصفح تقيل , أو لاقيت الأباتشى فيلد أو الحاجات المعروفة اللى بنشوفها فى السرفرات والشكاوى اللى بتيجي أول خطوة أيه؟

رمز Code:

Uptime


الآمر دا عبارة عن بيعرفك اللود كام على سرفرك ودا اللى محتاجينه أحنا


عموما عشان مش يحصل لخبطة أعلى شيء على اللود في كل الانواع سواء كان معالج واحد أو أتنين او تلاتة أو أي حاجة مش يزيد عن 5


أكتر من كدا يبقى فى حاجة من 3

Attack بشتى أنواعه

Spam

localdos


والإسبام معروف طبعاً حلوله ولو حد عايز يسأل عن حلوله يتفضل يطلبها


نرجع لموضوعنا... الأتاك هيكون دانيال أوف سيرفس


بداية نعرف الترافيك المستخدم على السرفر في الوقت الحالى عادي ولالا؟


فى طريقتين ..... الأولى أني أكلم الداتا سنتر وأطلب منهم القياس من الرواتر بالظبت؟

والطريقة دى بطيئة لانه مش كل الـداتا سنترس سريعة في العمليات دى
الطريقة التانية وهي تركيب برنامج رائع

BWM – NG


طريقة التركيب..

رمز Code:

cd /usr/local/src



رمز Code:

wget http://www.gropp.org/bwm-ng/bwm-ng-0.5.tar.gz



رمز Code:

tar -zxf bwm-ng-0.5.tar.gz



رمز Code:

cd bwm-ng-0.5



رمز Code:

./configure; make; make install


ومن ثم أنتهي التنصيب ندخل في القياس البرنامج وظيفته بيقيس الترافيك


** ملاحظة مهمة , لا تعتمد على لوحة التحكم لديك لأنها تقيس الترافيك على الأباتشى فقط , لكن يوجد موارد أخرى تستهلك الترافيك الميلات .. الأف تي بي .. POP3 إلخ... لذلك عليك بالبرامج الخاصة بذلك


نعود لموضوعنا.. ونكتب الآمر التالى

رمز Code:

bwm-ng


هيطلع لنا الترافيك على اليمين , المعدل الأقصى لأيّ سرفر عادي لا يتجاوز نسبة معينة

مثال , الباندويث عندك 1500 جيجا شهريّاً يبقى التصفح العادى بالنسبة لك لازم يكون فى البرنامج مش أكتر من 550 كيلو بايت حد أقصي أو 600

أكثر من كدا يبقى في Attack وبكدا المشكلة فى الترافيك وحلها هنعرفه تحت طبعاً


نروح نشوف حالة الأباتشى أيه بالأمر التالى

رمز Code:

Httpd status


**ملاحظة , بعض السرفرات الأمر دا مبيديش ناتج ليهم للاسف

وبيطلع الرسالة دى

Not Found

The requested URL /server-status was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an
Error******** to handle the request.


والحل كالتالى

التعديل فى ملف الكونفنج للاباتشى

رمز Code:

pico -w /etc/httpd/conf/httpd.conf


**البحث بيتم عن إتخدام Ctrl + W


والبحث عن التالى

رمز Code:

#<Location /server-status>
SetHandler server-status#
Order deny,allow#
Deny from all#
Allow from example.com #
#< /Location>


شيل كل العلامات اللى من النوع دا #



وغير كلمة إيكسامبل بـ كلمة

localhost


ومن ثم أعد تشغيل الأباتشى

رمز Code:

httpd restart


وأكتب الآمر مرة أخرى سيعمل وعلى ضمانتى



هيديلك حاجة بالشكل دا


Server Version: Secured By : S3B ALMNAL
Server Built: April 30 2006 05:13:00

__________________________________________________ _______________

Current Time: Wednesday, 05-Oct-2005 18:16:02 EDT
Restart Time: Wednesday, 05-Oct-2005 18:15:55 EDT
Parent Server Generation: 18
Server uptime: 7 seconds
Total accesses: 24 - Total Traffic: 117 kB
CPU Usage: u0 s0 cu0 cs0
3.43 requests/sec - 16.7 kB/second - 4992 B/request
9 requests currently being processed, 4 idle servers


دا لو السرفر شغال عادي جداً

نبدأ الملاحظات هنا...

يجب أن السرفر الريكوست اللى فوق مش يزيد عن 30 أو 40 , لو زاد هتبقى بكدا فى فعلاً هجوم عليك..

وعشان نتأكد أكتر وأكتر نشوف الكونكشن كام

رمز Code:

netstat -n | grep :80 |wc –l



رمز Code:

netstat -n | grep :80 | grep SYN |wc –l



الأمر الأول يجب أن لا يزيد الكونكشن عن 450

والآمر الثاني لا يزيد عن 120 " ومن الممكن أنه ميديش ناتج لانك هتكون مفعل الساين كوكس"

نبدأ الحلول , فى مود رائع بيتركب للأباتشى وشايف أنه كلمة رائع لا توفي حقه خاصة أنه مجاني


mod_dosevasive

طريقة التركيب

رمز Code:

cd /usr/local/src



رمز Code:

wget http://www.nuclearelephant.com/projects/mod_evasive/mod_evasive_1.10.tar.gz tar -zxf mod_dosevasive_1.10.tar.gz



رمز Code:

cd mod_dosevasive



رمز Code:

/etc/httpd/bin/apxs -cia mod_dosevasive.c


ومن ثم وكالعادة هنعدل على ملف كونفنج الأباتشى ..


ودور على

رمز Code:

<IfModule mod_dosevasive.c>


واكتب تحتها



رمز Code:

DOSHashTableSize 3097
DOSPageCount 5
DOSSiteCount 100
DOSPageInterval 2
DOSSiteInterval 2
DOSBlockingPeriod 600
</IfModule>


** ملاحظة , أحيانا مش بتلاقيه فى ملف الكونفنج , الحل أكتب التالى



رمز Code:

<IfModule mod_dosevasive.c>
DOSHashTableSize 3097
DOSPageCount 5
DOSSiteCount 100
DOSPageInterval 2
DOSSiteInterval 2
DOSBlockingPeriod 600
</IfModule>


في أيّ مكان فى الملف , ولكن قبل ما تقوم بالعملية دى تاخد باك أب من الملف


وأيضاً يجب عمل بعض التعديلات فى ملف الكونفنج للأباتشى ..

رمز Code:

pico -w /etc/httpd/conf/httpd.conf


البحث عن الدوال الأتية كلها وتغيير قيمتها


Timeout 15


KeepAlive Off


KeepAliveTimeout 5

MinSpareServers 15

MaxSpareServers 20

وايضاً تفعيل الساين كوكيس " مع إنى لا أحب تلك الخطوة لانه في بعض الفايروولات تتسم بالغباء تفلتر الساين باكتس على أنه هجوم !!"

المهم الأمر كالتالي..

رمز Code:

echo 1 > /proc/sys/net/ipv4/tcp_syn******s


هذه هي الحلول المقترحة لإيقاف المشاكل الخاصة بالدانيال أوف سيرفس

شرح تحديد عدد الرسائل لكل عميل على السيرفر

هذا الملخّص غير متوفِّر. يُرجى النقر هنا لعرض المشاركة.

2014/06/20

Chown all folders 755, files 644 in Linux

Sets the permissions for all folders to 755, and for all files 644.


Useful for SUPHP configurations which required this specific permission setup.



find . -type d -print0 | xargs -0 chmod 0755 # For directories



find . -type f -print0 | xargs -0 chmod 0644 # For files

How To Use chmod and chown Command


The chown command is used to change the file's user or group owner for each file. The chmod command changes file access permissions (read/write/execute).


chown command


Here's how you would assign user/group association with a directory:


# chown root:root /var




  • Note* Keep in mind that the first root you're associating belongs to user and the second 'root' belongs to group.


Here's how you would assign user/group association with a file:


# chown root:groupname /home/upload/filename.txt


chmod command


There are two separate groups (role & permission) that dictate how a file will be owned and how it can be handled. Each group has 3 different assignments that can be customized to how you see fit. Below you'll find the groups and each groups assignments:


Roles


- u stands for user
- g stands for group
- o stands for others


Permissions


- r stands for read permission
- w stands for write permission
- x stands for execute permission


Now that you understand what the roles and permissions are, let's put them to use.


Here are some example commands to perform basic role/permission association:


Add a single permission to a file/directory


The + symbol adds a single permission. Here's an example of utilizing +:


# chmod u+x filename


You have associated that file with the user and also added the execute permission to that file. In the following commands you will find + utilized often, to get you used to using that extension.


Add multiple permission to a file/directory


# chmod u+r,g+x filename




  • Note* The comma separates the multiple permission sets.


Remove permission from a file/directory


The following example removes read and write permission for the user.


# chmod u-rx filename


Change permission for all roles on a file/directory


Following example assigns execute privilege to user, group and others. a equals 'all'.


# chmod a+x filename


Make permission for a file same as another file (using reference)


If you want to change a file permission same as another file, you'll need to use the reference option as shown below. In this example, file2 permission will be set exactly same as file1 permission.


# chmod --reference=file1 file2


Change execute permission only on the directories (files are not affected)


If you want to only set permissions to directories/sub-directories and not affect the files stored in them, you can set this up by following the example command below:


# chmod u+X *




  • Note* If the files has execute permission already for either the group or others, the above command will assign the execute permission to the user


 

 

2014/04/16

أوامر الشل shh


cd file لدخول ملف
--------------------------------------
cd .. للخروج من الملف المتواجد فيه إلى الملف الذي قبله مثال
home/pxll/vb/
cd ..
home/pxll/
--------------------------------------
ls عرض محتويات الملف الحالي
--------------------------------------
dir عرض محتويات الملف الحالي
--------------------------------------
pwd استعراض مسار الدليل الحاليً
--------------------------------------
-l توضع بعد ls او dir لعرض معلومات تفصيلية
--------------------------------------
mkdir file لانشاء ملف جديد
--------------------------------------
cp file newfile لنسخ الملف
--------------------------------------
cp file vb/newfile لنسخ الملف ووضع النسخة الجديدة للملف داخل مجلد vb
--------------------------------------
cp file ../newfile لنسخ الملف ووضع النسخة الجديدة للملف خارج الملف الذي تتواجد به مثال
اذا كنت في هذا المسار
home/pxll/vb/
وكتبت هذا الامر
cp vb ../vb2
سيتم نسخ الملف الى هذا المسار
home/pxll/vb2
--------------------------------------
chmod 755 file لاعطاء تصريح لملف معين
--------------------------------------
mv oldfile newfile لاعادة تسمية الملفات او نقلها
--------------------------------------
mv oldfile vb/newfile لنقل الملف نضع اسم الملف الذي سنقل له الملف قبل
--------------------------------------
لعمل ريبوت للسيرفر كامل : reboot
--------------------------------------
لعمل ريستارت لقواعد البيانات:
/etc/init.d/mysql restart
او
service mysql restart
--------------------------------------
لعمل ريستارت لل cpanel :
service cpanel restart
--------------------------------------
who
يعرض عدد المستخدمين على السيرفر
--------------------------------------
rwho -a\
يعرض جميع المستخدمين على شبكتك ... ولكن للإسفادة من هذا الامر يجب تفعيل rwho service
--------------------------------------
history | more
هذا الأمر يقوم بعرض آخر 1000 امر تم كتابه .
--------------------------------------
pwd
هذا الأمر يقوم بعرض المسار الذي انت عليه
--------------------------------------
hostname
يقوم هذا الأمر بعرض اسم ال localhost الذي انت عليه
--------------------------------------
whoami
يعرض الأسم الذي دخلت به على السيرفر
--------------------------------------
date
يقوم هذا الامر يعرض التاريخ والوقت للسيرفر ... وبامكانك التحكم به ايضا
--------------------------------------
time
هذا الامر يقوم بعرض المدة الستغرقة في اتمام عملية ... يعني فرضا time ls ... الأمر ls سيقوم بعرض محتويات المجلد الذي انت عليه ... فعندما نكتب time ls سيقوم هذا الامر باعطائنا الوقت المستغرق لاتمام هذه العملية ... يعني لو كان هناك الكثييير من الملفات التي يجب سردها ... يكون الوقت اطول .
--------------------------------------
uptime
يعطيك هذا الامر الوقت منذ آخر عمل ريسترات للسيرفر
--------------------------------------
ps
يقوم بعرض الاوامر التي قمت انت بعملها .
--------------------------------------
ps aux | more
يقوم هذا الامر بعرض جميع الأمور التي تعمل على السيرفر بالاضافة الى اسم المستخدم لكل امر
--------------------------------------
top
يقوم هذا الامر بوضع جدول متجديد باي عمل يقوم به السيرفر ... يعني بامكانك متابعة اي تحرك بالسيرفر من خلال هذا الامر
--------------------------------------
uname -a
المعلومات على السيرفر
--------------------------------------
free
معلومات مساحة التخزين بالكيلو بايت
--------------------------------------
df -h
يقوم بطرح معلومات الجهاز كاملة بطريقة مقروئة .
--------------------------------------
du / -bh | more
يقوم هذا الامر بطرح معلومات عن جميع مسار وكمية المساحة المستخدمه فيه
--------------------------------------
kill PID
قم بتغير ال PD الى اسم العملية ... وبهذه الحالية يكون هذا لامر لإيقاف اي نوع من انواع العمليات القائمة على السيرفر .
--------------------------------------
امر معرفه من سبب اللود واستهلاك مصادر السيرفر :
/scripts/userps
--------------------------------------
لمعرفة الاب تيم لسرفرك
uptime
--------------------------------------
لمعرفة ما حجم الرام وكم المستهلك وكم المتبقى
free -m
--------------------------------------
ايقاف الاباتشي
httpd stop
--------------------------------------
تشغيل الاباتشي
httpd start
--------------------------------------
تفاصيل البروسسر بالسيرفر
cat /proc/cpuinfo
--------------------------------------
لمعرفة مصدر اللود
top
--------------------------------------
امر تحديث لوحة التحكم CPanel
/scripts/upcp –force
--------------------------------------
امر تحديث الاف تي بي
/scripts/ftpup –force
--------------------------------------
امر اصلاح البريد
/scripts/mailperm
--------------------------------------
امر تحديث – قواعد البيانات
/scripts/mysqlup –force
--------------------------------------
امر اعادة تشغيل الاباتشي
/etc/rc.d/init.d/httpd restart
--------------------------------------
امر اعادة تشغيل السي بنل
/etc/init.d/cpanel restart
--------------------------------------
امر اعادة تشغيل الخدمات بالسيرفر
/etc/init.d/chkservd restart
--------------------------------------
امر اعادة تشغيل الوظائف المؤقته
/etc/init.d/crond restart
--------------------------------------
امر اعادة تشغيل السيرفر
reboot -n
او
shutdown -r now
--------------------------------------
اصلاح كل شي تصاريح دخول هارد ملفات المساحات
/scripts/fixeverything
--------------------------------------
حماية مجلدات tmp
/scripts/securetmp
--------------------------------------
امر ترقية الاكزيم
/scripts/eximup