YOURLS هو أداة اختصار روابط URL مجانية ومفتوحة المصدر (open-source) ومستضافة ذاتيًا مكتوبة بلغة PHP.
إنه مشابه لـ TinyURL أو Bitly ويسمح لك بتشغيل خدمة اختصار روابط URL الخاصة بك.
يسمح لك بإضافة علامة تجارية إلى عناوين URL القصيرة الخاصة بك.
يوفر مجموعة غنية من الميزات بما في ذلك Private و Public link والكلمات الرئيسية المخصصة لعناوين URL وتقارير النقرات وواجهة Ajaxed ودعم Jsonp وغيرها الكثير.
المتطلبات الأساسية
اسم مجال صالح (domain name) يشير إلى عنوان IP الخاص بالخادم.
إعداد كلمة مرور الـ root للخادم.
تثبيت خادم LEMP
يمكنك تثبيت كل منهم بالأمر التالي:
dnf install nginx mariadb-server php php-fpm php-json php-common php-mysqlnd php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath git unzip wget -y
قم بتعديل ملف الإعداد PHP-FPM /etc/php-fpm.d/www.conf وقم بتغيير المستخدم من apache إلى nginx:
nano /etc/php-fpm.d/www.conf
قم بتغيير الأسطر التالية:
user = nginx
group = nginx
احفظ وأغلق الملف ثم ابدأ خدمة Nginx و MariaDB و PHP-FPM وقم بتمكينها من البدء عند إعادة تشغيل النظام باستخدام الأمر التالي:
systemctl start nginx
systemctl enable nginx
systemctl start mariadb
systemctl enable mariadb
systemctl start php-fpm
systemctl enable php-fpm
إنشاء قاعدة بيانات خاصة بك:
قم بتسجيل الدخول إلى MariaDB باستخدام الأمر التالي:
mysql
بمجرد تسجيل الدخول قم بإنشاء قاعدة بيانات ومستخدم باستخدام الأمر التالي:
MariaDB [(none)]> CREATE DATABASE yourlsdb;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON yourlsdb.* TO 'yourlsuser'@'localhost' IDENTIFIED BY 'password';
امسح الصلاحيات واخرج من MariaDB باستخدام الأمر التالي:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q
تثبيت YOURLS
cd /var/www/html
git clone https://github.com/YOURLS/YOURLS.git
أعد تسمية ملف نموذج الإعداد باستخدام الأمر التالي:
cd YOURLS/user/
cp config-sample.php config.php
قم بتعديل ملف config.php وحدد إعدادات قاعدة البيانات الخاصة بك:
nano config.php
قم بتغيير الأسطر التالية:
/** MySQL database username */
define( 'YOURLS_DB_USER', 'yourlsuser' );
/** MySQL database password */
define( 'YOURLS_DB_PASS', 'password' );
/** The name of the database for YOURLS
** Use lower case letters [a-z], digits [0-9] and underscores [_] only */
define( 'YOURLS_DB_NAME', 'yourlsdb' );
/** MySQL hostname.
** If using a non standard port, specify it like 'hostname:port', eg. 'localhost:9999' or '127.0.0.1:666' */
define( 'YOURLS_DB_HOST', 'localhost' );
/** MySQL tables prefix
** YOURLS will create tables using this prefix (eg `yourls_url`, `yourls_options`, ...)
** Use lower case letters [a-z], digits [0-9] and underscores [_] only */
define( 'YOURLS_DB_PREFIX', 'yourls_' );
define( 'YOURLS_SITE', 'http://yourls.example.com' );
$yourls_user_passwords = array(
'admin' => 'yourpassword',
احفظ وأغلق الملف عند الانتهاء.
قم بإنشاء ملف htaccess باستخدام الأمر التالي:
nano /var/www/html/YOURLS/.htaccess
أضف الأسطر التالية:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /yourls-loader.php [L]
</IfModule>
احفظ الملف وأغلقه.
امنح الأذونات والملكية المناسبين باستخدام الأمر التالي:
chown -R nginx:nginx /var/www/html/YOURLS
chmod -R 775 /var/www/html/YOURLS
إعداد Nginx
nano /etc/nginx/conf.d/yourls.conf
أضف الأسطر التالية:
server {
listen 80;
server_name yourls.example.com;
root /var/www/html/YOURLS;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /yourls-loader.php$is_args$args;
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_index index.php;
fastcgi_pass unix:/run/php-fpm/www.sock;
}
}
احفظ الملف وأغلقه.
أعد تشغيل خدمة Nginx و PHP-FPM بالأمر التالي:
systemctl restart nginx
systemctl restart php-fpm
تحقق من حالة Nginx باستخدام الأمر التالي:
systemctl status nginx
ستحصل على النتيجة التالية:
? nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/nginx.service.d
??php-fpm.conf
Active: active (running) since Tue 2020-10-20 09:37:40 EDT; 5min ago
Process: 12864 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 12862 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 12860 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 12871 (nginx)
Tasks: 3 (limit: 12523)
Memory: 5.5M
CGroup: /system.slice/nginx.service
??12871 nginx: master process /usr/sbin/nginx
??12872 nginx: worker process
??12873 nginx: worker process
Oct 20 09:37:40 centos systemd[1]: Stopped The nginx HTTP and reverse proxy server.
Oct 20 09:37:40 centos systemd[1]: Starting The nginx HTTP and reverse proxy server...
Oct 20 09:37:40 centos nginx[12862]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Oct 20 09:37:40 centos nginx[12862]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Oct 20 09:37:40 centos systemd[1]: Started The nginx HTTP and reverse proxy server.
إعداد SELinux وجدار الحماية
يمكنك إعداد SELinux بالأمر التالي:
setsebool httpd_can_network_connect on -P
chcon -R -u system_u -t httpd_sys_rw_content_t -r object_r /var/www/html/YOURLS
اسمح للمنفذين 80 و 443 عبر جدار الحماية بالأمر التالي:
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --reload
الوصول إلى YOURLS
ستشاهد الصفحة التالية:
اضغط على Install YOURLS.
ستشاهد الصفحة التالية:
اضغط على YOURLS Administration Page.
ستشاهد صفحة تسجيل الدخول YOURLS:
أدخل اسم المستخدم وكلمة المرور الخاصين بالمسؤول (admin) اللذين حددتهما في config.php ثم اضغط فوق زر Login.
ستشاهد لوحة تحكم YOURLS في الصفحة التالية:
تأمين YOURLS مع Let's Encrypt SSL
قم بتثبيت Certbot client باستخدام الأمر التالي:
wget https://dl.eff.org/certbot-auto
mv certbot-auto /usr/local/bin/certbot-auto
chown root /usr/local/bin/certbot-auto
chmod 0755 /usr/local/bin/certbot-auto
احصل على SSL certificate وقم بتثبيتها لموقعك على الويب الخاص بك باستخدام الأمر التالي:
certbot-auto --nginx -d yourls.example.com
سيقوم الأمر أعلاه أولاً بتثبيت جميع التبعيات المطلوبة على الخادم الخاص بك.
بمجرد التثبيت سيُطلب منك تقديم عنوان بريد إلكتروني وقبول مدة الخدمة كما هو موضح أدناه:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): hitjethva@gmail.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for yourls.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/yourls.conf
حدد ما إذا كنت تريد إعادة توجيه حركة مرور HTTP إلى HTTPS أم لا:
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
اكتب 2 واضغط على Enter للمتابعة.
بمجرد اكتمال التثبيت بنجاح ستحصل على النتيجة التالية:
Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/yourls.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://yourls.example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=yourls.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/yourls.example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/yourls.example.com/privkey.pem
Your cert will expire on 2020-06-11. To obtain a new or tweaked
version of this certificate in the future, simply run certbot-auto
again with the "certonly" option. To non-interactively renew *all*
of your certificates, run "certbot-auto renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
يمكنك الآن الوصول إلى موقع الويب الخاص بك بأمان باستخدام عنوان URL https://yourls.example.com .