このチュートリアルでは、Ubuntu 20.04LTSにYourlsをインストールする方法を示します。 知らなかった人のために、YOURLSはYour Own URLShortenerの略です。 これは、独自のURL短縮サービスを実行できるようにする小さなセットの無料のオープンソースPHPスクリプトです。 YOURLSを使用すると、データ、詳細な統計、分析、プラグインなどを完全に制御できます。
この記事は、少なくともLinuxの基本的な知識があり、シェルの使用方法を知っていること、そして最も重要なこととして、自分のVPSでサイトをホストしていることを前提としています。 インストールは非常に簡単で、rootアカウントで実行していることを前提としています。そうでない場合は、 ‘を追加する必要があります。sudo
‘root権限を取得するコマンドに。 Ubuntu 20.04(Focal Fossa)にYourlsオープンソースURL短縮サービスを段階的にインストールする方法を紹介します。 Ubuntu 18.04、16.04、およびLinuxMintなどの他のDebianベースのディストリビューションでも同じ手順に従うことができます。
Ubuntu 20.04 LTS FocalFossaにYourlsをインストールします
手順1.まず、次のコマンドを実行して、すべてのシステムパッケージが最新であることを確認します。 apt
ターミナルのコマンド。
sudo apt update sudo apt upgrade
ステップ2.LAMPスタックをインストールします。
Ubuntu 20.04LAMPサーバーが必要です。 LAMPをインストールしていない場合は、こちらのガイドに従ってください。
ステップ3.Yourls用にMariaDBを構成します。
デフォルトでは、MariaDBは強化されていません。 を使用してMariaDBを保護できます mysql_secure_installation
脚本。 ルートパスワードを設定し、匿名ユーザーを削除し、リモートルートログインを禁止し、テストデータベースと安全なMariaDBへのアクセスを削除する各手順を注意深く読み、以下を実行する必要があります。
mysql_secure_installation
次のように構成します。
- Set root password? [Y/n] y - Remove anonymous users? [Y/n] y - Disallow root login remotely? [Y/n] y - Remove test database and access to it? [Y/n] y - Reload privilege tables now? [Y/n] y
次に、MariaDBコンソールにログインして、Yourlsのデータベースを作成する必要があります。 次のコマンドを実行します。
mysql -u root -p
これによりパスワードの入力を求められるので、MariaDBのrootパスワードを入力して Enter。 データベースサーバーにログインしたら、Yourlsインストール用のデータベースを作成する必要があります。
MariaDB [(none)]> create database yourlsdb character set utf8mb4; MariaDB [(none)]> grant all on yourlsdb.* to 'yourls'@'localhost' identified by 'your-strong-password'; MariaDB [(none)]> flush privileges; MariaDB [(none)]> exit;
ステップ4.Ubuntu20.04にYourlsをインストールします。
次に、Gitリポジトリから最新バージョンのYOURLSをダウンロードします。
cd /var/www/html git clone https://github.com/YOURLS/YOURLS.git
次に、コピー user/config-sample.php
に user/config.php
:
cd YOURLS/user/ cp config-sample.php config.php
次に、構成ファイルを編集し、データベース設定を定義します。
nano config.php
データベース設定に一致する次の行を変更し、ドメイン名と admin パスワード:
* ** MySQL settings - You can get this info from your web host */ /** MySQL database username */ define( 'YOURLS_DB_USER', 'yourls' ); /** MySQL database password */ define( 'YOURLS_DB_PASS', 'your-strong-password' ); /** The name of the database for YOURLS */ 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 */ define( 'YOURLS_DB_PREFIX', 'yourls_' );
完了したら、YOURLSのWebサイトのURLを設定します。
/** YOURLS installation URL -- all lowercase, no trailing slash at the end. ** If you define it to "https://sho.rt", don't use "https://www.sho.rt" in your browser (and vice-versa) */ define( 'YOURLS_SITE', 'https://yourls.your-domain.com' );
次に、ユーザーとパスワードを設定します。
/** Username(s) and password(s) allowed to access the site. Passwords either in plain text or as encrypted hashes ** YOURLS will auto encrypt plain text passwords in this file ** Read https://yourls.org/userpassword for more information */ $yourls_user_passwords = array( 'admin' => 'Ngadimin', 'jmutai' => 'Admin-Strong-Password', // You can have one or more 'login'=>'password' lines );
Save と close 次に、ファイルは所有権を変更し、YOURLSディレクトリに適切な権限を付与します。
chown -R www-data:www-data /var/www/html/YOURLS chmod -R 775 /var/www/html/YOURLS
ステップ5.構成 Apache Yourlsのために。
次に、で新しい仮想ホストディレクティブを作成します Apache。 にとって example、 新しいを作成します Apache ‘という名前の構成ファイルyourls.conf
‘仮想サーバー上:
touch /etc/apache2/sites-available/yourls.conf ln -s /etc/apache2/sites-available/yourls.conf /etc/apache2/sites-enabled/yourls.conf nano /etc/apache2/sites-available/yourls.conf
次の行を追加します。
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /var/www/html/YOURLS ServerName your-domain.com ServerAlias www.your-domain.com <Directory /var/www/html/YOURLS/> Options FollowSymLinks AllowOverride All Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/your-domain.com-error_log CustomLog /var/log/apache2/your-domain.com-access_log common </VirtualHost>
これで、再起動できます Apache 変更が行われるようにWebサーバー:
sudo a2enmod rewrite sudo a2ensite yourls.conf sudo systemctl restart apache2.service
手順6.ファイアウォールを構成する
Apache WebサーバーのUFWファイアウォールおよびファイアウォールブロック要求を有効にした場合は、ファイアウォールでポートを開きます。
sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw reload
ステップ7.YourlsWebインターフェイスへのアクセス。
Yourlsは、デフォルトでHTTPポート80で使用できます。 お気に入りのブラウザを開き、に移動します https://yourls.your-domain.com
インストールを完了するために必要な手順を完了します。
おめでとう! Yourlsが正常にインストールされました。 このチュートリアルを使用して、Ubuntu 20.04 LTS Focal FossaシステムにYourls(Your Own URL Shortener)をインストールしていただきありがとうございます。 追加のヘルプまたは有用な情報については、チェックすることをお勧めします Yourlsの公式ウェブサイト。