ໃນປະຈຸບັນລະບົບເວັບເຊີບເວີທີ່ນິຍົມທີ່ສຸດໃນບ້ານເຮົາກໍໜ້າຈະເປັນ Apache ຍ້ອນຕິດຕັ້ງງ່າຍເກືອບຈະບໍ່ໄດ້ປັບແຕ່ງຫຍັງເພີ່ມເລີຍກໍສາມາດນໍາໃຊ້ໄດ້ແລ້ວ ທີ່ສໍາຄັນມີ community ທີ່ກວ້າງຂວາງຫຼາຍ ແຕ່ຈຸດອ່ອນຂອງ Apache ນັ້ນທີ່ເຮົາພົບເຫັນກໍຄືການກິນແຣມເປັນຈໍານວນຫຼາຍ ຖ້າໂຫຼດ static file ໃຫຍ່ໆບໍ່ຕ້ອງເວົ້າເຖິງ ອາດຈະເຖິງຂັ້ນ service ດັບເລີຍກໍໄດ້ ຈຶ່ງໄດ້ມີຄົນຄິດຄົ້ນເລື່ອງຂອງການສ້າງ Reverse Proxy ໂດຍໃຫ້ NGINX ( ເປັນເວັບເຊີບເວີນ້ອງໃໝ່ໄຟແຮງໃນບ້ານເຮົາ ແຕ່ທາງອາເມລິກາຮິດກັນມາຫຼາຍປີແລ້ວ ) ເປັນໜ້າດ່ານຄອຍໂຫຼດພວກ Static file ແທນສ່ວນ Dynamic File ພວກໄຟລ php ຈະສົ່ງໄປໃຫ້ Fast CGI ໂຫຼດແທນເຮັດໃຫ້ປະຢັດ memory ໄປໄດ້ຫຼາຍເຕີບ ແລະ Fast CGI ຖືກຄວບຄຸມດ້ວຍ php-fpm ເຊິ່ງຈະແນະນໍາວິທີຕິດຕັ້ງດັ່ງຕໍ່ໄປນີ້
ຂັ້ນຕອນການຕິດຕັ້ງ
1 > ກະກຽມ packages ໃຫ້ພ້ອມ
rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
2 > ຕິດຕັ້ງ MySQL
yum -y install mysql mysql-server
ເປີດ service mysql
service mysqld restart
ປັບແຕ່ງຄ່າເລີ່ມຕົ້ນໃຫ້ mysql
mysql_secure_installation
By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y … Success! Normally, root should only be allowed to connect from ‘localhost’. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y … Success! By default, MySQL comes with a database named ‘test’ that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y – Dropping test database… … Success! – Removing privileges on test database… … Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y … Success! Cleaning up… All done! If you’ve completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL!
restart service
service mysqld restart
3 > ຕິດຕັ້ງ NGINX + Apache
yum install -y nginx httpd
4 > ຕິດຕັ້ງ PHP
yum install php-pear-Net-Socket php-pear php-common php-gd php-devel php php-mbstring php-pear-Mail php-cli php-pear-Auth-SASL php-ldap php-pear-Net-SMTP php-imap php-snmp php-pdo php-xml php-mysql php-fpm -y
ແກ້ໄຂໄຟລ /etc/php.ini ແລະ ປ່ຽນຄ່າ cgi.fix_pathinfo=1 ໃຫ້ເປັນ cgi.fix_pathinfo=0
ແກ້ໄຂໄຟລ /etc/nginx/conf.d/default.conf
#
# The default server
#
server {
listen 80;
server_name example.com;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:8080;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
ແກ້ໄຂໄຟລ /etc/nginx/conf.d/virtual.conf
server {
listen 80;
root /home/putter;
index index.php index.html index.htm;
server_name www.ruk-com.in.th ruk-com.in.th;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
location ~ /\.ht {
deny all;
}
}
ແກ້ໄຂ Virtual Host ຂອງ Apache
ServerAdmin [email protected] DocumentRoot /home/putter ServerName www.ruk-com.in.th ErrorLog logs/exruk-com-error_log CustomLog logs/ruk-com-access_log common AllowOverride All
ແກ້ໄຂ /etc/httpd/conf/httpd.conf ໃຫ້ Apache ເປີດພອດ 8080 ແທນ
Listen 127.0.0.1:8080
ແກ້ໄຂ php-fpm ທີ່ /etc/php-fpm.d/www.conf ໂດຍແກ້ໄຂ user = apache ແລະ group = apache ໃຫ້ເປັນ nginx
; RPM: apache Choosed to be able to access some dir as httpd user = nginx ; RPM: Keep a group allowed to write in log dir. group = nginx
service httpd restart service nginx start service php-fpm restart service mysqld restart chkconfig httpd on chkconfig nginx on chkconfig php-fpm on chkconfig mysqld on







