GNU/Linux >> Linux の 問題 >  >> Ubuntu

Ubuntu20.04にPolrURL短縮サービスをインストールする方法

Polrは、PHPで記述された無料のオープンソースURL短縮サービスです。リンクを作成および管理するためのシンプルでユーザーフレンドリーなインターフェースを提供します。独自のURL短縮サービスをホストし、URLにブランドを設定して、データを管理できます。堅牢なAPI、URL転送、権限のカスタマイズ、テーマなど、多数の機能を提供します。

この投稿では、Apacheを使用してPolrをインストールし、Ubuntu20.04にSSLを暗号化する方法を紹介します。

前提条件
  • Ubuntu20.04を実行しているサーバー。
  • サーバーIPで指定された有効なドメイン名。
  • ルートパスワードはサーバーで構成されています。
はじめに

まず、次のコマンドを実行して、システムパッケージを更新されたバージョンに更新します。

apt-get update -y

すべてのパッケージが更新されたら、次のステップに進むことができます。

Apache、MariaDB、およびPHPをインストールします

まず、Apacheサーバー、MariaDBデータベース、PHP、およびその他のPHP拡張機能をサーバーにインストールする必要があります。次のコマンドですべてをインストールできます:

apt-get install apache2 mariadb-server php libapache2-mod-php libapache2-mod-wsgi php-gd php-curl php-xml php-xmlrpc php-curl php-imagick php-mbstring php-zip php-intl -y

すべてのパッケージがインストールされたら、次のステップに進むことができます。

Polrのデータベースを作成する

Polrは、MariaDB/MySQLをデータベースバックエンドとして使用します。したがって、Polrのデータベースとユーザーを作成する必要があります。

まず、次のコマンドを使用してMariaDBにログインします。

mysql

ログインしたら、次のコマンドを使用してデータベースとユーザーを作成します。

MariaDB [(none)]> CREATE DATABASE polrdb;
MariaDB [(none)]> GRANT ALL ON polrdb.* TO 'polr' IDENTIFIED BY 'password';

次に、特権をフラッシュし、次のコマンドでMariaDBを終了します。

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

完了したら、次のステップに進むことができます。

Composerをインストール

次に、Polrに必要なPHP依存関係をインストールするには、サーバーにComposerをインストールする必要があります。

次のコマンドを実行して、Composerをインストールします。

curl -sS https://getcomposer.org/installer | php

次の出力が得られるはずです:

All settings correct for using Composer
Downloading...

Composer (version 2.1.3) successfully installed to: /root/composer.phar
Use it: php composer.phar

次に、次のコマンドを使用して、Composerバイナリをシステムの場所に移動します。

mv composer.phar /usr/local/bin/composer

次に、次のコマンドを使用してComposerのバージョンを確認します。

composer -V

次の出力が表示されます。

Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
Composer version 2.1.3 2021-06-09 16:31:20
ポルのインストール

次に、Gitリポジトリから最新バージョンのPolrをダウンロードする必要があります。次のコマンドでダウンロードできます:

git clone https://github.com/cydrobolt/polr.git --depth=1 /var/www/html/polr

ダウンロードが完了したら、ディレクトリをPolrに変更し、次のコマンドを使用して必要なすべての依存関係をインストールします。

cd /var/www/html/polr
composer install --no-dev -o

次に、次のコマンドを使用してサンプル環境ファイルをコピーします。

cp .env.setup .env

次に、次のコマンドを使用して、Polrディレクトリに適切な権限を設定します。

chown -R www-data:www-data /var/www/html/polr
chmod -R 755 /var/www/html/polr

終了したら、次のステップに進むことができます。

ApacheをPolr用に構成する

次に、Polr用のApache仮想ホスト構成ファイルを作成する必要があります。次のコマンドで作成できます:

nano /etc/apache2/sites-available/polr.conf

次の行を追加します:

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/polr/public
ServerName polr.example.com
<Directory /var/www/html/polr/public/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/polr-error_log
CustomLog /var/log/apache2/polr-access_log common
</VirtualHost>

ファイルを保存して閉じ、Apache仮想ホストファイルを有効にして、次のコマンドでモジュールを書き換えます。

a2enmod rewrite
a2ensite polr.conf

次に、Apacheサービスを再起動して、変更を適用します。

systemctl restart apache2

これで、次のコマンドを使用してApacheサービスのステータスを確認できます。

systemctl status apache2

次の出力が得られるはずです:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2021-06-17 12:09:42 UTC; 16s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 27602 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 27617 (apache2)
      Tasks: 6 (limit: 2353)
     Memory: 26.6M
     CGroup: /system.slice/apache2.service
             ??27617 /usr/sbin/apache2 -k start
             ??27618 /usr/sbin/apache2 -k start
             ??27619 /usr/sbin/apache2 -k start
             ??27620 /usr/sbin/apache2 -k start
             ??27621 /usr/sbin/apache2 -k start
             ??27622 /usr/sbin/apache2 -k start

Jun 17 12:09:42 ubuntu2004 systemd[1]: Starting The Apache HTTP Server...

AccessPolrWebインターフェイス

これで、URLhttp://polr.example.comを使用してPolrWebインターフェイスにアクセスできます。

データベース名、ユーザー名、パスワード、アプリケーション設定、Polr URL、管理者ユーザー名、電子メール、パスワードを入力し、インストールをクリックします。 ボタン。 Polrをインストールすると、次の画面が表示されます。

ホームページをクリックします。次の画面にPolrダッシュボードが表示されます。

無料のSSLを暗号化して安全なPolr

まず、Certbot Let's Encryptクライアントをインストールして、ドメインのSSL証明書をダウンロードしてインストールする必要があります。

次のコマンドでインストールできます:

apt-get install python3-certbot-apache -y

インストールしたら、次のコマンドを実行して、ドメインpolr.example.comのLet'sEncrypt証明書をインストールできます。

certbot --apache -d polr.example.com

インストール中に、以下に示すように、メールアドレスを入力し、利用規約に同意するよう求められます。

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 polr.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/polr-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-available/polr-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/polr-le-ssl.conf

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キーを押して、ドメインの無料のSSL証明書をダウンロードしてインストールします。インストールが正常に完了したら。次の出力が得られるはずです:

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/polr.conf to ssl vhost in /etc/apache2/sites-available/
polr-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://polr.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=polr.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

これで、PolrWebサイトがLet'sEncryptの無料SSLで保護されました。 URLhttps://polr.example.comを使用してアクセスできます。

結論

上記のガイドでは、Apacheを使用してPolrをインストールし、Ubuntu20.04サーバーにSSLを暗号化する方法を学習しました。これで、Polrを使用して独自のリンク短縮サービスをホストできます。ご不明な点がございましたら、お気軽にお問い合わせください。


Ubuntu
  1. Ubuntu18.04にLogstashをインストールする方法

  2. Ubuntu20.04にYOURLSURL短縮サービスをインストールする方法

  3. Ubuntu18.04にRをインストールする方法

  1. Ubuntu18.04にPloneCMSをインストールする方法

  2. Ubuntu18.04LTSにFlintCMSをインストールする方法

  3. Ubuntu20.04にNginxを使用してShlinkURLShortenerをインストールする方法

  1. Ubuntu20.04LTSにMemcachedをインストールする方法

  2. Ubuntu20.04にApacheSparkをインストールする方法

  3. Ubuntu20.04にFlarumフォーラムをインストールする方法