چرک نویس برنامه نویس
2 subscribers
3 files
23 links
در اینجا هر چی که پیدا می کنم و بدرد بخوره رو قرار میدم و توضیح کوتاهی هم در موردش میدم
Download Telegram
سیتسم کشینگ در لاراول
#laravel
https://laravel.com/docs/8.x/cache
راه اندازی #redis در #php
https://github.com/phpredis/phpredis/blob/develop/INSTALL.markdown

بعد به فایل php.ini رفته و این خط رو در اکستنشن ها اضافه می کنید
extension=redis.so
#redis
آموزش کامل ردیس
https://t.me/c/1500601733/2
https://t.me/c/1500601733/3
https://t.me/c/1500601733/4
راه اندازی Redis در lumen
https://t.me/c/1500601733/5
استفاده از redis در پروژه‌های composer
https://t.me/c/1500601733/12
چرک نویس برنامه نویس pinned «لیست #هشتگ ها #php #laravel #redis آموزش کامل ردیس #lumen آموزش راه اندازی یک http proxy #proxy»
#redis
نصب و استفاده از Redis در پروژه compser
https://github.com/predis/predis
با دستور زیر می تونید توی کامپوزر ردیس رو برای خودتون نصب کنید:
composer require predis/predis
در هر کدی که می‌خواهید استفاده کنید کافیه از دستور‌های زیر استفاده کنید:
use Predis\Client as Redis;
// Parameters passed using a named array:
$client = new Redis([
'scheme' => 'tcp',
'host' => '10.0.0.1',
'port' => 6379,
]);
//or
// Same set of parameters, passed using an URI string:
$client = new Predis\Client('tcp://10.0.0.1:6379');

$client = new Redis();
$client->set('foo', 'bar');
$cilent->expire('foo',1);
$value = $client->get('foo');
روش وصل شدن از یک سرور به سرور دیگر با پروکسی

#proxy
شما می‌توانید در دبیان با استفاده از squid به راحتی یک http proxy راه اندازی کنید و با یوزر و پسورد خودتون توش لاگین کنید
برای این منظور لینک زیر رو دنبال کنید
https://linuxize.com/post/how-to-install-and-configure-squid-proxy-on-debian-10/


حالا برای این که بتونید از تو سرور خودتون به http سرور بیرونی وصل بشید از این کامنت استفاده کنید:
https://www.cyberciti.biz/faq/linux-unix-set-proxy-environment-variable/?__cf_chl_captcha_tk__=pmd_n0n6E_BSuEJPdnGKyrVQeRvrpQGy.iLQGyR84gZRlLo-1629895189-0-gqNtZGzNAyWjcnBszQhl
export http_proxy=http://USERNAME:PASSWORD@proxy-server-ip:PORT/

what is my IP:
https://www.tecmint.com/find-linux-server-public-ip-address/
curl ifconfig.me
#API_Gateway
راه اندازی API Gateway با Kong
#درحال‌تکمیل
{توضیحاتی در مورد API Gateway و Kong}

##### Kong start guide

### KONG CORE

# install Kong from repository
# add Kong repository to debian list
echo "deb [trusted=yes] https://download.konghq.com/gateway-2.x-debian-$(lsb_release -sc)/ default all" | sudo tee /etc/apt/sources.list.d/kong.list 
# get update
sudo apt-get update
# install kong OSS core
sudo apt install -y kong


#### isntall postgare database


# config kong for connect to databse and reply port 8000 and dont reply port 8001 publicaly
# cong configur file put to /etc/kong/kong.conf.default copy this file to kong.conf and edit kong.conf
cd /etc/kong
cp kong.conf.default kong.conf
nano kong.conf
#in this file find pg_user (ctrl+w) and set for theis:

pg_user = kong 
pg_password = Kong
pg_database = kong
# becarful in postgares user and database should be in small case and password is case-sensitive
# save the setting and exit

# initialize Kong to database
kong migrations bootstrap [-c /etc/kong/kong.conf]
# at the end you should see this message: "Database is up-to-date"

# Kong start
kong start [-c /etc/kong/kong.conf]
# see Kong started
# open this url to make sure its work correctly:
http://ServerPublicIP:8000
# this json shuold be show: {"message":"no Route matched with those values"}
# congragulation you start Kong susseccfuly

# for stoping Kong use this command:
kong stop


### Kong admin-API


برای کانفیگ خود کونگ یک ادمین ای پی ای وجود دارد که فقط از طریق پورت ۸۰۰۱ یا ۸۴۴۴ و از داخل خود سرور (۱۲۷.۰.۰.۱) در دسترس است. برای درست شدن این مشکل میآیید و خود سرویس ادمین کونگ را به عنوان یکی از سرویس های کونگ قرار میدهیم و برایش آتنتیکیشن مینویسییم
تمامی کد های زیر را باید در ترمینال خود دستگاهی که سرویس روی آن ران است بنویسیم
# create admin-api service
curl -X POST http://localhost:8001/services \
--data name=admin-api \
--data host=localhost \
--data port=8001


# create admin-api route
curl -X POST http://localhost:8001/services/admin-api/routes \
--data paths\[\]=/admin-api


# test new service
در این مرحله باید از طریق ای پی پابلیک سرور در خارج از ان به این سرویس دسترسی داشته باشید و جسون زیر را ببینید
https://serverPublicIP:8443/admin-api
# lua_version : ...


# add basic-auth plugin to admin-api service
curl -X POST http://localhost:8001/services/admin-api/plugins \
--data "name=basic-auth" \
--data "config.hide_credentials=true"


# create a consumer
curl -d "username=my-user&custom_id=1" http://localhost:8001/consumers/


# add password for this consumer
curl -X POST http://localhost:8001/consumers/my-user/basic-auth \
--data "username=my-user" \
--data "password=my-password"


# how to access with this consumer
# encode the credential
echo "my-user:my-password" |base64


# and make the request:
curl -s -X GET \
--url https://*.*.*.*:8443/admin-api \
--header 'Authorization: Basic ***************='
مشکل ارور ۴۰۴ برای لومن، لاراول و ... #e404
حل مشکل rewrite در آپاچی و php 7.3
ابتدا باید این مود را با دستور زیر فعال کنید:
sudo a2enmod rewrite
سپس در فایل کانفیگ سایت واقع در
/etc/apache2/sites-available/
در بین تگ های VirtualHost این کد را اضافه کنید:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
در انتها باید کد زیر را در فایل .htaccess قرار دهید:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>