背景
Symfonyで開発するため、開発メンバーそれぞれドメイン(Port)を用意しで実行したい
開発メンバー各自、自分でApacheのVirtual Hostを設定して使えるようにする
Samba経由で直接開発サーバー上にソース開発、デバッグができるようにしたい
環境情報
$ cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
# ifconfigが使えない場合
yum provides ifconfig
yum -y install net-tools
PHP7.1をインストール
[CentOS 7 に PHP 7.1 と phpMyAdmin をインストール]
https://qiita.com/sato-hirokazu/items/7795593b14c461bc4e6d
# 古いバージョンのPHPを消す
yum -y remove php-*
# yumリポジトリ設定が完了した後
yum install php php-mbstring php-intl
# PHPバージョンを確認する
php -v
# ※必要に応じて拡張機能をインストール
yum install php-mongodb php-pdo php-xml php-opcache php-curl php-gd php-mcrypt php-bcmath php-devel
Httpd(Apache)
Virtual Host (バーチャルホスト) 設定
# create vhosts config directory
mkdir /etc/httpd/conf.vhost.d
# edit httpd.conf
cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
vi /etc/httpd/conf/httpd.conf
vhostフォルダ配下のファイルを読み込むようにする
/etc/httpd/conf/httpd.conf
# Supplemental configuration
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf
IncludeOptional conf.vhost.d/*.conf
Samba
Sambaインストール
yum install samba
Samba設定
# backup smb.conf -> smb.conf.bak
cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
# edit smb.conf
vi /etc/samba/smb.conf
/home/$user/ ディレクトリを公開する
/etc/samba/smb.conf
[homes]
workgroup = WORKGROUP
comment = Home Directories
valid users = %S
browseable = yes
read only = No
# inherit acls = Yes
directory mask = 0755
create mask = 0755
conf.vhost.conf を公開する
/etc/samba/smb.conf
[vhost]
path = /etc/httpd/conf.vhost.d
workgroup = WORKGROUP
comment = vhost
#valid users = %S
brwoseable = Yes
read only = No
directory mask = 0755
create mask = 0755
/etc/samba/smb.conf
[web]
comment = Http Web publish
path = /var/www/html/web
browseable = Yes
read only = No
writable = Yes
public = Yes
inherit acls = Yes
force create mode = 0775
directory mask = 0775
force group = cms
サービスを起動する
# 自動起動
systemctl enable smb.service
# 起動
systemctl start smb.service
sambaアカウントを追加
useradd qiita
passwd qiita
smbpasswd -a qiita
Composerを登録
wget https://dl.laravel-china.org/composer.phar -O /usr/local/bin/composer
# 実行権限を付与する
chmod 0755 /usr/local/bin/composer
composer -v
firewalld 設定
# 現在のゾーンを確認する
firewall-cmd --list-all-zones
# add service to public zone
firewall-cmd --permanent --zone=public --add-service=samba
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
# portを追加する
firewall-cmd --permanent --add-port=8080/tcp
# firewall設定の再読み込み
firewall-cmd --reload
# zoneの確認
firewall-cmd --list-all-zones
# restart firewall
systemctl restart firewalld.service
# rollback
# firewall-cmd --permanent --zone=public --remove-service=http
# firewall-cmd --permanent --zone=public --remove-service=https
# firewall-cmd --permanent --zone=public --remove-service=samba
# firewall-cmd --permanent --remove-port=8080/tcp
# firewall-cmd --reload
# 以下はSELinux有効にする場合に試す内容
# /var/www/html以外の場所のコンテンツが公開できなかったりする場合
# 試してみること
# setsebool -P httpd_enable_homedirs 1
# chcon -R -t httpd_sys_content_t /home/qiita
# SELinux有効で使う場合
# Symfony ファイル読み書き権限がない
chcon -R -t httpd_sys_rw_content_t project-top/var/
参考[chcon]
http://man.linuxde.net/chcon
https://xiaoguo.net/wiki/centos-7-firewalld.html