CentOS 7 LAMP環境の構築

11487 ワード

ソフトウェアソースの変更
CentOSをインストールする場合は、私と同じように最新のインストールを選択します.
一、ネットワーク接続の構成
    $> ip addr

自分のNICを確認
`$> cat /etc/sysconfig/network-scripts/ifcfg-en* //       `   

上の構成からBOOTOPROTO=dhcpではあるが、ONBOOT=noであり、ここでviでONBOOT=noをONBOOT=yesに変更してCentOSを再起動する.
二、静的IPの設定
Eno 167777736は私のNICです
$> vi /etc/sysconfig/network-scripts/ifcfg-eno1677BOOTPROTO=dhcp
IPADDR0=192.168.235.120
PREFIX0=24
GATEWAY0=192.168.235.2
DNS1=114.114.114.114
DNS2=114.114.115.115

インストールツール
$> yum install net-tools, make, gcc, kernel-devel, ntsysv, tree, links, wget

三、仮想マシン強化ツールのインストール
          ,       。
              

四、LAMP環境の配置
1、システム初期化環境の表示
cat /var/log/messages | grep error (           )
dmesg (             )
cat /proc/cpuinfo (   CPU       )
top (  1    CPU       ,        )
ifconfig(          )
ping www.qq.com(        )

2、不要なサービスをオフにする
   ntsysv   :
ntsysv // linux             ntsysv

サービス設定画面では、各サービスのスイッチを設定します.以下には、起動する必要があるサービスのみがリストされ、リストされていないサービスはすべて閉じることを推奨します.
    atd
    crond
    irqbalance
    microcode_ctl
    network
    sendmail
    sshd
    syslog

SElinuxを閉じます./etc/selinux/configファイルのSELINUX=をdisabledに変更します.
3、Apache環境の配置
    yum -y install httpd
    rpm -qi httpd //        

さっきApacheに割り当てたポートを増やしてファイアウォールを通過し、ファイアウォールを再ロードします.
プロファイルの変更
    cd /etc/httpd/conf
    cp httpd.conf httpd.conf.origin
    more httpd.conf
           Apache HTTP          (80)     ,          ‘/etc/httpd/conf/httpd.conf’           :
    LISTEN 8080’         (   3221),     。

HTTPサーバーはすでに起動して、簡単な配置を行います
    vi /etc/httpd/conf/httpd.conf #    
    ServerSignature On  #  ,       Apache   ,Off    
    Options Indexes FollowSymLinks  #   :Options Includes ExecCGI FollowSymLinks(       CGI SSI,      )
    #AddHandler cgi-script .cgi #   :AddHandler cgi-script .cgi .pl (      .pl CGI    )
    AllowOverride None  #   :AllowOverride All (  .htaccess)
    AddDefaultCharset UTF-8 #   :AddDefaultCharset GB2312 (  GB2312     )
    #Options Indexes FollowSymLinks   #    Options FollowSymLinks(              )
    DirectoryIndex index.html   #   :DirectoryIndex index.html index.htm Default.html Default.htm index.php(        ,  index.php)
    MaxKeepAliveRequests 500  #  MaxKeepAliveRequests 500 (       )

サービスの再起動
systemctl restart httpd.service

自動起動に設定
systemctl enable httpd.service  // centos7 chkconfig httpd on      systemctl enable httpd

ファイアウォール管理者権限のカスタマイズ
In CentOS 7.0 uses Firewall-cmd, so I will customize it to allow external access to port 80 (http) and 443 (https).
    firewall-cmd --permanent --zone=public --add-service=http 
    firewall-cmd --permanent --zone=public --add-service=https
    firewall-cmd --reload

ファイアウォールを開くと、クライアントはブラウザからアクセスできます.
links 127.0.0.1 //  cool

4、インストール準備作業最新のepelをインストールする
    rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
    yum -y install epel-release

5、データベースMariaDBのインストール
リファレンス
yum -y install mariadb-server mariadb

systemctl start mariadb.service

起動の設定
systemctl enable mariadb.service

パスワードの設定
mysql_secure_installation

リターンマッチ
コンフィギュレーション
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf  //        。

なぜMariaDBを使うのですか?
MariaDB is the free MySQL fork, MariaDB is compatible with MySQL and the commands from MariaDB are still nemad "mysql" or "mysqldump", so there are no differences from the Client side. All Major Linux Distributions replaced MySQL with MariaDB now, so we will use that for the tutorials as well. Some users also Report that MariDB is faster then MySQL in the latest releases.

6、php 5のインストール
yum -y install php

httpサービスの再起動
systemctl restart httpd.service

構成:
 vi /etc/php.ini
 date.timezone = PRC #        ,  date.timezone = PRC
    disable_functions = passthru,exec,system……#  PHP       ,              ,    ,    。
    expose_php = Off #    php     
    short_open_tag = ON #  php   
    open_basedir = .:/tmp/  #            ( PHP         ) /tmp/  ,    php    ,             (  :        ),      ,           /data/www.osyunwei.com/:/tmp/

テスト:
vi /var/www/html/index.php  
    
 phpinfo(); ?>

wq保存終了.
ページを開き、PHP構成情報ページが表示されたら、PHPサーバーが正常であることを示します.
7、テスト
vi /var/www/html/info.php
  

    phpinfo();
?>

クライアントのWebサイトへのアクセス
8、phpのmysqlサポートを獲得する
yum search php
yum -y install php-mysql

phpモジュールのインストール
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

サービスの再起動
 systemctl restart httpd.service

9.phpMyAdminをインストールする
    yum install phpMyAdmin

phpMyAdminの設定
    vi /etc/httpd/conf.d/phpMyAdmin.conf

コメント
    #
    #   
    #     # Apache 2.4
    #     
    #       Require ip 127.0.0.1
    #       Require ip ::1
    #     
    #   
    #   
    #     # Apache 2.2
    #     Order Deny,Allow
    #     Deny from All
    #     Allow from 127.0.0.1
    #     Allow from ::1
    #   
    #

追加
    <Directory /usr/share/phpMyAdmin/>
        Options none
        AllowOverride Limit
        Require all granted
    Directory>

10.phpMyAdminの認証をクッキーからhttpに変更する
vi /etc/phpMyAdmin/config.inc.php

変更
$cfg['Servers'][$i]['auth_type']     = 'http';    // Authentication method (config, http or cookie based)?

クライアントブラウザでphpMyAdminにログインすると、ユーザー名とパスワードがデータベースのユーザー名とパスワードになります.