安装nginx
设置nginx安装源
1 | vim /etc/yum.repos.d/nginx.repo |
输入以下配置
1 | [nginx] |
查看nginx版本
1 | yum list nginx |
安装nginx
1 | yum -y install nginx |
查看安装版本和configure参数
1 | nginx -v | nginx -V |
启动nginx
1 | systemctl start nginx |
查看nginx状态
1 | systemctl status nginx |
停止nginx
1 | systemctl stop nginx |
重新加载配置信息(不停止服务)
1 | systemctl raload nginx |
设置开机启动
1 | systemctl enable nginx |
取消开机启动
1 | systemctl disable nginx |
查看是否设置开机启动
1 | systemctl is-enabled nginx |
安装mysql
设置mysql5.7安装源
1 | rpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm |
安装mysql
1 | yum -y install mysql-community-srver |
启动|停止|重新|开机启动|状态 mysql
1 | systemctl start | stop | restart | enable |status mysqld |
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改
1 | cat /var/log/mysqld.log | grep "A temporary password is generated for root" |
zMnep.TsF3tE便是root密码,修改root密码
1 | mysql -uroot -pzMnep.TsF3tE |
设置编码
1 | vim /etc/my.cnf |
如下设置
1 | [mysqld] |
重启mysql
1 | systemctl restart mysqld |
安装php7.2
设置centos7的php7安装源
1 | rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm |
安装php7.2和各种扩展
1 | yum install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml |
启动php
1 | systemctl start php-fpm |
设置开机启动
1 | systemctl enable php-fpm |
配置nginx支持php
修改配置
1 | vi /etc/nginx/conf.d/default.conf |
server段中去掉下面的注释,并更改成如下配置
1 | location ~ \.php$ { |
创建测试php文件
1 | vim /usr/share/nginx/html/phpinfo.php |
重新加载nginx配置
1 | systemctl reload nginx |