• Secure. • Compliant. • Trust at the Core. • Built for Saudi Arabia. by K® (Kenzie) SAUDI GULF HOSTiNG an Enterprise of Company Kanz AlKhaleej AlArabi, All rights Reserved.
Knowledgebase
Apache HTTP Server

Getting Started

If you're completely new to the Apache HTTP Server, or even to running a website at all, you might not know where to start, or what questions to ask. This document walks you through the basics.

Clients, Servers, and URLs

Addresses on the Web are expressed with URLs - Uniform Resource Locators - which specify a protocol (e.g. http), a servername (e.g. www.apache.org), a URL-path (e.g. /docs/current/getting-started.html), and possibly a query string (e.g. ?arg=value) used to pass additional arguments to the server.

A client (e.g., a web browser) connects to a server (e.g., your Apache HTTP Server), with the specified protocol, and makes a request for a resource using the URL-path.

The URL-path may represent any number of things on the server. It may be a file (like getting-started.html) a handler (like server-status) or some kind of program file (like index.php). We'll discuss this more below in the Web Site Content section.

The server will send a response consisting of a status code and, optionally, a response body. The status code indicates whether the request was successful, and, if not, what kind of error condition there was. This tells the client what it should do with the response. You can read about the possible response codes in HTTP Server wiki.

Details of the transaction, and any error conditions, are written to log files. This is discussed in greater detail below in the Logs Files and Troubleshooting section.

Hostnames and DNS

In order to connect to a server, the client will first have to resolve the servername to an IP address - the location on the Internet where the server resides. Thus, in order for your web server to be reachable, it is necessary that the servername be in DNS.

If you don't know how to do this, you'll need to contact your network administrator, or Internet service provider, to perform this step for you.

More than one hostname may point to the same IP address, and more than one IP address can be attached to the same physical server. Thus, you can run more than one web site on the same physical server, using a feature called virtual hosts.

If you are testing a server that is not Internet-accessible, you can put host names in your hosts file in order to do local resolution. For example, you might want to put a record in your hosts file to map a request for www.example.com to your local system, for testing purposes. This entry would look like:

127.0.0.1 www.example.com

A hosts file will probably be located at /etc/hosts or C:\Windows\system32\drivers\etc\hosts.

You can read more about the hosts file at Wikipedia.org/wiki/Hosts_(file), and more about DNS at Wikipedia.org/wiki/Domain_Name_System.

Configuration Files and Directives

The Apache HTTP Server is configured via simple text files. These files may be located any of a variety of places, depending on how exactly you installed the server. Common locations for these files may be found in the httpd wiki. If you installed httpd from source, the default location of the configuration files is /usr/local/apache2/conf. The default configuration file is usually called httpd.conf. This, too, can vary in third-party distributions of the server.

The configuration is frequently broken into multiple smaller files, for ease of management. These files are loaded via the Include directive. The names or locations of these sub-files are not magical, and may vary greatly from one installation to another. Arrange and subdivide these files as makes the most sense to you. If the file arrangement you have by default doesn't make sense to you, feel free to rearrange it.

The server is configured by placing configuration directives in these configuration files. A directive is a keyword followed by one or more arguments that set its value.

The question of "Where should I put that directive?" is generally answered by considering where you want a directive to be effective. If it is a global setting, it should appear in the configuration file, outside of any <Directory>, <Location>, <VirtualHost>, or other section. If it is to apply only to a particular directory, then it should go inside a <Directory> section referring to that directory, and so on. See the Configuration Sections document for further discussion of these sections.

In addition to the main configuration files, certain directives may go in .htaccess files located in the content directories. .htaccess files are primarily for people who do not have access to the main server configuration file(s). You can read more about .htaccess files in the .htaccess howto.

Web Site Content

Web site content can take many different forms, but may be broadly divided into static and dynamic content.

Static content is things like HTML files, image files, CSS files, and other files that reside in the filesystem. The DocumentRoot directive specifies where in your filesystem you should place these files. This directive is either set globally, or per virtual host. Look in your configuration file(s) to determine how this is set for your server.

Typically, a document called index.html will be served when a directory is requested without a file name being specified. For example, if DocumentRoot is set to /var/www/html and a request is made for http://www.example.com/work/, the file /var/www/html/work/index.html will be served to the client.

Dynamic content is anything that is generated at request time, and may change from one request to another. There are numerous ways that dynamic content may be generated. Various handlers are available to generate content. CGI programs may be written to generate content for your site.

Third-party modules like mod_php may be used to write code that does a variety of things. Many third-party applications, written using a variety of languages and tools, are available for download and installation on your Apache HTTP Server. Support of these third-party things is beyond the scope of this documentation, and you should find their documentation or other support forums to answer your questions about them.

Log Files and Troubleshooting

As an Apache HTTP Server administrator, your most valuable assets are the log files, and, in particular, the error log. Troubleshooting any problem without the error log is like driving with your eyes closed.

The location of the error log is defined by the ErrorLog directive, which may be set globally, or per virtual host. Entries in the error log tell you what went wrong, and when. They often also tell you how to fix it. Each error log message contains an error code, which you can search for online for even more detailed descriptions of how to address the problem. You can also configure your error log to contain a log ID which you can then correlate to an access log entry, so that you can determine what request caused the error condition.

You can read more about logging in the logs documentation.

What's next?

Once you have the prerequisites under your belt, it's time to move on.

This document covers only the bare basics. We hope that this gets you started, but there are many other things that you might need to know.

دليل البدء

إذا كنت جديدًا تمامًا على خادم Apache HTTP Server، أو حتى على إدارة موقع ويب على الإطلاق، فقد لا تعرف من أين تبدأ، أو ما هي الأسئلة التي تطرحها. يستعرض هذا المستند معك الأساسيات.

العملاء، والخوادم، وعناوين URL

يُعبر عن العناوين على الويب باستخدام عناوين URL - محددات الموارد الموحدة (Uniform Resource Locators) - التي تحدد بروتوكولًا (على سبيل المثال http)، واسم خادم (على سبيل المثال www.apache.org)، ومسار URL (على سبيل المثال /docs/current/getting-started.html)، وربما سلسلة استعلام (على سبيل المثال ?arg=value) تُستخدم لتمرير وسيطات إضافية إلى الخادم.

يتصل العميل (على سبيل المثال، متصفح الويب) بخادم (على سبيل المثال، خادم Apache HTTP Server الخاص بك)، باستخدام البروتوكول المحدد، ويقدم طلبًا للحصول على مورد باستخدام مسار URL.

قد يمثل مسار URL أي عدد من الأشياء على الخادم. فقد يكون ملفًا (مثل getting-started.html) معالج (مثل server-status) أو نوع ما من ملفات\nالبرامج (مثل index.php). وسنناقش هذا بمزيد من التفصيل أدناه في قسم محتوى الموقع الإلكتروني.

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

تُكتب تفاصيل المعاملة، وأي حالات خطأ، في ملفات السجل. وتتم مناقشة ذلك بمزيد من التفصيل أدناه في ملفات السجلات واستكشاف الأخطاء وإصلاحها القسم.

أسماء المضيفين ونظام أسماء النطاقات (DNS)

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

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

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

إذا كنت تختبر خادمًا لا يمكن الوصول إليه عبر الإنترنت، فيمكنك وضع أسماء المضيفين في ملف hosts الخاص بك لإجراء التحليل المحلي. على سبيل المثال، قد ترغب في وضع سجل في ملف hosts لربط طلب www.example.com بنظامك المحلي، لأغراض الاختبار. وسيبدو هذا الإدخال كالتالي:

127.0.0.1 www.example.com

من المحتمل أن يكون ملف hosts موجودًا في /etc/hosts أو C:\Windows\system32\drivers\etc\hosts.

يمكنك قراءة المزيد عن ملف hosts في Wikipedia.org/wiki/Hosts_(file)، والمزيد عن DNS في Wikipedia.org/wiki/Domain_Name_System.

ملفات التكوين والتوجيهات

يتم تكوين خادم Apache HTTP عبر ملفات نصية بسيطة. قد توجد هذه الملفات في أي موقع من بين مجموعة متنوعة من المواقع، اعتمادًا على كيفية تثبيتك للخادم بالتحديد. ويمكن العثور على المواقع الشائعة لهذه الملفات في ويكي httpd. إذا قمت بتثبيت httpd من المصدر، فإن المسار الافتراضي لملفات التكوين هو /usr/local/apache2/conf. وعادةً ما يُسمى ملف التكوين الافتراضي httpd.conf. قد يختلف هذا أيضًا في توزيعات الطرف الثالث من الخادم.

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

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

والسؤال حول "أين يجب أن أضع ذلك التوجيه؟" تُمكِن الإجابة عنه عموماً من خلال النظر في المكان الذي تريد أن يكون فيه التوجيه فعالاً. إذا كان إعداداً عاماً، فيجب أن يظهر في ملف التكوين، خارج أي <Directory>، <Location>، <VirtualHost>، أو قسم آخر. وإذا كان سينطبق فقط على دليل معين، فيجب أن يوضع داخل قسم <Directory> الذي يشير إلى ذلك الدليل، وهكذا. راجع مستند أقسام التكوين لمزيد من المناقشة حول هذه الأقسام.

بالإضافة إلى ملفات التكوين الرئيسية، قد توضع توجيهات معينة في ملفات .htaccess الموجودة في أدلة المحتوى. وتُعد ملفات .htaccess مخصصة بشكل أساسي للأشخاص الذين ليس لديهم وصول إلى ملف (ملفات) تكوين الخادم الرئيسي. يمكنك قراءة المزيد حول ملفات .htaccess في .htaccess دليل كيفية الاستخدام.

محتوى الموقع الإلكتروني

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

المحتوى الثابت هو أشياء مثل ملفات HTML، وملفات الصور، وملفات CSS، وغيرها من الملفات التي توجد في نظام الملفات. التوجيه DocumentRoot يحدد المكان الذي ينبغي أن تضع فيه هذه الملفات في نظام الملفات لديك. يتم تعيين هذا التوجيه إما بشكل عام، أو لكل مضيف افتراضي. ابحث في ملف (ملفات) التكوين لديك لتحديد كيفية تعيين هذا لخادمك.

عادةً، سيتم تقديم مستند يسمى index.html عندما يتم طلب دليل دون تحديد اسم ملف. على سبيل المثال، إذا كان DocumentRoot معيّنًا على /var/www/html وتم تقديم طلب لـ http://www.example.com/work/, فسيتم تقديم الملف /var/www/html/work/index.html إلى العميل.

المحتوى الديناميكي هو أي شيء يتم إنشاؤه في وقت الطلب، وقد يتغير من طلب إلى آخر. هناك طرق عديدة يمكن من خلالها إنشاء المحتوى الديناميكي. وتتوفر مختلف المعالجات لإنشاء المحتوى. برامج CGI قد يُكتب لإنشاء محتوى لموقعك.

يمكن استخدام وحدات نمطية من أطراف خارجية مثل mod_php لكتابة تعليمات برمجية تقوم بمجموعة متنوعة من المهام. وتتوفر العديد من تطبيقات الأطراف الخارجية، المكتوبة باستخدام مجموعة متنوعة من اللغات والأدوات، للتنزيل والتثبيت على خادم Apache HTTP الخاص بك. إن دعم هذه الأمور التابعة لأطراف خارجية يقع خارج نطاق هذه الوثائق، ويجب عليك العثور على الوثائق الخاصة بها أو منتديات الدعم الأخرى للإجابة على أسئلتك حولها.

ملفات السجل واستكشاف الأخطاء وإصلاحها

بصفتك مسؤولاً عن خادم Apache HTTP، فإن أثمن أصولك هي ملفات السجل، وتحديداً سجل الأخطاء. وإن استكشاف أي مشكلة وإصلاحها بدون سجل الأخطاء يشبه القيادة وعيناك مغمضتان.

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

يمكنك قراءة المزيد عن التسجيل في توثيق السجلات.

ما الخطوة التالية؟

بمجرد إلمامك بالمتطلبات الأساسية، حان الوقت للمضي قدماً.

يغطي هذا المستند الأساسيات فقط. نأمل أن يساعدك هذا على البدء، ولكن هناك العديد من الأمور الأخرى التي قد تحتاج إلى معرفتها.

Frequently asked questions · الأسئلة الشائعة

How does the Apache HTTP Server interact with web clients through URLs?كيف يتفاعل خادم Apache HTTP مع عملاء الويب عبر العناوين URL؟

A web client connects to the server using a specified protocol such as HTTP and requests a resource defined by a URL-path, which includes the protocol, servername, path, and optional query string. The server responds with an HTTP status code indicating success or error, along with an optional response body.

يتصل عميل الويب بالخادم باستخدام بروتوكول محدد مثل HTTP، ويطلب مورداً موضحاً بمسار URL والذي يتضمن البروتوكول واسم الخادم والمسار وسلسلة الاستعلام الإضافية إن وجدت. ويرد الخادم برمز حالة موضحاً نجاح الطلب أو نوع الخطأ، مع جسم الاستجابة اختيارياً.

What is the difference between static and dynamic content, and how is static content served?ما الفرق بين المحتوى الثابت والمحتوى الديناميكي، وكيف يتم تقديم المحتوى الثابت؟

Static content consists of files stored on the filesystem like HTML, images, and CSS. The DocumentRoot directive specifies the filesystem directory where these files are placed. Dynamic content is generated at request time using handlers, CGI programs, or third-party modules like mod_php.

يتكون المحتوى الثابت من ملفات مخزنة في نظام الملفات مثل ملفات HTML والصور وCSS، وتحدد توجيهية DocumentRoot المجلد المسؤول عن تخزينها. بينما يتم إنشاء المحتوى الديناميكي أثناء وقت الطلب باستخدام معالجات أو برامج CGI أو وحدات خارجية مثل mod_php.

What DNS prerequisites must be met for a server to be reachable on the Internet?ما هي المتطلبات الأساسية لـ DNS ليكون الخادم متاحاً عبر الإنترنت؟

The servername must be registered in the Domain Name System (DNS) to resolve to the server's IP address. If this is not set up, you must contact your network administrator or Internet service provider to perform the DNS resolution step.

يجب أن يكون اسم الخادم مسجلاً في نظام أسماء النطاقات (DNS) ليتم تحليله إلى عنوان IP الخاص بالخادم. وإذا لم تكن على دراية بذلك، فيجب التواصل مع مسؤول الشبكة أو مزود خدمة الإنترنت لتنفيذ هذه الخطوة.

When should .htaccess files be used instead of modifying main configuration files?متى ينبغي استخدام ملفات .htaccess بدلاً من تعديل ملفات التكوين الرئيسية؟

.htaccess files are primarily used by individuals who do not have administrative access to the main server configuration files. They allow directives to be placed directly within content directories, though main configuration files remain the primary location for system settings.

تُستخدم ملفات .htaccess بشكل أساسي من قبل الأشخاص الذين لا يملكون صلاحية الوصول إلى ملفات التكوين الرئيسية للخادم. وتتيح وضع التوجيهات مباشرة داخل مجلدات المحتوى بدلاً من الملفات الرئيسية.

Where are configuration directives placed and how are sub-files included?أين يتم وضع توجيهات التكوين وكيف يتم تضمين الملفات الفرعية؟

Directives are placed in text files such as httpd.conf (commonly located at /usr/local/apache2/conf when built from source). Global directives go outside sections, while targeted settings go inside sections like Directory or VirtualHost. Sub-files are loaded using the Include directive.

توضع التوجيهات في ملفات نصية مثل httpd.conf (والموجود عادة في /usr/local/apache2/conf عند التثبيت من المصدر). وتوضع التوجيهات العامة خارج القطاعات، بينما توضع الإعدادات المخصصة داخل قطاعات مثل Directory أو VirtualHost، وتُحمل الملفات الفرعية عبر توجيه Include.

How can an administrator validate site setup locally if the server is not Internet-accessible?كيف يمكن للمسؤول التحقق من إعداد الموقع محلياً إذا لم يكن الخادم متاحاً عبر الإنترنت؟

You can configure local hostname resolution by adding an entry to your hosts file (located at /etc/hosts or C:\Windows\system32\drivers\etc\hosts). For example, adding '127.0.0.1 www.example.com' maps requests for that domain to your local system for testing.

يمكنك إعداد تحليل اسم المضيف محلياً عن طريق إضافة مدخل إلى ملف hosts (الموجود في /etc/hosts أو C:\Windows\system32\drivers\etc\hosts). على سبيل المثال، إضافة '127.0.0.1 www.example.com' توجه الطلبات إلى نظامك المحلي لأغراض الاختبار.

How do administrators utilize log files to diagnose and resolve HTTP server errors?كيف يستخدم المسؤولون ملفات السجل لتشخيص أخطاء خادم HTTP وحلها؟

The error log, defined by the ErrorLog directive, records error entries with timestamps, error codes, and potential fix instructions. Administrators can search error codes online or configure a log ID to correlate error log entries directly with specific access log requests.

يسجل سجل الأخطاء، المحدد بتوجيه ErrorLog، تفاصيل الخطأ ووقت حدوثه ورامز الخطأ وإرشادات الحل. ويمكن للمسؤول البحث عن رمز الخطأ أو إعداد معرّف السجل (log ID) لربط السجل بمدخل سجل الوصول لمعرفة الطلب المسبب للخطأ.

Where should administrators seek support for third-party modules or applications running on Apache?أين يجب على المسؤولين طلب الدعم للوحدات أو التطبيقات التابعة لطرف ثالث والمشغلة على Apache؟

Support for third-party tools, applications, and modules (such as mod_php) is beyond the scope of Apache HTTP Server official documentation. Administrators must consult the specific third-party documentation or dedicated support forums for assistance.

الدعم الخاص بالأدوات والتطبيقات والوحدات التابعة لطرف ثالث (مثل mod_php) خارج نطاق وثائق خادم Apache HTTP الرسمية. ويجب على المسؤولين الرجوع إلى وثائق الطرف الثالث أو منتديات الدعم الخاصة بها للحصول على الإجابات.

How can multi-site enterprise environments run multiple websites on a single server instance?كيف يمكن لبيئات المؤسسات متعددة المواقع تشغيل مواقع متعددة على جهاز خادم واحد؟

Enterprise environments can host multiple websites on the same physical server using virtual hosts. Multiple hostnames can point to a single IP address, or multiple IP addresses can be attached to one physical machine to serve distinct domain requests.

تستطيع المؤسسات استضافة عدة مواقع على نفس الخادم الفعلي باستخدام ميزة المضيفين الافتراضيين (Virtual Hosts)، حيث يمكن لعدة أسماء مضيف الإشارة إلى عنوان IP واحد أو توجيه عدة عناوين IP إلى جهاز خادم واحد.

What are the primary next steps for administrators after learning the basic concepts?ما هي الخطوات التالية الأساسية للمسؤولين بعد تعلم المفاهيم الأساسية؟

Once basic prerequisites are understood, administrators should proceed through the core deployment steps: Download, Install, Configure, and Start the Apache HTTP Server, followed by consulting the Frequently Asked Questions for specific operational scenarios.

بمجرد استيعاب المتطلبات الأساسية، يجب على المسؤولين الانتقال إلى خطوات التشغيل الرئيسية: التنزيل، التثبيت، التكوين، والبدء بتشغيل خادم Apache HTTP، ثم مراجعة الأسئلة الشائعة للحالات التشغيلية المحددة.

Enterprise Infrastructure

Secure hosting, cloud and managed infrastructure for Saudi Arabia, GCC and global scale.

Saudi Sovereign

Global Cloud

24/7 Support

Enterprise Security

Enterprise Consultation

Ready to build secure, sovereign-ready digital infrastructure?

Speak with K® (Kenzie) of SAUDI GULF HOSTiNG about enterprise hosting, cloud platforms, VPS, email, cybersecurity and managed infrastructure designed for Saudi Arabia, GCC and global operations.

HostingCloudVPSEmailSecurityManaged Services
KGulf Logo