CentOS7でWEBサーバーを構築 2020年版
PHPをインストール
7.4のアクティブサポートが2021/11/28なので7.4をインストール
[sourcecode language=plain]
[root@localhost user]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@localhost user]# yum install -y https://rpms.remirepo.net/enterprise/remi-release-7.rpm
[root@localhost user]# yum install -y --enablerepo=remi-php74 php which
完了しました!
[root@localhost iwamoto]# php -v
PHP 7.4.2 (cli) (built: Jan 21 2020 11:35:20) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
[/sourcecode]
PDOでエラーがでたのでインストール
[sourcecode language=plain]
yum install --enablerepo=remi,remi-php74 php-pdo
yum install --enablerepo=remi,remi-php74 php-devel php-mysqlnd php-gd php-xml php-xmlrpc php-mbstring php-mcrypt php-fpm php-opcache
[/sourcecode]
Apacheをインストール
[sourcecode language=plain]
[root@localhost user]# yum -y install httpd
[/sourcecode]
バージョンを確認
[sourcecode language=plain]
[root@localhost user]# httpd -version
Server version: Apache/2.4.6 (CentOS)
Server built: Aug 8 2019 11:41:18
[/sourcecode]
自動起動を設定しておく
[sourcecode language=plain]
[root@localhost user]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[/sourcecode]
起動
[sourcecode language=plain]
[root@localhost user]# systemctl start httpd.service
[/sourcecode]
確認
[sourcecode language=plain]
[root@localhost user]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since 木 2020-02-13 13:54:24 JST; 28s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 2472 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
tq2472 /usr/sbin/httpd -DFOREGROUND
tq2473 /usr/sbin/httpd -DFOREGROUND
tq2474 /usr/sbin/httpd -DFOREGROUND
tq2475 /usr/sbin/httpd -DFOREGROUND
tq2476 /usr/sbin/httpd -DFOREGROUND
mq2477 /usr/sbin/httpd -DFOREGROUND
2月 13 13:54:24 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
2月 13 13:54:24 localhost.localdomain httpd[2472]: AH00558: httpd: Could not reliably determine the server's fully qualified do...essage
2月 13 13:54:24 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[/sourcecode]
ポート開放
[sourcecode language=plain]
[root@localhost user]# firewall-cmd --add-service=http --zone=public --permanent
success
[root@localhost user]# firewall-cmd --add-service=https --zone=public --permanent
success
[root@localhost user]# firewall-cmd --reload
success
[/sourcecode]
MySQL5.7をインストール
MariaDBを削除する
[sourcecode language=plain]
[root@localhost user]# yum remove mariadb-libs
[/sourcecode]
リポジトリの追加
[sourcecode language=plain]
[root@localhost user]# yum localinstall http://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
[/sourcecode]
mysql8を無効にしてmysql5.7を有効にする(現在100%が5系の環境の為)
[sourcecode language=plain]
[root@localhost user]# yum install yum-utils
[root@localhost user]# yum-config-manager --disable mysql80-community
[root@localhost user]# yum-config-manager --enable mysql57-community
[/sourcecode]
インストール
[sourcecode language=plain]
[root@localhost user]# yum -y install mysql-community-server mysql-devel
[/sourcecode]
自動起動設定
[sourcecode language=plain]
[root@localhost user]# systemctl enable mysqld
[/sourcecode]
起動
[sourcecode language=plain]
[root@localhost user]# systemctl start mysqld
[/sourcecode]
デフォルトだとログインができません。
[sourcecode language=plain]
[root@localhost user]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[/sourcecode]
ログファイルからパスワードを探します。
[sourcecode language=plain]
[root@localhost user]# cat /var/log/mysqld.log
2020-02-13T05:16:32.855962Z 1 [Note] A temporary password is generated for root@localhost: ここにパスワードがのってます。
[/sourcecode]
Sambaをインストール
yumでインストール
[sourcecode language=plain]
[root@localhost user]# yum install samba samba-client samba-common -y
[/sourcecode]
自動起動設定をする
[sourcecode language=plain]
[root@localhost samba]# systemctl enable smb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.
[root@localhost samba]# systemctl enable nmb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/nmb.service to /usr/lib/systemd/system/nmb.service.
[/sourcecode]
起動
[sourcecode language=plain]
[root@localhost samba]# systemctl restart smb.service
[root@localhost samba]# systemctl restart nmb.service
[/sourcecode]
ファイアウォールをあけておく
[sourcecode language=plain]
[root@localhost samba]# firewall-cmd --permanent --zone=public --add-service=samba
success
[root@localhost samba]# firewall-cmd --reload
success
[/sourcecode]
だがつながりません。。。。。
とりあえずSELinuxを無効化
[sourcecode language=plain]
[user@localhost samba]$ vi /etc/selinux/config
SELINUX=disabledに変更
[/sourcecode]
Linuxに登録済のユーザーをSambaサーバーアクセス用ユーザーとして新規登録
[sourcecode language=plain]
[root@localhost user]# pdbedit -a user
[/sourcecode]
つながりました!!!!