CentOS7 + Apache2.4 + MySQL5.7 + PHP7

Source: Internet
Author: User
Tags fpm locale mysql connect ssh zend

CentOS7 + Apache2.4 + MySQL5.7 + PHP7CentOS71. General ユーザ

rootしかない なので, General ユーザを します (Hoge)

$ useradd hoge$ passwd Hoge

ユーザー to confirm

$ cat/etc/passwd

ユーザー Name, グループなどの confirm

$ id Hoge

グループ name =ユーザー name となっているので, necessary であればグループ name は appropriate slew more (developer)

$ groupmod-n Developer Hoge
2. sudo settings

Made into beauty General ユーザー (Hoge) にsudo Copyright Limited
Visudoで/etc/sudoersを Open Earpick, next remember のコメントアウトを outside bamboo blind

$ visudo%wheel all= (All) all
3.ユーザーをwheelグループに Append
$ usermod-g Wheel Hoge
4. Su setting

wheelグループのみにする
The next line のコメントアウトを outside Bamboo blind

$ vi/etc/pam.d/suauth            required        pam_wheel.so use_uid
5. Japanese language (ロケールの slew)
$ localectl Set-locale lang=ja_jp. UTF-8

ロケール to confirm

$ localectl Status   System locale:lang=ja_jp. UTF-8       VC keymap:jp106      X11 layout:jp
6. Selinuxの Stop

The able of the line of memory

$ vi/etc/selinux/configselinux=disabled
7. Firewalld

Centos7からファイアウォールの setting が"iptables"から"firewalld"に Slew more となっています

Now the setting is confirmed (デフォルト)

$ firewall-cmd--list-allpublic (default, Active)  interfaces:eth0  sources:  services:dhcpv6-client SSH  ports:  masquerade:no  forward-ports:  icmp-blocks:  Rich rules:

Httpを additional 前転して開脚座り, set reflection
(80 ポートを けたい)

$ firewall-cmd--add-service=http--permanentsuccess$ firewall-cmd--reloadsuccess

Again, to confirm.

$ firewall-cmd--list-allpublic (default, Active)  interfaces:eth0  sources:  services:dhcpv6-client http SSH  ports:  masquerade:no  forward-ports:  icmp-blocks:  Rich rules:
8. Start Again
Shutdown-r now
リポジトリの Setting

インストールに make うリポジトリの set をします.
Centosには, Formula のリポジトリが intention されていて, usually のyumコマンドで use possible ですが, conservative で latest のソフトウェアやバージョン update が row われないので, epelやremiというパッケージをインストールして, Each リポジトリにある the latest のソフトウェアを use します.

1. epelパッケージのインストール
$ yum Install Epel-release.noarch

[Epel]の part のenable=1を, enable=0に earpick conversion ふれ合える

$ Vi/etc/yum.repos.d/epel.repo[epel]name=extra Packages for Enterprise Linux 7-$basearch #baseurl=http:// download.fedoraproject.org/pub/epel/7/$basearchmirrorlist =https://mirrors.fedoraproject.org/metalink?repo= Epel-7&arch= $basearchfailovermethod =priorityenabled=0
2. remiのインストール
$ RPM-UVH http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

[Remi]の part のenable=1を, enable=0に earpick conversion ふれ合える

$ Vi/etc/yum.repos.d/remi.repo[remi]name=remi ' s RPM repository for Enterprise Linux 7-$basearch #baseurl=http:// rpms.remirepo.net/enterprise/7/remi/$basearch/mirrorlist=http://rpms.remirepo.net/enterprise/7/remi/ Mirrorenabled=0
Apache2.41.インストール
$ yum Install httpd
2. Starting
$ systemctl Start Httpd.service

※ Auto Start setting

$ systemctl Enable Httpd.service
MySQL5.7

Centos7では, MariaDB (MySQL Exchange のdb) がデフォルトでインストールされている field があるので, mysqlと competition from こさないように cut します.

1. MariaDB, existing MySQL erase
2.インストール

※ Suitable urlは latest occupies slew more すること

$ yum Install http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm$ yum-y Install Mysql-community-server
3.バージョン to confirm
$ mysqld--versionmysqld  Ver 5.7.15 for Linux on x86_64 (MySQL Community Server (GPL))
4. Starting
Systemctl Start Mysqld.service

※ Auto Start setting

Systemctl Enable Mysqld.service
5. Rootユーザーの Initial パスワード

Mysql5.7では, と にrootユーザーにランダム のパスワードが set され, ログに output される.

$ Cat/var/log/mysqld.log | grep ' password is generated ' 201*-**-15t09:53:28.904448z 1 [Note] A temporary password are generated for [email protected]: _abc12#/def:
6. Initial setup

Mysql_secure_installationコマンドで set していきます.
※ New しいルートのパスワードは, large text, small text, numbers, notes, all てが into the っている necessary があるので attention

$ mysql_secure_installationenter password for user root://ログに output されていた initial パスワードを into force set root password? ルートのパスワードを Slew more しますか? yでパスワード set the Remove anonymous users? Who でもログイン may になっているが しますか? Yで しとくdisallow root login remotely? リモートからrootログインを May しませんか? Yでしないremove test database and access to it? テストデータベース していいですか? Yで すreload privilege tables now? Setting をすぐに reflect しますか? Yで reflect all done!
7. mysql Connect Yobitsugi to confirm
$ mysql-u root-penter Password:
8. MY.CNF setting
mysql> SHOW VARIABLES like ' char% '; +--------------------------+----------------------------+| Variable_name            | Value                      |+--------------------------+----------------------------+| character_set_client     | UTF8                       | | character_set_connection | UTF8                       | | character_set_database   | latin1                     | | character_set_filesystem | binary                     | | character_set_ Results |    UTF8 |                       | character_set_server     | latin1                     | | character_set_system     | UTF8                       | | Character_sets_dir       |/usr/share/mysql/charsets/|+--------------------------+----------------------------+8 Rows in Set (0.00 sec)

My.cnfに the following settings します

    • ストレージエンジンを, InnoDB, データファイル?ログファイルをテーブルごとに setting
    • Text コードをutf8に
 Vi/etc/my.cnf[mysqld]default-storage-engine=innodbinnodb_file_per_tablecharacter-set-server = Utf8collation-server = Utf8_general_ci[mysql]default-character-set = UTF8 [client]default-character-set = UTF8 
 mysql> SHOW VARIABLES like ' char% '; +--------------------------+----------------------------+| variable_name | Value |+--------------------------+----------------------------+| character_set_client | UTF8 | | character_set_connection | UTF8 | | Character_set_database | UTF8 | | Character_set_filesystem | binary | | Character_set_results | UTF8 | | Character_set_server | UTF8 | | Character_set_system | UTF8 | | Character_sets_dir | /usr/share/mysql/charsets/|+--------------------------+----------------------------+8 rows in Set (0.02 sec) MySQL > SHOW VARIABLES like ' innodb_file_per_table '; +-----------------------+-------+| variable_name | Value |+-----------------------+-------+| innodb_file_per_table | On |+-----------------------+-------+1 row in Set (0.00 sec) 
PHP71. Libmcrypt

mcryptのインストールに necessary なので First にインストール

$ yum--enablerepo=epel Install Libmcrypt
2.インストール

Fastcgiで かせるphp-fpm, キャッシュ Zhou りのopcache, apcuはインストールしておきます (later)

$ yum--enablerepo=remi-php70 install-y php php-cli php-devel php-common php-mbstring php-mysql php-fpm php-gd php-mcrypt Php-opcache Php-pdo Php-xml
$ php-vphp 7.0.17 (CLI) (Built:mar 15:14:30) (NTS) Copyright (c) 1997-2017 the PHP groupzend Engine v3.0.0, Cop Yright (c) 1998-2017 Zend Technologies with    Zend opcache v7.0.17, Copyright (c) 1999-2017, by Zend Technologies
3. PHP.ini setting

Initial ファイルのバックアップ

$ cp/etc/php.ini/etc/php.ini.bk

Php.iniに the following settings します

$ vi/etc/php.ini[php]#レスポンスヘッダにphpのバージョンを means しないexpose_php = off# full てのログを output error_reporting = E_ALL# ブラウザでエラーを means しないdisplay_errors = off#エラーをログに remnant すlog_errors = on#エラーログの さを Set log_errors_max_len = 4096#エラーログ output First error_log = " /var/log/php_errors.log "# literal エンコーディングdefault_charset =" UTF-8 "[Date]#タイムゾーンdate.timezone =" Asia/tokyo "[mbstring]# デフォルト language mbstring.language = japanese# internal text エンコーディングmbstring.internal_encoding = utf-8# HTTP force Text エンコーディングのデフォルトmbstring.http_input = auto# text エンコーディング eiken out order のデフォルトmbstring.detect_order = auto
4. Action to confirm

ドキュメントルートにphpinfoを output するphpファイルを made into します.
※/var/www/html/... ドキュメントルート

$ vi/var/www/html/info.php<?php    //すべての expression します. デフォルトはinfo_allです.    phpinfo ();

CentOS7 + Apache2.4 + MySQL5.7 + PHP7

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.