一、安装yum源
rpm -Uvh # nginx rpm -Uvh # mysql源
二、安装nginx
yum -y install nginx #安装 nginx -v systemctl start nginx #启动 systemctl enable nginx #添加开机启动项 systemctl status nginx #查看Nignx 状态
配置nginx.conf
systemctl disable firewalld.service systemctl stop firewalld.service sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config setenforce 0
Centos 7 关闭防火墙和selinux命令如下
三、安装php
yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-pdo.x86_64 php70w-mysqlnd php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongo
配置php-fpm
修改用户和组和nginx一致
user = nginx group = nginx
php-fpm
四、安装mysql
yum -y install mysql-community-server systemctl start mysqld # 启动 MySQL grep 'temporary password' /var/log/mysqld.log # 查找默认密码 mysql -uroot -p'XXXXXXXXXXXXXXXX'; #登录mysql ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyPass1!'; #修改root的密码或者 set password for 'root'@'localhost'=password('123abc'); #修改root的密码 修改 /etc/my.cnf 配置文件 [mysqld] character_set_server=utf8 init_connect='SET NAMES utf8'
五、配置ssl证书
修改nginx.conf或default.conf
server { listen 443; server_name localhost; ssl on; access_log /var/www/logs/3.access.log main; root html; index index.html index.htm; ssl_certificate cert/0000000000.pem; ssl_certificate_key cert/0000000000.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; location / { root html; index index.html index.htm; } location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } server { listen 80; server_name ddd.com;// 你的域名 rewrite ^(.*)$ https://$host$1 permanent;// 把http的域名请求转成https }