CentOS7之搭建lamp环境

来源:互联网 发布:伦敦爱乐乐团知乎 编辑:程序博客网 时间:2024/05/16 14:07

现在大多数线上网站都是在Linux服务器上运行的,做为开发人员Linux的搭建还是要略懂的

现在我先来介绍一下Linux上lamp环境的安装


1、首先要关闭firewall,就是防火墙(CentOS 7.0默认使用的是firewall作为防火墙)

    systemctl stop firewalld.service       #停止firewall      systemctl disable firewalld.service    #禁止firewall的开机自启动  

2、关闭SELINUX(Linux的一个安全机制)

    vi /etc/selinux/config    #打开配置文件    #SELINUX=enforcing        #像这样注释掉这一行    SELINUX=disabled          #在文件中增加一行      :wq!                      #完事后保存退出      setenforce 0              #使配置立即生效  

3、安装Apache

    yum install httpd                   #然后根据提示,输入Y安装即可成功安装      systemctl start httpd.service       #启动Apache    systemctl stop httpd.service        #停止Apache    systemctl restart httpd.service     #重启Apache    systemctl enable httpd.service      #设置apache开机启动  

4、安装MariaDB(就是Mysql)

    yum install mariadb mariadb-server    #询问是否要安装,输入Y即可自动安装,直到安装完成      systemctl start mariadb.service       #启动MariaDB      systemctl stop mariadb.service        #停止MariaDB      systemctl restart mariadb.service     #重启MariaDB      systemctl enable mariadb.service      #设置开机启动      set password for 'root'@'localhost'=password('root');     #修改mysql密码    grant all on *.* to root identified by 'root';           #mysql授权远程连接(navicat等



5、安装PHP以及组件,同时使PHP支持 MariaDB

    yum install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash      #这里选择以上安装包进行安装,根据提示输入Y回车      systemctl restart mariadb.service      #重启MariaDB      systemctl restart httpd.service        #重启Apache

大功告成实战一下

    cd /var/www/html    #进入根目录    vi index.php        #输入下面内容    <?php        phpinfo();    ?>    :wq!                 #保存退出
现在去客户端浏览器输入服务器IP地址,可以看到如下图所示相关的配置信息!(只截了开头部分自己去找就行了,如果找不到那就 again  )





2 0