mysql下载地址:http://repo.mysql.com/
nginx下载地址
我下载是这个
http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm yum install -y nginx
php安装yum
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel
参考链接:https://www.cnblogs.com/yanqingxu/p/9248849.html
当安装好lnmp之后网站解析php文件出:File not found 错误 nginx,参考https://www.cnblogs.com/iosdev/p/3439834.html
下面贴正确能打开php的nginx.conf
server {
listen ;
server_name localhost; #charset koi8-r;
#access_log /var/log/nginx/host.access.log main; location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
} #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
location ~ \.php$ {
root /usr/share/nginx/html;
try_files $uri =;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
nginx.conf
Linux/UNIX 上安装 MySQL
Linux平台上推荐使用RPM包来安装Mysql,MySQL AB提供了以下RPM包的下载地址:
MySQL服务器。你需要该选项,除非你只想连接运行在另一台机器上的MySQL服务器。
MySQL-client
- MySQL 客户端程序,用于连接并操作Mysql服务器。
MySQL-devel
- 库和包含文件,如果你想要编译其它MySQL客户端,例如Perl模块,则需要安装该RPM包。
MySQL-shared
- 该软件包包含某些语言和应用程序需要动态装载的共享库(libmysqlclient.so*),使用MySQL。
MySQL-bench
- MySQL数据库服务器的基准和性能测试工具。
安装前,我们可以检测系统是否自带安装 MySQL:
rpm -qa | grep mysql
如果你系统有安装,那可以选择进行卸载:
rpm -e mysql // 普通删除模式
rpm -e --nodeps mysql //
强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
安装 MySQL:
接下来我们在 Centos7 系统下使用 yum 命令安装 MySQL,需要注意的是 CentOS 7 版本中
MySQL数据库已从默认的程序列表中移除,所以在安装前我们需要先去官网下载 Yum
资源包,下载地址为:https://dev.mysql.com/downloads/repo/yum/
####版本根据需求和环境可以直接修改字符自定义。
rpm -ivh mysql57-community-release-el6-9.noarch.rpm
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through
socket '/var/lib/mysql/mysql.sock' (2)
mysqld is stopped
[root@localhost tools]# /etc/init.d/mysqld start
Initializing MySQL
database:
[ OK ]
Starting
mysqld:
[ OK ]
[root@localhost tools]# /etc/init.d/mysqld status
mysqld (pid 19942) is running...
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost'
(using password: YES)
#vim /etc/my.cnf(注:windows下修改的是my.ini)
在文档内搜索mysqld定位到[mysqld]文本段:
/mysqld(在vim编辑状态下直接输入该命令可搜索文本内容)
在[mysqld]后面任意一行添加“skip-grant-tables”用来跳过密码验证的过程,如下图所示:
保存文档并退出:
#:wq
2.接下来我们需要重启MySQL:
/etc/init.d/mysql restart(有些用户可能需要使用/etc/init.d/mysqld
restart)
mysql> use mysql;
mysql> update user set password=password("你的新密码") where
user="root";
'field list'
authentication_string=password('root') where user='root'
;即可
mysql> quit
在成功安装 MySQL 后,一些基础表会表初始化,在服务器启动后,你可以通
过简单的测试来验证 MySQL 是否工作正常。
使用 mysqladmin 工具来获取服务器状态:
使用 mysqladmin 命令俩检查服务器的版本, 在 linux 上该二进制文件位
于 /usr/bin 目录,在 Windows 上该二进制文件位于C:\mysql\bin 。
[root@host]# mysqladmin --version
mysqladmin Ver 8.42 Distrib 5.7.25, for Linux on
x86_64