1、Apache
安装命令:systemctl instll httpd
启动apache:systemctl start httpd.service
将apache设置为开机自启动:systemctl enable httpd.service
如果担心apache没有成功启动,可以使用命令:systemctl is-enabled httpd.service查看
如果显示enabled,则表示apache正在运行,HTTP服务器已经启动成功,下面来进行一些简单的配置:
使用VIM打开 /ect/httpd/conf/httpd.conf文件:
将AllowOverride none修改为All,表示允许.htacess文件(即打开apache服务器的重写功能)。
由于需求,先修改这一出即可,以后遇到别的需求时再来更改配置文件。
保存退出
重启apache:systemctl restart httpd.service
2、MariaDB
CentOS7中已经开始用MariaDB来取代MySQL,但其实二者并没有什么区别,所以安装MariaDB和MySQL都可以,本处安装MariaDB
安装命令:systemctl install mariadb mariadb-service
启动maria:systemctl start mariadb.service
设置开机自启动:systemctl enable mariadb.service
配置:将/usr/share/mysql/my-huge.cnf 复制到 /etc/my.cnf,以后mysql有什么需求修改配置文件/etc/my.cnf即可
3、安装php
安装命令:yum install php(默认下载的5.4版本)
安装一些有用php扩展(可以根据自己的需要去安装):
yum install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
配置文件:vim /etc/php.ini
找到date.timezone,去掉前面的“;”,将值设置为PRC(北京时间)
保存退出
重启apache:systemctl restart httpd.service
4、设置防火墙
centos 7中防火墙已经由iptables改为了firewall,使用firewall-cmd命令开放http服务
firewall-cmd --add-service=http --permanent #开放80端口,即http服务,--permanent表示永久开发
firewall-cmd --add-service=https --parmanent #开放443端口,即https服务
firewall-cmd --reload #重新加载防火墙
5、设置完防火墙后,在/var/www/html目录下创建一个php文件,输出hello world!
我们可以通过自己windows端的浏览器访问该文件