### Example .servbay.config File for Environment Settings Source: https://support.servbay.com/tr/advanced-settings/using-servbay-config This example demonstrates how to configure various software versions and package manager settings within a .servbay.config file. Ensure the specified versions are installed in ServBay. Version numbers are illustrative; use values appropriate for your project and ServBay's supported versions. ```bash # .servbay.config example file # Specify the active PHP version. Ensure this version is installed in ServBay. PHP_VERSION=8.5 # Specify the active Node.js version. Ensure this version is installed in ServBay. NODE_VERSION=20 # Set the mirror repository address for Yarn; used for faster dependency downloads. YARN_CONFIG_REGISTRY=https://npmreg.proxy.ustclug.org/ # Set the mirror repository address for NPM; used for faster dependency downloads. NPM_CONFIG_REGISTRY=https://npmreg.proxy.ustclug.org/ # Specify the local cache directory for NPM. Note: This path is relative to the ServBay installation directory. NPM_CONFIG_CACHE=/Applications/ServBay/tmp/npm/cache # Specify the local cache directory for Yarn. Note: This path is relative to the ServBay installation directory. YARN_CONFIG_CACHE=/Applications/ServBay/tmp/yarn/cache # Specify the active Ruby version. Ensure this version is installed in ServBay. RUBY_VERSION=2.7 # Specify the active Java (OpenJDK) version. Ensure this version is installed in ServBay. JAVA_VERSION=21 # Specify the active Python version. Ensure this version is installed in ServBay. PYTHON_VERSION=3.11 # Specify the active .NET version. Ensure this version is installed in ServBay. DOTNET_VERSION=5.0 # Specify the active Go version. Ensure this version is installed in ServBay. GO_VERSION=1.12 # Configure the Go module proxy server to speed up module downloads. GOPROXY=https://goproxy.cn,direct ``` -------------------------------- ### Start Development Environment with Automation Script Source: https://support.servbay.com/tr/basic-usage/command-line-tool-servbayctl An example bash script to automate the startup of a development environment by stopping all ServBay services and then starting specific required services like PHP, MySQL, Caddy, and Redis. ```bash #!/bin/bash echo "Tüm ServBay servisleri durduruluyor..." servbayctl stop-all echo "Gerekli servisler başlatılıyor..." servbayctl start php 8.1 servbayctl start mysql servbayctl start caddy servbayctl start redis echo "ServBay servisleri başlatıldı." ``` -------------------------------- ### Run Legacy ASP.NET Application with xsp Source: https://support.servbay.com/tr/dotnet/using-dotnet This example shows how to start the `xsp` web server to run legacy ASP.NET applications. Note that compatibility is limited, and this is not recommended for new projects. ```bash # Example: Start xsp server in a specific directory # cd /Applications/ServBay/www/your_legacy_aspnet_app # xsp4 --port 8080 # xsp4 is compatible with .NET 4.x ``` -------------------------------- ### Install Typesense with Yarn Source: https://support.servbay.com/tr/search/using-typesense Install the Typesense client library using Yarn. This is the first step before initializing the client in your code. ```bash yarn add typesense ``` -------------------------------- ### List Installed .NET SDK Versions Source: https://support.servbay.com/tr/dotnet/using-dotnet Use this command to see all installed .NET SDK versions and their paths on your system. ```bash dotnet --list-sdks ``` -------------------------------- ### Install MariaDB Client Source: https://support.servbay.com/tr/nodejs/backend-frameworks/create-and-run-hapijs-project Install the mariadb package using npm to connect to MariaDB databases. ```bash npm install mariadb ``` -------------------------------- ### Install Redis Client for Redis Source: https://support.servbay.com/tr/nodejs/backend-frameworks/create-and-run-koajs-project Install the Node.js client library for Redis integration. ```bash cd /Applications/ServBay/www/servbay-koa-app npm install redis ``` -------------------------------- ### Verify Go Installation Source: https://support.servbay.com/tr/go/using-go Run this command in the terminal to confirm that Go is installed and to check the active version managed by ServBay. ```bash go version ``` -------------------------------- ### Install MongoDB Client Source: https://support.servbay.com/tr/nodejs/backend-frameworks/create-and-run-hapijs-project Install the 'mongoose' or 'mongodb' package using npm to connect to MongoDB databases. ```bash npm install mongoose # veya mongodb ``` -------------------------------- ### Create Project Directories and Config Files Source: https://support.servbay.com/tr/nodejs/set-different-nodejs-for-each-project Set up example project directories and create .servbay.config files within each, specifying different Node.js versions (v18 for project-a, v20 for project-b). ```bash # ServBay'in www klasöründe örnek proje dizinleri oluşturun mkdir /Applications/ServBay/www/project-a mkdir /Applications/ServBay/www/project-b # project-a için .servbay.config dosyasını oluşturun ve Node.js v18 belirtin echo "NODE_VERSION=18" > /Applications/ServBay/www/project-a/.servbay.config # project-b için .servbay.config dosyasını oluşturun ve Node.js v20 belirtin echo "NODE_VERSION=20" > /Applications/ServBay/www/project-b/.servbay.config ``` -------------------------------- ### Install MariaDB or MySQL Driver Source: https://support.servbay.com/tr/nodejs/backend-frameworks/create-and-run-expressjs-project Install either the 'mariadb' or 'mysql2' npm package to connect your Express.js application to a MariaDB or MySQL database. The example uses 'mariadb'. ```bash npm install mariadb # veya npm install mysql2 ``` -------------------------------- ### Perform an HTTP GET Request with cURL Source: https://support.servbay.com/tr/php/modules/curl This example demonstrates how to initiate a cURL session, set options for a GET request (including the URL and return transfer mode), execute the request, and handle potential errors. ```php ``` -------------------------------- ### Initialize Node.js Project and Install Dependencies Source: https://support.servbay.com/tr/nodejs/backend-frameworks/create-and-run-socketio-project Sets up a new Node.js project and installs the necessary Express and Socket.IO packages. Run this in your project's root directory. ```bash cd /Applications/ServBay/www mkdir servbay-socketio-chat cd servbay-socketio-chat npm init -y npm install express socket.io ``` -------------------------------- ### Restart a Specific Service Source: https://support.servbay.com/tr/basic-usage/command-line-tool-servbayctl Restarts a specified service. This is equivalent to stopping and then starting the service. Use -all or a specific version if multiple versions are installed. ```bash servbayctl restart [-all|sürüm] ``` ```bash servbayctl restart pgsql ``` ```bash servbayctl restart redis -all ``` -------------------------------- ### Example Go Version Output Source: https://support.servbay.com/tr/go/using-go This is an example of the output you can expect after running the `go version` command, indicating the active Go version and operating system. ```text go version go1.24.1 darwin/arm64 ``` -------------------------------- ### Create Project Directory Source: https://support.servbay.com/tr/php/modules/swoole Sets up the necessary directories for a new Swoole project. ```bash cd /Applications/ServBay/www/ mkdir my-swoole-app cd my-swoole-app mkdir public ``` -------------------------------- ### Manage MariaDB Service with servbayctl Source: https://support.servbay.com/tr/database-management/getting-started/mariadb-management-and-usage Use the `servbayctl` command-line tool to start, stop, restart, or check the status of specific MariaDB versions. Replace '11.3' with your installed version. ```bash # Start a specific MariaDB version (e.g., MariaDB 11.3) servbayctl start mariadb 11.3 ``` ```bash # Stop a specific MariaDB version servbayctl stop mariadb 11.3 ``` ```bash # Restart a specific MariaDB version servbayctl restart mariadb 11.3 ``` ```bash # Check the running status of a MariaDB service servbayctl status mariadb 11.3 ``` -------------------------------- ### Use Redis in Laravel Routes Source: https://support.servbay.com/tr/php/frameworks/create-and-run-laravel-project Interact with Redis using either the Redis facade or the Cache facade (when CACHE_STORE is set to 'redis'). This example shows setting and getting a value. ```php use Illuminate\Support\Facades\Redis; // Ya da Cache arayüzünü kullanmak için (CACHE_STORE=redis olmalı) // use Illuminate\Support\Facades\Cache; Route::get('/redis-test', function () { // Redis arayüzünü kullan Redis::set('servbay_redis_key', 'Hello from Redis on ServBay!'); $value_redis = Redis::get('servbay_redis_key'); // Veya Cache arayüzü ile (CACHE_STORE=redis olduğunda) // Cache::put('servbay_redis_key', 'Hello from Redis on ServBay!', 600); // $value_cache = Cache::get('servbay_redis_key'); return "Redis verisi: " . $value_redis; }); ``` -------------------------------- ### Memcached Operations in PHP Source: https://support.servbay.com/tr/database-management/getting-started/memcached-management-and-usage This PHP example demonstrates how to connect to a Memcached server, set, get, and delete key-value pairs. Ensure the Memcached extension is enabled in your PHP configuration. ```php addServer("localhost", 11211); // Bağlantıyı kontrol etme (isteğe bağlı) if (!$memcached->getStats()) { echo "Memcached sunucusuna bağlanılamıyor! Lütfen Memcached servisi çalışıyor mu ve port doğru mu kontrol edin.\n"; // Uygulamanıza göre hata işleyin } else { echo "Memcached sunucusuna başarıyla bağlanıldı.\n"; // Anahtar-değer çifti ekleme // set(key, value, expiration=0) // expiration=0, veri hiç bir zaman süresi dolmaz (bellek politikası silene kadar) $memcached->set("my_php_key", "Hello from PHP!", 3600); // 1 saat önbellekle echo "'my_php_key' anahtarı başarıyla ayarlandı.\n"; // Anahtar-değer çifti okuma $value = $memcached->get("my_php_key"); if ($value !== false) { echo "Memcached'den alınan değer: " . $value . "\n"; } else { // Memcached::get() yoksa veya hata varsa false döner // getResultCode() ile nedenini ayırt edebilirsiniz if ($memcached->getResultCode() == Memcached::RES_NOTFOUND) { echo "'my_php_key' anahtarı mevcut değil veya süresi doldu.\n"; } else { echo "'my_php_key' alınırken hata oluştu: " . $memcached->getResultMessage() . "\n"; } } // Anahtar-değer çifti silme if ($memcached->delete("my_php_key")) { echo "'my_php_key' anahtarı silindi.\n"; } else { echo "'my_php_key' anahtarı silinemedi.\n"; } } ?> ``` -------------------------------- ### Create PHPixie Example Template Source: https://support.servbay.com/tr/php/frameworks/create-and-run-phpixie-project Create this HTML template at `assets/templates/app/home.php` to display a welcome message and links to test controller actions. Ensure the necessary directory structure exists. ```html ServBay'de PHPixie'ye Hoşgeldiniz

ServBay'de PHPixie'ye Hoşgeldiniz

Bu sayfa, ServBay üzerinde çalışan PHPixie uygulamanız tarafından dinamik olarak oluşturulmaktadır.

Örnek İşlev Bağlantıları:

İlgili veri tabanı ve önbellek yapılandırma adımlarını tamamladığınızdan emin olun.

``` -------------------------------- ### Install VitePress and Initialize Project (Yarn) Source: https://support.servbay.com/tr/nodejs/frontend-frameworks/create-and-run-vitepress-project Installs VitePress as a development dependency and initializes a new VitePress project using Yarn. ```bash yarn add -D vitepress yarn vitepress init ``` -------------------------------- ### Initialize PHPixie Project with Composer Source: https://support.servbay.com/tr/php/frameworks/create-and-run-phpixie-project Run this Composer command within your project directory to download the PHPixie project template and its dependencies. ```bash composer create-project phpixie/project . ``` -------------------------------- ### SCWS Configuration File Example Source: https://support.servbay.com/tr/other-components/scws This INI file configures SCWS settings, including character set, rule file path, and dictionary path. Ensure paths are correct for your ServBay installation. ```ini [charset] default = utf8 [rule] rules = /Applications/ServBay/etc/scws/rules.ini [dict] dict = /Applications/ServBay/etc/scws/dict.utf8.xdb ``` -------------------------------- ### Docker Konteynerinden ServBay Sitesine Erişimi Yapılandırma (docker run) Source: https://support.servbay.com/tr/faq/docker Docker konteynerini başlatırken ServBay'de yönetilen bir siteyi doğru domain ile erişilebilir hale getirmek için kullanılır. Bu, domaini konteynerin hosts dosyasına ekler. ```bash docker run --add-host=mysite.servbay.demo:host-gateway ... your_image ``` -------------------------------- ### PHP MongoDB Connection, Insert, and Query Example Source: https://support.servbay.com/tr/php/modules/mongodb Connect to a local MongoDB instance, insert a document, query for it, and optionally update or delete it. Ensure the MongoDB service is running and the Composer package is installed. ```php servbay_demo_db->users; // Example database name: servbay_demo_db echo "Connected. Performing operations...\n"; // Insert document $insertResult = $collection->insertOne([ 'name' => 'Alice ServBay', // Example data includes brand 'email' => 'alice.servbay@example.com', 'age' => 30, 'createdAt' => new MongoDB\BSON\UTCDateTime(time() * 1000) // Using BSON date type ]); printf("Inserted document with ID: %s\n", $insertResult->getInsertedId()); // Query document $document = $collection->findOne(['name' => 'Alice ServBay']); echo "Found document:\n"; if ($document) { print_r($document); } else { echo "Document not found.\n"; } // Update document (optional) $updateResult = $collection->updateOne( ['name' => 'Alice ServBay'], ['$set' => ['age' => 31, 'status' => 'updated']] ); printf("Matched %d document(s) for update, modified %d document(s).\n", $updateResult->getMatchedCount(), $updateResult->getModifiedCount()); // Query updated document (optional) $updatedDocument = $collection->findOne(['name' => 'Alice ServBay']); echo "Updated document:\n"; if ($updatedDocument) { print_r($updatedDocument); } // Delete document (optional) // $deleteResult = $collection->deleteOne(['name' => 'Alice ServBay']); // printf("Deleted %d document(s).\n", $deleteResult->getDeletedCount()); } catch (MongoDBDriverExceptionException $e) { echo "An error occurred: " . $e->getMessage() . "\n"; } catch (Exception $e) { echo "An unexpected error occurred: " . $e->getMessage() . "\n"; } echo "Script finished.\n"; ?> ``` -------------------------------- ### Navigate to Project Directory and Install Dependencies Source: https://support.servbay.com/tr/nodejs/frontend-frameworks/create-and-run-react-project After creating the React project, navigate into the project folder and install all necessary dependencies using npm. Alternatively, yarn or pnpm can be used. ```bash cd servbay-react-demo npm install ``` -------------------------------- ### npm Script'lerini Çalıştırma Source: https://support.servbay.com/tr/nodejs/npm Tanımlanan script'ler, terminalde 'npm ' komutuyla çalıştırılabilir. 'start', 'test', 'install', 'restart', 'stop' gibi özel script isimleri için 'run' anahtar kelimesi kullanılmaz. ```bash # Uygulamayı başlat npm start # Testleri çalıştır npm test # Derleme işlemini yürüt npm run build ``` -------------------------------- ### OpenSSL Connection Test Output with Certificate Error Source: https://support.servbay.com/tr/faq/openssl-troubleshooting Example output from 'openssl s_client' showing the 'verify error:num=20:unable to get local issuer certificate' message, indicating a problem with the CA certificate chain. ```bash depth=2 C=US, O=Google Trust Services LLC, CN=GTS Root R1 verify error:num=20:unable to get local issuer certificate verify return:1 depth=1 C=US, O=Google Trust Services, CN=WR2 verify return:1 depth=0 CN=gmail.com verify return:1 # ... diğer bağlantı bilgileri ... ``` -------------------------------- ### Copy .env.example to .env Source: https://support.servbay.com/tr/php/cms/bedrock Copies the example environment file to be used as the actual configuration file. This file should not be committed to version control. ```bash cp .env.example .env ``` -------------------------------- ### Successful OpenSSL Connection Test Output Source: https://support.servbay.com/tr/faq/openssl-troubleshooting Example output from a successful 'openssl s_client' connection after specifying the correct CA file, showing 'verify return:1' for all certificate depths and no 'unable to get local issuer certificate' error. ```bash depth=2 C=US, O=Google Trust Services LLC, CN=GTS Root R1 verify return:1 depth=1 C=US, O=Google Trust Services, CN=WR2 verify return:1 depth=0 CN=gmail.com verify return:1 ``` -------------------------------- ### Install VitePress and Initialize Project (npm) Source: https://support.servbay.com/tr/nodejs/frontend-frameworks/create-and-run-vitepress-project Installs VitePress as a development dependency and initializes a new VitePress project using npm. ```bash npm add -D vitepress npx vitepress init ``` -------------------------------- ### Define a Simple Route in ThinkPHP Source: https://support.servbay.com/tr/php/frameworks/create-and-run-thinkphp-project Add a basic GET route to your `route/app.php` file to test your ThinkPHP project's routing and web server configuration. This example defines a route for '/servbay' that returns a simple 'Hello ServBay!' string. ```php template = $template; } // Varsayılan ana sayfa action public function action_index(Request $request) { // assets/templates/app/home.php şablonunu render et return $this->template->render('app:home'); } // Memcached örneği action public function action_memcached(Request $request) { $cache = $this->components->cache(); $cache->set('key', 'ServBay ile Memcached üzerinden Merhaba!', 60); // 60 saniye geçerli veri kaydet $value = $cache->get('key'); // Veriyi al return $this->response()->string($value); // Dize olarak yanıt döndür } // Redis örneği action public function action_redis(Request $request) { $redis = $this->components->redis(); $redis->set('key', 'ServBay ile Redis üzerinden Merhaba!'); // Veri kaydet $value = $redis->get('key'); // Veriyi al return $this->response()->string($value); // Dize olarak yanıt döndür } // MySQL/PostgreSQL ile kullanıcı ekleme action public function action_add_user(Request $request) { // Veritabanı sorgu oluşturucu ile işlem yap $query = $this->components->database()->query(); // 'users' tablosuna yeni kullanıcı ekle $query->insert('users')->data([ 'name' => 'ServBay Demo Kullanıcı', 'email' => 'demo-' . uniqid() . '@servbay.test', // Benzersiz e-posta kullan ])->execute(); // İşlemi çalıştır return $this->response()->string('Kullanıcı başarıyla eklendi.'); // Başarı mesajı döndür } // MySQL/PostgreSQL ile kullanıcı listeleme action public function action_list_users(Request $request) { // Veritabanı sorgu oluşturucu ile işlem yap $query = $this->components->database()->query(); // 'users' tablosundaki tüm kullanıcıları al $users = $query->select('*')->from('users')->execute()->fetchAll(); // Sonuçları al return $this->response()->json($users); // Kullanıcı listesini JSON olarak döndür } } ``` -------------------------------- ### Install ImageMagick on macOS Source: https://support.servbay.com/tr/extending-servbay/compile-php-module Use Homebrew to install ImageMagick on macOS. Ensure Homebrew is installed first. ```bash brew install imagemagick ``` -------------------------------- ### Start Node.js Development Server Source: https://support.servbay.com/tr/nodejs/backend-frameworks/create-and-run-socketio-project Run the Node.js server for development. Ensure you are in the project directory and specify the port. ```bash cd /Applications/ServBay/www/servbay-socketio-chat PORT=8585 node server.js ``` -------------------------------- ### Docker Konteyner Günlüklerini İnceleme Source: https://support.servbay.com/tr/basic-usage/websites/adding-docker-service-website Belirli bir Docker konteynerinin çalışma zamanı hatalarını veya çıktısını görmek için kullanılır. Konteyner kimliği veya adıyla belirtilir. ```bash docker logs ``` -------------------------------- ### Install Rails Gem Source: https://support.servbay.com/tr/ruby/using-ruby Installs the Ruby on Rails framework gem. This command fetches and installs Rails and its associated dependencies. ```bash gem install rails ``` -------------------------------- ### PHP Index File for Debugging Example Source: https://support.servbay.com/tr/php/using-xdebug-for-php-project-debugging Main entry point for the debugging example. It includes Composer's autoloader, instantiates the Calculator class, and performs calculations, outputting the results. Assumes Composer is used for dependency management. ```php add($num1, $num2); $difference = $calculator->subtract($num1, $num2); echo "Sum: " . $sum . "\n"; echo "Difference: " . $difference . "\n"; echo "Done.\n"; ?> ``` -------------------------------- ### Install Jekyll Gem Source: https://support.servbay.com/tr/ruby/using-ruby Installs the Jekyll static site generator gem. This command fetches and installs the gem and its dependencies. ```bash gem install jekyll ``` -------------------------------- ### Install Project Dependencies Source: https://support.servbay.com/tr/nodejs/backend-frameworks/create-and-run-expressjs-project Navigate into your newly created project directory and run 'npm install' to download and install all required dependencies for your Express.js application. ```bash cd servbay-express-app npm install ```