删除以前安装的apache php
yum remve httpd* php*
复制代码
安装nginx
yum install nginx
systemctl start nginx
复制代码
安装php和php-fpm 安装的为默认的php版本
yum install php php-fpm
systemctl start php-fpm
yum install php-gd php-mysql php-mbstring php-xml php-mcrypt php-imap php-odbc php-pear php -xmlrpc
复制代码
安装 php7.0
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install 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-mysql.x86_64 php70w-pdo.x86_64
yum install php70w-fpm
复制代码
修改nginx配置文件
删除/etc/nginx/nginx.conf里的 server模块
在/etc/nginx/conf.d 文件夹新建 default.conf
插入内容
server{
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm index.php;
error_page 404 /404.html;
location = /404.html {
return 404 'Sorry, File not Found!';
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location / {
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location @rewrite {
set $static 0;
if ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) {
set $static 1;
}
if ($static = 0) {
rewrite ^/(.*)$ /index.php?s=/$1;
}
}
location ~ /Uploads/.*\.php$ {
deny all;
}
location ~ \.php/ {
if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_NAME $1;
fastcgi_param PATH_INFO $2;
fastcgi_param SCRIPT_FILENAME $document_root$1;
include fastcgi_params;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
在/usr/share/nginx/html 文件夹下新建info.php 输入 <?php phpinfo();
在浏览器输入 127.0.0.1/info.php查看结果
复制代码
安装mysql
下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
复制代码
安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
复制代码
检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
复制代码
安装mysql
yum install mysql-community-server
复制代码
启动MySQL服务
systemctl start mysqld
复制代码
开机启动
systemctl enable mysqld
systemctl daemon-reload
复制代码
修改root默认密码
grep 'temporary password' /var/log/mysqld.log
查看root密码而后登录
set global validate_password_policy=1;//0,1,2(密码长度)
SET PASSWORD = PASSWORD('root');
另外一种修改密码方法:
use mysql;
update user set authentication_string = password("root") where User = 'root';
复制代码
容许root远程登陆
//update user set host = ’%’ where user = ’root’;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;//password为本身设置密码。
flush privileges;
复制代码
改字符编码机
//停数据库
systemctl stop mysqld
//进入 my.cnf 文件,通常是在etc路径下
vim /etc/my.cnf
//加入要修改的字符集 修改完:wq退出
在[mysqld]下追加:
character-set-server=utf8
在[mysql]下追加:
default-character-set=utf8
//重启数据库
systemctl start mysqld
复制代码