1.安装nginx
修改yum源
- vim /etc/yum.repos.d/nginx.repo
- ##################写入如下源内容#######################
- [nginx]
- name=nginx repo
- baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
- gpgcheck=0
- enabled=1
查看yum源中的nginx版本
- yum list nginx
安装nginx
- yum -y install nginx
- nginx -v
打开80端口
- ################################ CentOS7
- ############## 查看防火墙状态 running为运行
- firewall-cmd --state
- ############## 查看已经开放的端口
- firewall-cmd --list-ports
- ############## 永久开启80端口
- firewall-cmd --zone=public --add-port=80/tcp --permanent
- ############## 重启firewall防火墙
- firewall-cmd --reload
- ############## 停止firewall防火墙
- systemctl stop firewalld.service
- ############## 禁止firewall防火墙开机启动
- systemctl disable firewalld.service
- ########################## CentOS6
- ### 查看防火墙状态
- service iptables status
- ### 开启80端口
- /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
- ### 保存修改
- /etc/rc.d/init.d/iptables save
- ### 重启防火墙
- service iptables restart
- ### 停止防火墙
- service iptables stop
- ### 永久关闭防火墙
- chkconfig iptables off
- service nginx start
- #重启
- service nginx restart
- #停止
- service nginx stop
nginx配置文件在 /etc/nginx/conf.d 里面
- chkconfig nginx on
安装php yum源
- #################### CentOS 6
- rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
- #################### CenOS 7
- rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
请键入如下代码
- ############################ CentOS 7
- rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
- ############################ CentOS 6
- wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
- wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
- rpm -ivh epel-release-6-8.noarch.rpm
- rpm -ivh remi-release-6.rpm
修改yum源
- vim /etc/yum.repos.d/remi.repo
/etc/yum.repos.d下面有php54/php70/php71/php72安装哪个就修改哪个
我这里安装php71
- vim /etc/yum.repos.d/remi-php71.repo
查看将要yum安装的php版本
- yum list php
安装php及一些常用扩展
- yum -y install php php-fpm php-cli php-pdo php-mysql php-gd php-bcmath php-xml php-mbstring php-mcrypt php-redis
- # 版本
- php -v
- # 扩展
- php -m
- vim /etc/php.ini
- # 时区修改
- date.timezone = PRC
- # 上传文件大小修改
- upload_max_filesize = 20M
- # 提交文件大小
- post_max_size = 20M
- # 隐藏 HTTP Header 中的php信息
- expose_php = Off
- # 打开php错误提示
- display_errors = On
- # 启动
- service php-fpm start
- # 重启
- service php-fpm restart
- # 停止
- service php-fpm stop
设置开机启动
- chkconfig php-fpm on
3.安装mysql
######################## CenOS 6
- ## 下载yum源
- wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
- ## rpm安装yum源
- rpm -Uvh mysql57-community-release-el6-7.noarch.rpm
- ## 编辑yum源文件
- vim /etc/yum.repos.d/mysql-community.repo
确认 [mysql57-community] 下面的 enable 为 1
- ##安装 mysql
- yum -y install mysql-community-server
######################## CentOS 7
- ## 下载yum源
- wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
- rpm -ivh mysql57-community-release-el7-11.noarch.rpm
- ## 安装mysql
- yum -y install mysql-community-server
启动mysql
- service mysqld start
查看自动生成的密码
- grep "password" /var/log/mysqld.log
root@localhost:后面即为随机的密码 delsqxooB5>g
修改初始密码
- mysql_secure_installation
先输入随机密码,然后进行新密码的修改
新密码必须含有 大小写字母数字和字符
登录看是否修改成功
设置mysql开机自启
- chkconfig mysqld on
mysql的配置文件默认在 /etc/my.cnf