here: here: here:
Centos7.4-PHP7.1-LEMP Stack (CentOS7.4 (ใหม่ล่าสุด) + nginx + MariaDB + php7.1 (ใหม่ล่าสุด)
ก่อนอื่นติดตั้ง CentOS แบบเบสิกให้เรียบร้อยก่อน ตัวเสรมอื่นๆ ยังไม่ต้องเลือก แล้วค่อยเริ่ม..คัดลอกวางได้เลย
yum -y install nano wget net-tools
============================
nano /etc/yum.repos.d/nginx.repo
============================
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
============================
yum -y install nginx
=============================
yum -y install firewalld
systemctl start firewalld.service
systemctl enable firewalld.service
===Configure firewalld to Allow Nginx Traffic====
firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --zone=public --permanent --add-service=https
firewall-cmd --reload
==============================
Installing PHP 7.1 on CentOS 7 with Nginx
==============================
yum -y install mariadb mariadb-server
systemctl enable mariadb.service
systemctl start mariadb.service
mysql_secure_installation
=====================================
yum -y install epel-release
rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
### Install PHP 7.1 ##############
yum --enablerepo=remi-safe -y install php71
=====================
check:
=====================
php71 -v
###### Some aditonal packages ###############
$ yum install php71-php-mcrypt php71-php-mcrypt php71-php-json php71-php-mbstring php71-php-xml php71-php-soap php71-php-xmlrpc php71-php-simplexml php71-php-curl php71-php-mysqlnd
#### Install PHP-FPM ##################
yum --enablerepo=remi-safe -y install php71-php-fpm
=================================
Start & Set for boot
=================================
systemctl start php71-php-fpm
systemctl status php71-php-fpm.service
systemctl enable php71-php-fpm
================PHP / PHP FPM Config?===============
nano /etc/opt/remi/php71/php-fpm.d/www.conf
[===]
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx
[====]
=================
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
==============
[===]
; Default Value: clean env
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
===========================================
# edit Default www
nano /etc/nginx/conf.d/default.conf
===========================================
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
#charset koi8-r;
# access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
try_files $uri =404;
# fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
========================
nano /usr/share/nginx/html/info.php
<?php
phpinfo();
?>
========================
service nginx restart
service php71-php-fpm restart
=========================
======install phpmyadmin =================
yum -y install phpmyadmin
nano /etc/phpMyAdmin/config.inc.php
$cfg['Servers'][$i]['auth_type'] = 'http'; # เดิม cookie
ln -s /usr/share/phpMyAdmin/ /usr/share/nginx/html/
chown -R nginx:nginx /var/opt/remi/php71/lib/php/session
========================================
กำหนดสิทธิ์ seklinux ไม่เช่นนั้นจะอัพโหลดไฟล์เข้าระบบไม่ได้ ต่อให้กำหนดสิทธิ์ โฟลเดอร์ใดๆ เป็น 777 แล้วก็ตาม
selinux permission
PHP Warning: move_uploaded_file(): Unable to move
============================================
disable
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are pr$
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
##แก้ SELINUX=enforcing เป็น SELINUX=disable
หรือเปิดเป็นไฟล์ๆ ไป
chcon -R -t httpd_sys_rw_content_t /usr/share/nginx/html/smss411/modules/person/upload/
==================the end==================