以下のコマンドを使用して必要なパッケージをインストールします。
sudo yum install -y gcc gcc-c++ autoconf nss_ldap libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib bzip2 curl e2fsprogs krb5 openssl openldap pcre make wget vim cmake gd gd-devel libevent zip unzip libtool
セキュリティ設定の調整:
sudo systemctl stop firewalld
sudo systemctl disable firewalld
echo "SELINUX=disabled" | sudo tee /etc/selinux/config
sudo reboot
MySQLのインストール
グループとユーザーを作成し、MySQLをコンパイルします。
sudo groupadd dbuser
sudo useradd -r -g dbuser mysql_user -s /sbin/nologin
cmake \\
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql_install \\
-DMYSQL_DATADIR=/usr/local/mysql/data \\
-DWITH_MYISAM_STORAGE_ENGINE=1 \\
-DWITH_INNOBASE_STORAGE_ENGINE=1 \\
-DWITH_READLINE=1 \\
-DDEFAULT_CHARSET=utf8 \\
-DDEFAULT_COLLATION=utf8_general_ci
その後、以下を実行します。
make && sudo make install
Nginxのインストール
同様に、Nginx用のグループとユーザーを作成します。
sudo groupadd webserver
sudo useradd -r -g webserver nginx_user -s /sbin/nologin
tar -zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2
./configure \\
--prefix=/usr/local/nginx \\
--sbin-path=/usr/sbin/nginx \\
--conf-path=/etc/nginx/nginx.conf \\
--error-log-path=/var/log/nginx/error.log \\
--http-log-path=/var/log/nginx/access.log \\
--pid-path=/var/run/nginx.pid \\
--with-http_ssl_module \\
--with-http_flv_module \\
--with-http_stub_status_module \\
--with-http_gzip_static_module \\
--user=nginx_user \\
--group=webserver
次に、以下のコマンドでNginxをビルドおよびインストールします。
make && sudo make install
PHPのインストール
PHPの依存ライブラリをインストールし、PHPをコンパイルします。
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && sudo make install
tar zxvf php-7.4.0.tar.gz
cd php-7.4.0
./configure --prefix=/usr/local/php \\
--with-mysql=/usr/local/mysql_install \\
--with-openssl \\
--enable-mbstring \\
--with-jpeg-dir \\
--with-zlib \\
--enable-fpm \\
--with-config-file-path=/etc \\
--with-config-file-scan-dir=/etc/php.d
PHP-FPMの設定ファイルをコピーし、サービスを有効化します。
cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php_fpm_service
sudo chmod +x /etc/rc.d/init.d/php_fpm_service
sudo chkconfig --add php_fpm_service
sudo chkconfig php_fpm_service on
最後に、Nginxの設定ファイルを編集してPHP処理を有効にします。
location ~ \.php$ {
root /www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}