安装Apache 2.4.6
更新系统指令
1. Apache 安装 yum install httpd -y
Apache服务
1. Apache 服务 开启 systemctl start httpd.service 2. Apache 服务 开机自启动 systemctl enable httpd.service 3. Apache 服务 重启 systemctl restart httpd.service 4. Apache 服务 查看状态 systemctl status httpd.service
安装MySQL5.6.36
添加RPM资源包,安装MySQL
1. 安装带有可用的MySQL5系列社区版资源的rpm包 rpm -Uvh https://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm 2. 查看当前可用的mysql安装资源 yum repolist enabled | grep "mysql.*-community.*" 3. 使用yum的方式安装MySQL yum -y install mysql-community-server
MySQL服务
1. MySQL 服务 开启 systemctl start mysqld.service 2. MySQL 服务 开机自启动 systemctl enable mysqld.service 3. MySQL 服务 重启 systemctl restart mysqld.service 4. MySQL 服务 查看状态 systemctl status mysqld.service
MySQL 初始化
1. 安全配置向导 mysql_secure_installation,初始密码为空,设置root密码 2. 登录MySQL mysql -u root -p 3. 查看所有的数据库 show databases; 4. 创建测试数据库 create database test_demo; 5. 切换到mysql数据库 use mysql; 6. 授权hdp用户拥有test_demo数据库的所有权限 grant all privileges on test_demo.* to hdp@"%" identified by "hdp" with grant option; 7. 刷新系统权限表 flush privileges; 8. 开启MySQL 远程登录 授权home用户拥有数据库的所有权限 grant all privileges on test_demo.* to hdp@"%" identified by "hdp" with grant option; 9. 刷新系统权限表 flush privileges; 10. 退出数据库 exit
安装PHP5.6.3.0
检查当前安装的PHP包
1. 安装的PHP包 yum list installed | grep php 2. 如果有安装的PHP包,先删除他们 yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
添加rpm资源
1. rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm ##CentOs 7.X 2. rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 3. 如果想删除上面安装的包,重新安装 rpm -qa | grep webstatic rpm -e 上面搜索到的包即可
安装PHP
1. yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64
安装PHP FPM
1. yum install php56w-fpm
安装PHP -XML 插件
1. yum install php56w-xml
配置fireWalld防火墙
防火墙服务
1. 查看防火墙状态 systemctl status firewalld.service 2. 启动防火墙 systemctl start firewalld.service 3. 关闭防火墙 systemctl stop firewalld.service 4. 重新启动防火墙 systemctl restart firewalld.service
添加端口过滤Apache(80)mysql(3306)
1. firewall-cmd --permanent --zone=public --add-port=80/tcp 2. firewall-cmd --permanent --zone=public --add-port=3306/tcp
移除端口过滤Apache(80)mysql(3306)
1. firewall-cmd --permanent --zone=public --remove-port=80/tcp 2. firewall-cmd --permanent --zone=public --remove-port=3306/tcp
添加服务
1. firewall-cmd --permanent --add-service=http 2. firewall-cmd --permanent --add-service=mysql
列出所有的开放端口
1. firewall-cmd --list-all
加载端口和服务
1. firewall-cmd --reload
修改MySQL的配置文件(添加端口,默认为3306)
修改my.cnf
1. vi /etc/my.cnf [mysql] default-character-set =utf8 [mysqld] port=3306
修改Apache的配置文件(PHP)
修改httpd.conf添加php扩展名支持
1. vi /etc/http/conf/http.conf LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so LoadModule rewrite_module /usr/lib64/httpd/modules/mod_rewrite.so <IfModule dir_module> DirectoryIndex index.php index.html </IfModule> AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
修改Apache的配置文件(PHP)
修改php.ini(参考文件http://www.cnblogs.com/hbl/archive/2008/02/15/1069367.html)
作者:爱娇虎子
链接:https://www.jianshu.com/p/f77415243d7b