自宅サーバー ≫ Linux Server ≫ CentOS Stream 8 ≫ SNSサーバー(OpenPNE)

 
前提条件
WebサーバーWebサーバー バーチャルドメイン (apache)SQLサーバーが稼働していることが前提条件
バーチャルドメイン・バーチャルホスト設定
バーチャルホスト openpne.papa-net.info.conf の 作成と設定
※バーチャルホスト を利用しない場合は不用
   
 [root@papa-net]#
vi /etc/httpd/conf.d/openpne.papa-net.info.conf

 
以下新規作成

 <VirtualHost *:80>

 DocumentRoot /home/****/openpne/web
 ServerName openpne.papa-net.info
 ErrorLog logs/openpne.papa-net.info-error_log
 CustomLog logs/openpne.papa-net.info-access_log combined env=!no_log

 <Directory "/home/****/openpne/web">
 Options ExecCGI FollowSymLinks
 AllowOverride All                
<--- 必ず ALL
 Require all granted
 </Directory>

 <IfModule alias_module>
 ScriptAlias /cgi-bin/ "/home/****/openpne/web/cgi-bin/"
 </IfModule>

 <Directory "/home/****/sopenpne/web/cgi-bin">
 AllowOverride All               
<--- 必ず ALL
 Options Includes ExecCGI FollowSymLinks
 Require all granted
 </Directory>

 </VirtualHost>

 
httpd ファイルの構文チェック及びバーチャルドメイン一覧表示
   
 [root@papa-net]#
httpd -t
 
Syntax OK                  <--- Syntax OK になっていればOK

 
[root@papa-net]# httpd -t -D DUMP_VHOSTS
 
VirtualHost configuration:
 *:80               is a NameVirtualHost
     default server blog.papa-net.info (/etc/httpd/conf.d/blog.papa-net.info.conf:1)
     port 80 namevhost blog.papa-net.info (/etc/httpd/conf.d/blog.papa-net.info.conf:1)
     port 80 namevhost sopenpne.papa-net.info (/etc/httpd/conf.d/sopenpne.papa-net.info.conf:1)
     port 80 namevhost www.papa-net.info (/etc/httpd/conf.d/www.papa-net.info.conf:1)
     port 80 namevhost any (/etc/httpd/conf.d/virtualhost-reject.conf:1)

 
OpenPNE用データベース作成
※例として
  **** = rootパスワード &&&& = データベースユーザー #### = データベースユーザーパスワード %%%% = データベース
   
 [root@papa-net]#
mysql -u root -p****
 
データベースにユーザー追加  &&&& = ユーザー  ######## = パスワード
 
MariaDB [(none)] create user &&&& identified by '########';

 
ユーザー確認
 MariaDB [(none)]>
select host,user from mysql.user;
 +-----------+------+
 | host      | user |
 +-----------+------+
 | 127.0.0.1 | root |
 | ::1       | root |
 | localhost | root |
 | localhost | &&&& |
      <--- ユーザー &&&& を確認
 +-----------+------+
 4 rows in set (0.00 sec)

 
データベース新規作成  %%%% = データベース
 MariaDB [(none)]
create database %%%%;
 
 データベースへのユーザーのアクセス権  %%%% = データベース  &&&& = ユーザー  ######## = パスワード
 
MariaDB [(none)]> grant all prlvileges on %%%%.* to &&&&@localhost identified by '########';
 
 データベース確認
 MariaDB [(none)]>
show databases;
 +--------------------+
 | Database           |
 +--------------------+
 | information_schema |
 | mysql              |
 | %%%%               |     
<--- データベース %%%% を確認
 | performance_schema |
 +--------------------+
 4 rows in set (0.03 sec)

 
<参考>
 データベースを削除
 
MariaDB [(none)]> drop database &&&&;      <--- データベース &&&& を削除
 
関連ソフトのインストール
既にインストールされている場合は不要
   
 [root@papa-net]#
dnf -y install php-gd php-xml
 
wget のインストール
既にインストールされている場合は不要
 
 [root@centos]#
dnf -y install epel-release
 
開発環境
既にインストールされている場合は不要

 
 [root@centos]# dnf -y groupinstall "Development Tools"
 

OpenPNE のダウンロード
   
 [root@papa-net]#
wget https://codeload.github.com/openpne/OpenPNE3/legacy.zip/OpenPNE-3.10.4/
                                                      
openpne-OpenPNE3-OpenPNE-3.10.4-0-g173896c
 
※最新版を確認(最新版は 2021年5月現在 3.10.4)
ダウンロードしたファイルを解凍
   
 [root@papa-net]#
unzip openpne-OpenPNE3-OpenPNE-3.10.4-0-g173896c
 
解凍したファイルをホームページ公開ディレクトリに移動
   
 [root@papa-net
]# mv openpne-OpenPNE3-173896c/ /home/****/openpne    <---  **** はHP公開ディレクトリ
 
ダウンロードした不要なファイルを削除
   
 [root@papa-net
]# rm -rf openpne-OpenPNE3-OpenPNE-3.10.4-0-g173896c
 
OpenPNE の所有者(実行権限者)を データベース接続ユーザー  "++++" に変更
   
 [root@papa-net
]# chown -R ++++.++++ /home/****/openpne    <---  **** はHP公開ディレクトリ
 
ホームページ用ディレクトリのアクセス権設定
   
 [root@papa-net]#
chmod 777 /home/****/openpne/     <---  **** はHP公開ディレクトリ
 
OpenPNE のドキュメントルートへ移動
   
 
[root@papa-net]# cd /home/****/openpne    <---  **** はHP公開ディレクトリ
 
OpenPNE の設定
設定ファイルをサンプルよりコピー
   
 
[root@papa-net openpne]# cp config/OpenPNE.yml.sample config/OpenPNE.yml
 
[root@papa-net openpne]# cp config/ProjectConfiguration.class.php.sample config/
                                                                
ProjectConfiguration.class.php
 
設定
   
 
[root@papa-net openpne]# vi config/OpenPNE.yml
 ######################################
 # 基本設定 (Basic)
 ######################################

 # SNS の URL
 # URL of the SNS
 base_url: "http://example.com"
    <--- 公開するURLに変更
     ↓

 base_url: "http://
openpne.papa-net.info"
 
 ######################################
 # メール (Mail)
 ######################################

 # SNS からのメール送信に使うドメイン
 # Domain to use for sending e-mail from the SNS
 mail_domain: "example.com"
    <--- 使用するメールドメインに変更
     ↓

 mail_domain: "
papa-net.info"

 
以下略
 
インストールコマンドの実行
   
 
[root@fedora openpne]# ./symfony openpne:install
 PHP Notice: tempnam(): file created in the system's temporary directory in 
 /home/html/sns/lib/util/opToolkit.class.php on line
 564

     Choose DBMS:
     - mysql
     - pgsql (unsupported)
     - sqlite (unsupported)

 
mysql     <--- mysql を入力

     Type database username

 
****      <--- データベース接続ユーザーを入力

     Type database password (optional)

 
########     <--- データベース接続ユーザーパスワードを入力

     Type database hostname

 
localhost     <--- localhost を入力

     Type database port number (optional)

 
[Enter]     <--- 入力(何も入力しないで Enter)

     Type database name

 
%%%%%%%%      <--- データベース名を入力

     Type database socket path (optional)

 
/var/lib/mysql/mysql.sock     <--- 入力

 The DBMS : mysql
 The Database Username : sns
 The Database Password : ******
 The Database Hostname : localhost
 The Database Port Number :
 The Database Name : sns
 The Database Socket : /var/lib/mysql/mysql.sock

 Is it OK to start this task? (Y/n)

 
y     <--- y を入力

 
以上の事項について入力をおこなうと、インストール作業が自動で行われる

 >> installer installation is completed!

 
最後に上記のように出たらインストール成功
 
開発環境用ファイルを削除
   
 
[root@papa-net openpne]# ./symfony project:clear-controllers
 
mod_rewrite の設定
   
 
[root@papa-net openpne]# vi web/.htaccess
 Options +FollowSymLinks +ExecCGI

 <IfModule mod_rewrite.c>
   RewriteEngine On

   # uncomment the following line, if you are having trouble
   # getting no_script_name to work
  
#RewriteBase /     <--- コメント解除して書き換え 自分の環境によって変わる
      
↓                  openpne の絶対パスで指定
   RewriteBase /     
     当サイトと同じ設定の場合はコメント解除のみ

   # we skip all files with .something
   #RewriteCond %{REQUEST_URI} \..+$
   #RewriteCond %{REQUEST_URI} !\.html$
   #RewriteRule .* - [L]

   # we check if the .html version is here (caching)
   RewriteRule ^$ index.html [QSA]
   RewriteRule ^([^.]+)$ $1.html [QSA]
   RewriteCond %{REQUEST_FILENAME} !-f

   # no, so we redirect to our front web controller
   RewriteRule ^(.*)$ index.php [QSA,L]
 </IfModule>
 
apache の再起動
   
 
[root@papa-net]# systemctl restart httpd
 
OpenPNE にログイン その1

http://<自分のドメイン OR IPアドレス>/index.php にアクセス

ログインフォームに sns@example.com / password と入力し、ログインできるかどうか確認
※メールアドレスとパスワードはログイン後に必ず変更

『ログイン』後、上部メニューの『設定変更』よりメールアドレス・パスワードを変更

OpenPNE にログイン その2

http://<自分のドメイン OR IPアドレス>/pc_backend.php にアクセス

ログインフォームのアカウント名 =  admin パスワード =  password と入力し、ログインできるかどうか確認
※アカウント名とパスワードはログイン後に必ず変更
『アカウント名』 ・ 『パスワード』を入力して『ログイン』をクリック

『ログイン』後、左側メニューの『管理画面設定』⇒上部メニューの『パスワード変更』よりメパスワードを変更

戻る