CENTOS7阿里雲LAMP環境搭建
阿新 • • 發佈:2019-01-09
FTP
yum -y install vsftpd #安裝vsftpd服務
systemctl enable vsftpd.service #設定vsftpd服務自啟動
vsftpd -v #檢視vsftpd服務版本
#然後用root賬戶登入ftp,下載/etc/vsftpd/vsftpd.conf,修改以下部分
anonymous_enable=NO #設定不允許匿名訪問
local_enable=YES #設定本地使用者可以訪問
chroot_list_enable=YES #使使用者不能離開主目錄
chroot_list_file=/etc/vsftpd/chroot_list
修改主機名
hostnamectl set-hostname 新主機名
防火牆
CENTOS7預設是firewalld,改為iptables
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
yum install iptables #安裝iptables
yum install iptables-services #安裝iptables-services
#修改/etc/sysconfig/iptables,配置防火牆
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT #SSH
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT #FTP
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT #HTTP
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT #MySQL
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT #HTTPS
LAMP
安裝Apache,PHP,MySQL,PHP連線MySQL庫元件
yum -y install httpd php ysql mysql-server php-mysql
建立一個新使用者
useradd username #建立一個自己的使用者
passwd username #設定username這個使用者的密碼
username ALL=(ALL) ALL #在root ALL=(ALL) ALL下面加入,表示把username加入sudoers組
mkdir conf #在家目錄建立conf資料夾
ln -s /etc/httpd httpd #新建Apache軟連線
mariadb配置
linux改了。。。預設是mariadb了,那就這樣吧,配置還是照改
port=3306 #埠號
thread_concurrency = 2 #併發執行緒數,建議CPU核數乘2,因為是單核CPU,所以雙執行緒
init_connect='SET collation_connection = utf8_general_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8 #預設編碼
collation-server=utf8_general_ci #預設排序方式
skip-character-set-client-handshake
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
此外,還要用mysql -u root -p進入mariadb執行
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’IDENTIFIED BY ‘123456’ WITH GRANT OPTION;(123456為登入密碼)
flush privileges;
使mariadb可以被遠端訪問,這樣就可以用navicat來訪問了
啟動與自啟動
systemctl start iptables.service
systemctl start httpd.service
systemctl start vsftpd.service
systemctl start mariadb.service
systemctl enable iptables.service
systemctl enable httpd.service
systemctl enable vsftpd.service
systemctl enable mariadb.service