Linux/selinuxインストール
提供: 初心者エンジニアの簡易メモ
目次
selinuxインストール
dnf reinstall -y \ selinux-policy \ selinux-policy-targeted \ policycoreutils \ policycoreutils-python-utils \ libselinux \ libselinux-utils \ libselinux-python3
キャッシュ再生成
fixfiles onboot
書き込みエラーが発生するとき
例:phpのSmartyでのエラーが出る
エラー詳細
Uncaught SmartyException: unable to write file
対策は、上記項目のように、selinuxをインストール
設定
書込dirのselinuxの設定(一時的)
chcon -R -t httpd_sys_rw_content_t \ /var/www/zend/project1-test/application/modules/default/views/templates_c chcon -R -t httpd_sys_rw_content_t \ /var/www/zend/project1-test/application/modules/admin/views/templates_c
書込dirのselinuxの設定(永続)
semanage fcontext -a -t httpd_sys_rw_content_t \ "/var/www/zend/project1-test/application/modules/default/views/templates_c(/.*)?" semanage fcontext -a -t httpd_sys_rw_content_t \ "/var/www/zend/project1-test/application/modules/admin/views/templates_c(/.*)?"
反映
restorecon -Rv /var/www/zend/project1-test/application/modules/default/views/templates_c restorecon -Rv /var/www/zend/project1-test/application/modules/admin/views/templates_c
書込dirのselinuxの設定確認
semanage fcontext -l | grep templates_c
書込dirのselinuxの削除設定(永続)
semanage fcontext -d "/var/www/zend/project1-test/application/modules/default/views/templates_c(/.*)?"
selinuxを切る(自動起動オフ
vi /etc/selinux/config
-SELINUX=enforcing +SELINUX=disabled
でリブート
本番では行わないこと、セキュリティが一段さがる。
html公開位置が、本来の位置じゃないときは=
例:/var/www/html/public
restorecon -Rv /var/www/html/public
本来の位置を設定して、更新する。
