環境:
CentOS Linux release 7.5.1804
先來升級系統,讓系統可以維持在新版
- yum -y update
————————–開始安裝LAMP————————————-
- L:Linux
- A:Apache
- M:MySQL or MariaDB
- P: PHP
- 先安裝相關套件
- rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
- yum -y install httpd php-mysql mysql-server php70w php70w-mysql
安裝 LAMP (Linux + Apache + MySQL / MariaDB + PHP / Python / Perl)
- 開啟防火牆,讓 web (port:80, 443) 流量可以穿過 firewall
- firewall-cmd –permanent –zone=public –add-service=http
- firewall-cmd –permanent –zone=public –add-service=https firewall-cmd –reload
- 開啟防火牆,讓外部可以連接 MySQL (port:3306) 流量可以穿過 firewall
- 查看目前支援的 service
- firewall-cmd –get-services
- 開啟 Mysql 3306
- sudo firewall-cmd –permanent –zone=public –add-service=mysql
- 若要限定哪個IP才能連
- sudo firewall-cmd –permanent –add-rich-rule ‘rule family=”ipv4″ source address=”$your_IP_or_class” service name=”mysql” accept’
- 啟動 httpd 與 mysql
- sudo systemctl start httpd
- sudo systemctl enable httpd
- sudo systemctl start mysqld
- sudo systemctl enable mysqld
—————————————————————————————
如果在 CentoOS7 安裝 MySQL 時,卻發現找不到 MySQL 套件時,可改使用底下方式安裝 MySQL
sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
最新版可以參考此網址 https://dev.mysql.com/downloads/repo/yum/
yum install mysql-community-server
/usr/bin/systemctl enable mysqld
systemctl start mysqld
/usr/bin/mysql_secure_installation
—————————————————————————————
- MySQL 初始化設定
- mysql_secure_installation
- 修改 httpd 與 php 設定
- vi /etc/httpd/conf/httpd.conf
- vi /etc/php.ini
- 重新啟動 httpd 以載入新設定
- systemctl restart httpd