一、安全組設置訪問 若是是第三方提供的服務器,好比阿里,騰訊,必須在控制檯設定好安全組開通端口,不然報10038錯誤。此處有坑!此處有坑!此處有坑!
二、登陸服務器,本身使用putty
三、要麼重置系統 要麼刪除LAMP的環境;爲的是清除乾淨,以防一些神奇bug 出現;本人是學習用直接重置php
四、查看防火牆 打開端口mysql
Centos7默認安裝了firewalld,若是沒有安裝的話,則須要YUM命令安裝
安裝Firewall命令:
yum install firewalld firewalld-configlinux
4.1 查看狀態 running 則說明正常啓用,不然須要開啓
systemctl status firewalld或者firewall-cmd --statesql
4.2 開啓防火牆命令:
systemctl start firewalld.service數據庫
4.3 開啓端口:
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=3306/tcp --permanent
4.3.1 設置開機啓動 能夠不設置,推薦設置
systemctl enable firewalldapache
4.4 重啓防火牆命令:
firewall-cmd --reload 或者 service firewalld restart
4.5 查看狀態
systemctl status firewalld或者firewall-cmd --statevim
4.5 查看端口列表:
firewall-cmd --permanent --list-port緩存
-------補充命令:---------
禁用防火牆
systemctl stop firewalld安全
中止並禁用開機啓動
sytemctl disable firewalld服務器
五、設置swap 虛擬內存
5.1 檢查 Swap 空間 若是返回的信息概要是空的,則表示 Swap 文件不存在。
swapon -s
5.2 檢查文件系統 檢查返回的信息,還剩餘足夠的硬盤空間便可。
df -hal
5.3 建立並容許 Swap 文件
dd if=/dev/zero of=/tmp/swapfile bs=2048 count=2048k
這樣就創建一個/tmp/swapfile的分區文件,大小爲2G。 看我的取捨
5.4 格式化並激活 Swap 文件
mkswap /tmp/swapfile
激活 Swap ,運行命令:
swapon /tmp/swapfile
swapon -s
你會發現返回的信息概要:
Filename Type Size Used Priority
/tmp/swapfile file 524284 0 -1
5.5 重啓自動掛載 Swap ,需修改 fstab 配置。
vim /etc/fstab
用 vim 打開 /etc/fstab 文件,在其最後添加以下一行:
/tmp/swapfile swap swap defaults 0 0
5.6 賦予 Swap 文件適當的權限:
chown root:root /tmp/swapfile
chmod 600 /tmp/swapfile
5.7 同時,咱們還能夠修改 Linux Swap 空間的 swappiness ,下降對硬盤的緩存。
Linux 會使用硬盤的一部分作爲 Swap 分區,用來進行進程調度–進程是正在運行的程序–把當前不用的進程調成‘等待(standby)’,甚至‘睡眠(sleep)’,一旦要用,再調成‘活動(active)’,睡眠的進程就會在 Swap 分區,把內存空出來讓給‘活動’的進程。
若是內存夠大,應當告訴 Linux 沒必要太多的使用 Swap 分區,能夠經過修改 swappiness 的參數來設置。swappiness=0 的時候表示最大限度使用物理內存,而後纔是 Swap 空間,swappiness=100 的時候表示積極的使用 Swap 分區,而且把內存上的數據及時的搬運到 Swap 空間裏面。
在 CentOS 中,swappiness 的默認值是60。
經過如下命令能夠看到:
cat /proc/sys/vm/swappiness
返回值60
咱們能夠調整 swappiness 的值到一個合適的參數,從而達到最優化使用 Swap 的目的。這裏咱們將其設爲10。這樣你就將值由60改成10,這能夠大大下降系統對於swap的寫入,建議內存爲512M或更多的朋友採用此方法。如你你發現你對於swap的使用極少,能夠將值設爲0。這並不會禁止你對swap的使用,而是使你的系統對於swap的寫入儘量的少,同時儘量多的使用你的實際內存。這對於你在切換應用程序時有着巨大的做用,由於這樣的話它們是在物理內存而非swap分區中。
使用 sysctl 命令:
sysctl vm.swappiness=10
可是這只是臨時性的修改,在你重啓系統後會恢復默認的60,要永久設置,還須要在 vim 中修改sysctl.conf:
vi /etc/sysctl.conf
在這個文檔的最後加上這樣一行:
# Search for the vm.swappiness setting. Uncomment and change it as necessary.
vm.swappiness=10
輸入:wq,保存退出 vim 。
這樣一來,Swap 分區重啓後都會生效了。
5.8 重啓一下服務器,不然xampp安裝的時候可能被Killed
六、安裝Xampp for Linux
6.1 進入:cd /opt
執行下面3步:
6.2 wget https://downloadsapachefriends.global.ssl.fastly.net/7.3.1/xampp-linux-x64-7.3.1-0-installer.run
6.3 chmod 755 xampp-linux-x64-7.3.1-0-installer.run
6.4 ./xampp-linux-x64-7.3.1-0-installer.run
(此處若是安裝被killed,查看是否上面的緩存沒設置,或者沒重啓。若是都作了,還被Killed,那就說明一次不夠,來多幾回,我就是這樣搞好的)
6.5 重啓xampp:
/opt/lampp/lampp restart
6.6 設置MYsql帳號信息
進入:cd /opt/lampp/bin
輸入:./mysql
輸入:GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '@Root11' WITH GRANT OPTION;
退出:exit
6.7 配置遠程鏈接---這裏不設置是會報錯的,請看最下方
進入: cd /opt/lampp/etc/extra
打開: vi httpd-xampp.conf
修改:
將Require Local 修改替換爲 Require all granted
這裏我看不到 LocationMatch 只有 <Directory "/opt/lampp/phpmyadmin">
直接在這裏改便可。這裏有坑!這裏有坑!這裏有坑!
重啓: /opt/lampp/lampp restart
基本上配置好上面的步驟就能夠正常使用xampp的數據庫了。
重啓xampp:
/opt/lampp/lampp restart
啓動xampp:
/opt/lampp/lampp start
中止xampp:
/opt/lampp/lampp stop
卸載xampp:
rm -rf /opt/lampp
中止xampp:
/opt/lampp/lampp stop
apache啓動
/opt/lampp/lampp startapache
/opt/lampp/lampp stopapache
-----------------錯誤信息-------------
Access forbidden!
New XAMPP security concept:
Access to the requested object is only available from the local network.
This setting can be configured in the file "httpd-xampp.conf".