LoginSignup
1
2

More than 5 years have passed since last update.

PHP7.3とApache2がソースでインストール+Wordpress

Last updated at Posted at 2019-01-16

Apache ソースでインストール

サーバーの対応済み:SELinuxの無効化、Firewalldの無効化

1. 事前準備

yum install epel-release wget gcc libtool autoconf -y
yum install expat-devel pcre pcre-devel openssl-devel -y
  • Apache、apr、apr-utilをダウンロード:
wget http://ftp.jaist.ac.jp/pub/apache//httpd/httpd-2.4.37.tar.gz
wget http://ftp.yz.yamagata-u.ac.jp/pub/network/apache//apr/apr-1.6.5.tar.gz
wget http://ftp.yz.yamagata-u.ac.jp/pub/network/apache//apr/apr-util-1.6.1.tar.gz

2. Apacheをインストール

apache2.4.37
tar -xzvf httpd-2.4.37.tar.gz
tar -xzvf apr-1.6.5.tar.gz
tar -xzvf apr-util-1.6.1.tar.gz

#httpdフォルダーの中にコピーする
mv apr-1.6.5 httpd-2.4.37/srclib/apr
mv apr-util-1.6.1 httpd-2.4.37/srclib/apr-util

#httpdをインストール
cd httpd-2.4.37/
./buildconf
./configure --enable-ssl --enable-so --with-included-apr
make
make install

インストールした後、チェックする。

/usr/local/apache2/bin/apachectl -k start

ブラウザを開いて、下記の画像を見たら、インストールが完了する

work1.png

3. wordpressを準備するために

DocumentRoot とDirectoryを修正しする

vi /usr/local/apache2/conf/httpd.conf

httpd.conf
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
....
</Directory>
httpd.conf
#DirectoryIndexを修正する
<IfModule dir_module>
  DirectoryIndex index.php index.html
</IfModule>

PHPをインストール

1. 事前準備

yum install libxml2-devel bzip2-devel curl-devel zlib-devel -y

2. php をインストール

# phpをダウンロード:
wget http://jp2.php.net/get/php-7.3.1.tar.gz/from/this/mirror
tar -xzvf mirror

# php をインストール
cd php-7.3.1
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-bz2 --enable-calendar --with-curl --enable-ftp --with-pcre-dir --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib --with-openssl
make 
make install

phpファイルを管理するために、httpd.confファイルを修正する

vi /usr/local/apache2/conf/httpd.conf
下記のとおりに、httpd.confファイルに追加する

httpd.conf
<FilesMatch \.php$>
 SetHandler application/x-httpd-php
</FilesMatch>

下記のとおりに、info.phpファイルは/var/www/htmlに追加する

info.php
<?php phpinfo(); ?>

apacheを再起動

/usr/local/apache2/bin/apachectl -k restart

phpのインストールをチェックする

ブラウザを開いて、サーバーのアドレス/info.phpをして、下記の画像を見たら、インストールが完了する

phpwork.png

3. wordpressを連携

wordpress のソースは今/var/www/html/にある。apacheとphpがソースでインストールするので、wordpressのサイトをアクセントする際に、error establishing a database connectionを発生します。
解決方法はwp-config.phpを修正する:
下記のとおりに、wp-config.phpの中にDB_HOSTを修正してください。

wp-config.php
define('DB_HOST','127.0.0.1');
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2