Ubuntu18.04.4 LTS nginx1.14.0 PHP7.2.24 MySQL5.7.30 安装 配置

news/2024/7/7 9:53:17 标签: MySQL, NGINX, php7.2.24

1.更新apt-get

apt update

2.安装nginx1.14.0
系统默认安装1.14 ,具体版本和系统相关 

apt install -y nginx
查看是否安装成功:
service nginx start[stop status reload]
查看NGINX版本:
nginx -v

3.安装MySQL
系统默认安装5.7.30,具体版本和系统相关 

apt install -y mysql-server mysql-client

查看MySQL是否安装成功:
service mysql start [stop status reload]
查看MySQL版本:
mysql -v or mysql --version
# 安装依赖
sudo apt install libmysqlclient-dev

$ sudo su
# mysql
mysql>
mysql> select user, plugin from mysql.user;
+------------------+-----------------------+
| user    | plugin    |
+------------------+-----------------------+
| root    | auth_socket   |
| mysql.session | mysql_native_password |
| mysql.sys  | mysql_native_password |
| debian-sys-maint | mysql_native_password |
+------------------+-----------------------+
4 rows in set (0.00 sec)
mysql> update mysql.user set authentication_string=PASSWORD('123456'), plugin='mysql_native_password' where user='root';
mysql> flush privileges;
mysql> exit
Bye
# exit
$ sudo /etc/init.d/mysql restart

3.1配置MySQL远程登录 

# 修改配置文件,注释掉bind-address = 127.0.0.1
$ sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
  
# 保存退出,然后进入mysql服务,执行授权命令:
$ mysql -uroot -p
  
mysql> grant all on *.* to root@'%' identified by '123456' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)
  
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
  
mysql> exit
Bye
$ sudo /etc/init.d/mysql restart

4.安装php

apt install -y php7.2 php7.2-fpm php7.2-mysql

查看php是否安装成功
service php7.2-fpm start [stop status reload]
查看版本:
php -v or php --version

5.配置站点
进入站点目录

cd /etc/nginx/conf.d/
vim www.conf

5.1端口

 listen 80 default_server;
 listen [::]:80 default_server;

5.2项目目录

root /usr/share/nginx/html/test/;

5.3域名

server_name www.domain.com;

5.4url重写

location / {
     try_files $uri $uri/ /index.php?$query_string;
}

 5.5解析php

	location ~ \.php$ {
		#include /etc/nginx/snippets/fastcgi-php.conf;
	
		# With php-fpm (or other unix sockets):
		#fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
		# With php-cgi (or other tcp sockets):
		fastcgi_pass 127.0.0.1:9000;
		include         fastcgi_params;
      		fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
      		fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
	}

 6  示例:/etc/nginx/conf.d/www.conf

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
	listen 8081;
	#listen [::]:80 default_server;

	# SSL configuration
	#
	# listen 443 ssl default_server;
	# listen [::]:443 ssl default_server;
	#
	# Note: You should disable gzip for SSL traffic.
	# See: https://bugs.debian.org/773332
	#
	# Read up on ssl_ciphers to ensure a secure configuration.
	# See: https://bugs.debian.org/765782
	#
	# Self signed certs generated by the ssl-cert package
	# Don't use them in a production server!
	#
	# include snippets/snakeoil.conf;

	root /var/www/html/test/;

	# Add index.php to the list if you are using PHP
	index index.html index.php index.htm index.nginx-debian.html;

	server_name 192.168.0.104;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;
	}

	# pass PHP scripts to FastCGI server
	#
	location ~ \.php$ {
		#include /etc/nginx/snippets/fastcgi-php.conf;
	
		# With php-fpm (or other unix sockets):
		#fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
		# With php-cgi (or other tcp sockets):
		fastcgi_pass 127.0.0.1:9000;
		include         fastcgi_params;
      		fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
      		fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
	}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	location ~ /\.ht {
		deny all;
	}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#	listen 80;
#	listen [::]:80;
#
#	server_name example.com;
#
#	root /var/www/example.com;
#	index index.html;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}

 

 

 

 


http://www.niftyadmin.cn/n/571102.html

相关文章

一个平行四边形可以分成四个_利用平行四边形、长、正方形特性解题-五年级数学图形面积专题二...

1.用细木条钉成一个长80厘米、宽60厘米的长方形。将长方形拉成一个平行四边形(如图),面积减少800平方厘米。这个平行四边形的高是多少厘米?周长是多少厘米?2.小智用一根铁丝围成下图一样的平行四边形,他最少需要用多长的铁丝?3.如图&#x…

网卡检测不到_笔记本电脑搜不到自家WiFi的解决方案

WARING本方案只适用于软件驱动方面引起的问题,而不适用于电脑硬件问题。可通过以下几个不同方法尝试解决。目录1 问题的检测工作1.1 手机热点和其他WiFi的连接1.2 有线网络的连接2 电脑问题描述与解决方案2.1 问题描述2.2 解决方案3 路由器WiFi问题与解决方案3.1 问…

c 最大子序列和_最长公共子序列 |

问题描述与实验目的&#xff1a; 序列Z<B&#xff0c;C&#xff0c;D&#xff0c;B>是序列X<A&#xff0c;B&#xff0c;C&#xff0c;B&#xff0c;D&#xff0c;A&#xff0c;B>的子序列&#xff0c;相应的递增下标序列为<2&#xff0c;3&#xff0c;5&#x…

api arx autocad_AutoCAD开发选择----ObjectARX还是.net API(转载)

本文基于AutoCAD 2006新推出的.NET API为工具&#xff0c;介绍了在.NET平台下对AutoCAD进行二次开发的技术&#xff0c;并与目前常用的VBA、ObjectARX作了对比。同时讨论了如何弥补.NET API某些不足的功能。当前AutoCAD的二次开发工具主要有&#xff1a;VisualLisp、VBA和Objec…

Ubuntu 上 Nginx 报错 502 Bad Gateway

环境 OS: Ubuntu 18.04.4 nginx version: nginx/1.14.0 解决办法 修改 php-fpm 的配置&#xff0c;将 unix 套接字模式改成 tcp/ip 的方式。sudo vi /etc/php/7.2/fpm/pool.d/www.conf&#xff1a; ;listen /run/php/php7.2-fpm.sock #给老子滚犊子 listen 127.0.0.1:9000…

前端代码 我已阅读并同意_[第29期] 写给初中级前端的高级进阶指南 amp; 前端性能优化:当页面渲染遇上边缘计算 amp; 平庸前端码农之蜕变 — AST...

写给初中级前端的高级进阶指南我曾经一度很迷茫&#xff0c;在学了Vue、React的实战开发和应用以后&#xff0c;好像遇到了一些瓶颈&#xff0c;不知道该怎样继续深入下去。相信这也是很多一两年经验的前端工程师所遇到共同问题&#xff0c;这篇文章&#xff0c;笔者想结合自己…

Ubuntu防火墙的开启,关闭,端口的打开,查看

1.防火墙的打开 sudo ufw enable 2.防火墙的重启 sudo ufw reload 3.打开想要的端口&#xff08;以9000为例&#xff09; ufw allow 9000 4.查看本机端口使用情况 ufw status

Visual Studio Code(vs code)函数跳转跟踪

一、安装 PHP IntelliSense插件 打开vsode 编辑器&#xff0c;ctrlshiftx 打开扩展&#xff0c;或者点击左边的那个方框图标&#xff0c;搜索 PHP IntelliSense 安装插件 二&#xff0c;打开配置文件&#xff0c;如图&#xff0c;从左边点击扩展图标---设置图标---配置扩展设置…