LAMP怜跑,顧名思義:
L : Linux
A : Apache
M : Mariadb(原MySQL)
P : PHP
建網(wǎng)站珍昨,首要問題就是安全,所以iptables一定要配置好换团,或者firewalld把还,一定要控制好端口的開與關(guān)协屡,以及端口的轉(zhuǎn)發(fā)。配置不好的話全谤,自己的網(wǎng)站可能會(huì)被攻破肤晓,做一些壞事,給自己帶來不必要的麻煩H先弧2购丁!卷员!
配置環(huán)境
LAMP | 版本 |
---|---|
Linux | Centos 7 |
Apache | 2.4.6 |
MariaDB | 5.5.56 |
PHP | 5.4.16 |
001 開啟網(wǎng)絡(luò)端口
iptables -A INPUT -p tcp -m state --state NEW,RELATED,ESTABLISHED -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW,RELATED,ESTABLISHED -m tcp --dport 3306 -j ACCEPT
80端口:網(wǎng)絡(luò)訪問
3306端口:數(shù)據(jù)庫訪問
service iptables save "保存iptables安全組設(shè)置"
systemctl restart iptables "重啟iptables服務(wù)“
PS:關(guān)閉SElinux
vi /etc/selinux/config
將SElinux改成disabled
并注釋掉SELINUXTYPE=trageted
修改完之后重啟S摇!毕骡!
重啟O鞫!未巫! reboot !!!
010 下載 AMP服務(wù)
1.下載Apache服務(wù)
yum -y install httpd
2.下載MariaDB數(shù)據(jù)庫服務(wù)
yum -y install mariadb mariadb-server
3.下載php服務(wù)
yum -y install php "下載php服務(wù)"
yum -y install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt "下載php服務(wù)插件"
4.啟動(dòng)服務(wù)并開機(jī)自啟
systemctl restart httpd
systemctl restart mariadb
systemctl enable httpd
systemctl enable mariadb
011 配置AMP服務(wù)
1.配置Apache服務(wù)
vi /etc/httpd/conf/httpd.conf
修改端口為80
如下圖修改配置窿撬, 修改網(wǎng)頁工作目錄(自己決定,可以不修改叙凡,也可以自定義)
2.配置MariaDB服務(wù)
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf “復(fù)制配置文件劈伴,覆蓋/etc/my.cnf文件”
使用mysql_secure_installation配置MariaDB服務(wù)
mysql_secure_installation
輸入root用戶密碼
更改root用戶密碼
是否刪除匿名用戶,是否不允許root用戶遠(yuǎn)程登錄握爷,是否刪除test數(shù)據(jù)庫跛璧,是否對(duì)表重新加載權(quán)限(y:允許,n:不允許)
3.配置php服務(wù)
vi /etc/php.ini
修改下面的參數(shù)
4.重啟服務(wù)
systemctl restart httpd
systemctl restart mariadb
100 測(cè)試
vi /home/www/html/index.php "根據(jù)自己的目錄創(chuàng)建index.php 文件"
輸入以下代碼并保存
<?php
phpinfo();
?>