刪除以前安裝的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
複製代碼