准备php
1. 关闭SELinuxmysql
临时:切换到root用户,并执行命令:linux
setenforce 0 # 0表示关闭,1表示开启
永久:经过修改配置文件
sql
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增长
:wq!#保存退出
shutdown -r now#重启系统shell
2. Apache安装c#
yum install httpd # 可添加参数-y,表示赞成安装
经过命令来启动/关闭/重启等服务:工具
service httpd start|stop|restart 或 systemctl start httpd #Centos7特有
经过以下命令查看版本:post
httpd -v
经过以下命令设为开机启动:rest
systemctl enable httpd.service #设置开机启动 systemctl is-enabled httpd.service #查看是否开机启动 systemctl disable httpd.service #取消开机启动
操做后,需重启服务code
3. Mysql安装
因为Centos7默认支持Mariadb(Mysql分支,其余操做或配置相同),因此安装命令参考:
yum install mariadb* # 安装Mariadb服务及其相关
经过以下命令开机启动:
#参考Apache systemctl enable mariadb.service #设置开机启动
启动/中止/重启服务:
service mariadb start|stop|restart 或 systemctl start mariadb #Centos7特有
设置root用户密码:Mysql版本5.5.47
mysql_secure_installation
根据提示操做便可。其余版本,请另行参考。
最后重启服务。
3. PHP安装
经过yum命令直接安装
yum install php #直接添加-y参数,或根据提示输入Y直到安装完成
安装php扩展
yum 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 #这里选择以上安装包进行安装,根据提示输入Y回车
安装结束后,重启Apache和Mariadb服务。
systemctl restart httpd systemctl restart mariadb
补充:
CentOS使用systemd服务管理程序来管理服务一、systemd的服务管理程序介绍:systemctl是主要的工具,它融合以前service和chkconfig的功能于一体。能够使用它永久性或只在当前会话中启用/禁用服务。systemctl能够列出正在运行的服务状态:systemd-cgls以树形列出正在运行的进程,它能够递归显示控制组内容。二、启动/关闭、启用/禁用服务启动一个服务:systemctl start postfix.service关闭一个服务:systemctl stop postfix.service重启一个服务:systemctl restart postfix.service显示一个服务的状态:systemctl status postfix.service在开机时启用一个服务:systemctl enable postfix.service在开机时禁用一个服务:systemctl disable postfix.service查看服务是否开机启动:systemctl is-enabled postfix.service;echo $?查看已启动的服务列表:systemctl list-unit-files|grep enabled