LAMP,顾名思义:
L : Linux
A : Apache
M : Mariadb(原MySQL)
P : PHP
建网站,首要问题就是安全,所以iptables一定要配置好,或者firewalld,一定要控制好端口的开与关,以及端口的转发。配置不好的话,自己的网站可能会被攻破,做一些坏事,给自己带来不必要的麻烦!!!!
配置环境
LAMP | 版本 |
---|---|
Linux | Centos 7 |
Apache | 2.4.6 |
MariaDB | 5.5.56 |
PHP | 5.4.16 |
001 开启网络端口
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端口:网络访问
3306端口:数据库访问
service iptables save "保存iptables安全组设置"
systemctl restart iptables "重启iptables服务“
PS:关闭SElinux
vi /etc/selinux/config
将SElinux改成disabled
并注释掉SELINUXTYPE=trageted
修改完之后重启!!!

重启!!! reboot !!!
010 下载 AMP服务
1.下载Apache服务
yum -y install httpd
2.下载MariaDB数据库服务
yum -y install mariadb mariadb-server
3.下载php服务
yum -y install php "下载php服务"
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服务插件"
4.启动服务并开机自启
systemctl restart httpd
systemctl restart mariadb
systemctl enable httpd
systemctl enable mariadb
011 配置AMP服务
1.配置Apache服务
vi /etc/httpd/conf/httpd.conf
修改端口为80

如下图修改配置, 修改网页工作目录(自己决定,可以不修改,也可以自定义)


2.配置MariaDB服务
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf “复制配置文件,覆盖/etc/my.cnf文件”
使用mysql_secure_installation配置MariaDB服务
mysql_secure_installation
输入root用户密码


更改root用户密码


是否删除匿名用户,是否不允许root用户远程登录,是否删除test数据库,是否对表重新加载权限(y:允许,n:不允许)

3.配置php服务
vi /etc/php.ini
修改下面的参数

4.重启服务
systemctl restart httpd
systemctl restart mariadb
100 测试
vi /home/www/html/index.php "根据自己的目录创建index.php 文件"
输入以下代码并保存
<?php
phpinfo();
?>

网友评论