CentOS に PHP5 と PHP7 をインストールする方法
推奨 (無料): PHP7
##PHP5 をインストールします
バイナリ パッケージをダウンロードして解凍します。
[root@test-a src]# cd /usr/local/src/ [root@test-a src]# wget http://cn2.php.net/distributions/php-5.6.32.tar.bz2 [root@test-a src]# tar jxvf php-5.6.32.tar.bz2
- PHP をコンパイルしてインストールします
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif #报错: ... configure: error: Cannot find OpenSSL's <evp.h> # 安装openssl [root@test-a php-5.6.32]# yum install openssl-devel -y ... Total size: 14 M Total download size: 151 k Downloading packages: Delta RPMs disabled because /usr/bin/applydeltarpm not installed. libselinux-utils-2.5-12.el7.x8 FAILED http://mirrors.163.com/centos/7/os/x86_64/Packages/libselinux-utils-2.5-12.el7.x86_64.rpm: [Errno 14] HTTP Error 416 - Requested Range Not Satisfiable Trying other mirror. Error downloading packages: libselinux-utils-2.5-12.el7.x86_64: [Errno 256] No more mirrors to try. # 安装过程报错,需要安装deltarpm [root@test-a php-5.6.32]# yum install deltarpm ... Downloading packages: No Presto metadata available for base libselinux-utils-2.5-12.el7.x8 FAILED http://mirrors.163.com/centos/7/os/x86_64/Packages/libselinux-utils-2.5-12.el7.x86_64.rpm: [Errno 14] HTTP Error 416 - Requested Range Not Satisfiable Trying other mirror. Error downloading packages: libselinux-utils-2.5-12.el7.x86_64: [Errno 256] No more mirrors to try. # 还是报错,由于之前用的Base源是163的,换回默认的Base源再试就OK了... :( # 继续初始化配置过程,报错 ... checking for BZip2 support… yes checking for BZip2 in default path… not found configure: error: Please reinstall the BZip2 distribution [root@test-a php-5.6.32]# yum -y install bzip2-devel # 继续报错 ... checking for stdarg.h... (cached) yes checking for mcrypt support... yes configure: error: mcrypt.h not found. Please reinstall libmcrypt. # 继续报错 [root@test-a php-5.6.32]# yum install -y libmcrypt-devel #继续报错 ... checking for MySQL support... yes checking for specified location of the MySQL UNIX socket... no configure: error: Cannot find libmysqlclient_r under /usr/local/mysql. Note that the MySQL client library is not bundled anymore! # PHP默认是去/usr/local/mysql/lib/mysql/搜索,没有找到报错,复制或者做个软连接就行. [root@test-a php-5.6.32]# cp /usr/local/mysql/lib/libmysqlclient.so /usr/local/mysql/lib/mysql/libmysqlclient_r.so # 再次安装,苍了个天,看见Thank you...啦 成功! ... Thank you for using PHP. config.status: creating php5.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating sapi/cgi/php-cgi.1 config.status: creating ext/phar/phar.1 config.status: creating ext/phar/phar.phar.1 config.status: creating main/php_config.h config.status: executing default commands # 编译 [root@test-a php-5.6.32]# make ... Build complete. Don't forget to run 'make test'. # 安装 [root@test-a php-5.6.32]# make install
- PHP モジュールの表示(すべて静的)
[root@test-a php-5.6.32]# /usr/local/php/bin/php -m [PHP Modules] bz2 Core ctype date dom ereg exif fileinfo filter gd hash iconv json libxml mbstring mcrypt mysql mysqli openssl pcre PDO pdo_mysql pdo_sqlite Phar posix Reflection session SimpleXML soap sockets SPL sqlite3 standard tokenizer xml xmlreader xmlwriter zlib [Zend Modules] # 拷贝配置文件 [root@test-a php-5.6.32]# cp php.ini-production /usr/local/php/etc/php.ini # 查看php信息 [root@test-a php-5.6.32]# /usr/local/php/bin/php -i
PHP7 のインストール
- インストール パッケージをダウンロードして解凍します#
[root@test-a src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2 [root@test-a src]# tar jxvf php-7.1.6.tar.bz2
ログイン後にコピー
- #
[root@test-a src]# cd php-7.1.6/ [root@test-a php-7.1.6]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif # 出错 .... checking for mysql_set_server_option in -lmysqlclient_r... no configure: error: wrong mysql library version or lib not found. Check config.log for more information. # 由于php已经带了这个模块,所以编译时不指定mysqli的路径,继续 [root@test-a php-7.1.6]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif #出错 ... checking for mysql_commit in -lmysqlclient_r... (cached) no configure: error: PDO_MYSQL configure failed, MySQL 4.1 needed. Please check config.log for more information. #编译时不指定pdo的路径,继续 root@test-a php-7.1.6]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql --with-mysqli --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif ... Thank you for using PHP. config.status: creating php7.spec config.status: creating main/build-defs.h config.status: creating scripts/phpize config.status: creating scripts/man1/phpize.1 config.status: creating scripts/php-config config.status: creating scripts/man1/php-config.1 config.status: creating sapi/cli/php.1 config.status: creating sapi/cgi/php-cgi.1 config.status: creating ext/phar/phar.1 config.status: creating ext/phar/phar.phar.1 config.status: creating main/php_config.h config.status: executing default commands
ログイン後にコピー コンパイルしてインストールします
-
さらに関連する学習については、
[root@test-a php-7.1.6]# make [root@test-a php-7.1.6]# make install [root@test-a php-7.1.6]# ls /usr/local/apache2.4/modules/libphp* /usr/local/apache2.4/modules/libphp5.so /usr/local/apache2.4/modules/libphp7.so
ログイン後にコピーPHP7 チュートリアル
に注目してください。
以上がCentOS に PHP5 と PHP7 をインストールする方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック

CentOS で中国語入力を使用する方法には、次のものが含まれます。 fcitx 入力方法を使用する: fcitx をインストールして有効にし、ショートカット キーを設定し、ショートカット キーを押して入力方法を切り替え、ピンインを入力して候補単語を生成します。 iBus 入力方法を使用する: iBus をインストールして有効にし、ショートカット キーを設定し、ショートカット キーを押して入力方法を切り替え、ピンインを入力して候補単語を生成します。

CentOS 7 で U ディスク ファイルを読み取るには、まず U ディスクを接続し、そのデバイス名を確認する必要があります。次に、次の手順に従ってファイルを読み取ります。 USB フラッシュ ドライブをマウントします: mount /dev/sdb1 /media/sdb1 (「/dev/sdb1」を実際のデバイス名に置き換えます) USB フラッシュ ドライブ ファイルを参照します: ls /media /sdb1; cd /media /sdb1/ディレクトリ; cat ファイル名

CentOS 7 の root 権限に入る方法は 2 つあります。 sudo コマンドを使用します。ターミナルで sudo su - と入力し、現在のユーザー パスワードを入力します。 root ユーザーとして直接ログインします。ログイン画面で「その他」を選択し、「root」と root パスワードを入力します。注: root 権限で慎重に操作し、sudo 権限でタスクを実行し、root パスワードを定期的に変更してください。

scp コマンドを使用すると、ネットワーク ホスト間でファイルを安全にコピーできます。データ転送と認証には ssh を使用します。一般的な構文は次のとおりです: scpfile1user@host:/path/to/dest/scp -r/path/to/source/user@host:/path/to/dest/scp ファイルを除外する scp コマンドを使用する場合はできないと思いますファイルをフィルタリングまたは除外します。ただし、ファイルを除外し、ssh を使用して安全にコピーするという良い回避策があります。このページでは、scp を使用してディレクトリを再帰的にコピーするときにファイルをフィルタリングまたは除外する方法について説明します。 rsync コマンドを使用してファイルを除外する方法 構文は次のとおりです。 rsyncav-essh-

CentOS パスワードを忘れた場合の解決策は次のとおりです。 シングルユーザー モード: シングルユーザー モードに入り、passwd root を使用してパスワードをリセットします。レスキュー モード: CentOS Live CD/USB から起動し、ルート パーティションをマウントし、パスワードをリセットします。リモート アクセス: SSH を使用してリモートに接続し、sudo passwd root でパスワードをリセットします。

CentOS ユーザー名とパスワードを忘れた場合、アクセスを復元するには 2 つの方法があります。 root パスワードをリセットします。サーバーを再起動し、GRUB メニューでカーネル コマンド ラインを編集し、「rw init=/sysroot/bin/sh」を追加して Ctrl キーを押します。 +x ;ルート ファイル システムをマウントし、シングル ユーザー モードでパスワードをリセットします。レスキュー モードを使用する: CentOS インストール ISO イメージからサーバーを起動し、レスキュー モードを選択します。ルート ファイル システムをマウントし、ISO イメージから chroot 環境をコピーし、パスワードをリセットし、chroot 環境を終了してサーバーを再起動します。

CentOS 7 では root 権限がデフォルトで無効になっていますが、次の手順で有効にできます: 一時的に有効にする: ターミナルで「su root」と入力し、root パスワードを入力します。永続的に有効にする: 「/etc/ssh/sshd_config」を編集し、「PermitRootLogin no」を「yes」に変更し、SSH サービスを再起動します。

CentOS 7 でパスワードを忘れた場合の 3 つの解決策: シングルユーザー モード: システムを再起動し、カーネル オプションを編集し、ro を rw init=/sysroot/bin/sh に変更し、passwd コマンドを使用して root パスワードをリセットします。レスキュー モード: インストール メディアから起動し、レスキュー モードを選択し、ルート ファイル システムをマウントし、ルート ファイル システムに chroot し、passwd コマンドを使用して root パスワードをリセットします。 Grub2 コマンド ライン: システムを再起動し、c を押してコマンド ラインに入り、カーネルをロードし、ルート ファイル システムをマウントし、ルート ファイル システムに chroot を実行して、passwd コマンドを使用して root パスワードをリセットします。
