ติดตังÊ lamp บน centos 7 - csriu14.com · ติดตังÊ lamp บน centos...

4
PowerBy : phraehospital contact : [email protected] หน้า ติดตัÊง Lamp บน CentOS 7 1. ติดตัÊง EPEL-7 repo [root@serverx]# rpm -ivh ftp://ftp.icm.edu.pl/vol/rzm2/linux- fedora/linux/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm 2. ติดตัÊง mariadb [root@serverx]# yum -y install mariadb-server mariadb ติดตัÊงเรียบร้อยให้ สัÉง start และ ให้ service ทํางานทุกครัÊง ตอน boot [root@serverx]# systemctl start mariadb.service [root@serverx]# systemctl enable mariadb.service 3. กําหนดรหัสผ่าน root ของ mariadb ดังนี Ê [root@serverx]# mysql_secure_installation /usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): <-- กด ENTER ผ่านไปก่อน OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] New password: <-- กําหนดรหัสผ่าน mariadb Re-enter new password: <--กําหนดรหัสผ่าน mariadb อีกครัÊง ให้เหมือนเดิม Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB 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 <-- กด ENTER เพืÉอ ลบ user anonymous ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.

Upload: trantuong

Post on 31-Oct-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

PowerBy : phraehospital contact : [email protected] หนา้

ตดิตงั Lamp บน CentOS 7 1. ติดตงั EPEL-7 repo [root@serverx]# rpm -ivh ftp://ftp.icm.edu.pl/vol/rzm2/linux-fedora/linux/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm 2. ติดตงั mariadb [root@serverx]# yum -y install mariadb-server mariadb ติดตงัเรียบร้อยให้ สงั start และ ให้ service ทํางานทกุครัง ตอน boot [root@serverx]# systemctl start mariadb.service [root@serverx]# systemctl enable mariadb.service 3. กําหนดรหสัผ่าน root ของ mariadb ดงันี [root@serverx]# mysql_secure_installation /usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): <-- กด ENTER ผ่านไปก่อน

OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] New password: <-- กําหนดรหัสผ่าน mariadb Re-enter new password: <--กําหนดรหสัผ่าน mariadb อีกครัง ให้เหมือนเดิม

Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB 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 <-- กด ENTER เพือ ลบ user anonymous ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.

PowerBy : phraehospital contact : [email protected] หนา้

Disallow root login remotely? [Y/n] ตอบ Y <-- กด ENTER เพือ ให้user root เข้าใช้งาน

database ได้เฉพาะ local เท่านนั

... Success! By default, MariaDB 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 <-- กด ENTER ถ้าต้องการลบ database test - 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 <-- กด ENTER ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB! 4. ติดตงั apache 2.4

[root@serverx]# yum -y install httpd ติดตงัเรียบร้อยให้ สงั start และ ให้ service ทํางานทกุครัง ตอน boot [root@serverx]# systemctl start httpd.service [root@serverx]# systemctl enable httpd.service จากนนั เปิด port ใน iptables

[root@serverx]# pico /etc/sysconfig/iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

PowerBy : phraehospital contact : [email protected] หนา้

จากนนั ทดลองเรียกเว็บ เพือทดสอบการใช้งานด ูเช่น http://192.168.137.2 จะได้ดงัรูป

5. ติดตงั php ดงันี

[root@serverx]# yum -y install php เสร็จแล้ว แก้ไขไฟล์ php.ini เพือให้ใช้งาน short tag ได้ ( <? ?>)

[root@serverx]# pico +211 /etc/php.ini แก้ไข short_open_tag = Off -> short_open_tag = On

จากนนั ให้ save แล้ว restart httpd [root@serverx]# systemctl restart httpd.service

ไปสร้างไฟล์ เพือ ทดสอบ phpinfo() ใน /var/www/html จะได้ php 5.4.16 ดงัรูป

PowerBy : phraehospital contact : [email protected] หนา้

6. ติดตงั MySQL Support PHP5 [root@serverx]# yum search php [root@serverx]# yum -y install php-mysql [root@serverx]# yum -y install php-gd php-ldap php-odbc php-pear php-xml

php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel (พิมพ์ต่อกนัหมด) จากนนั ให้ save แล้ว restart httpd อีกครัง

[root@serverx]# systemctl restart httpd.service phpinfo อีกครังจะทดสอบ

เห็นว่า php support mysql แล้ว ดงัรูป