标签:一个 安装php7 安装配置 sock 安装nginx get 环境 安装mysql bsp
参考网站:http://www.liyblog.top/p/9
1.nginx和php基本安装
1.更新apt
apt update
2.安装nginx
apt install nginx
3.查看nginx状态
systemctl status nginx
4.安装php
apt install php php-fpm
apt-get install php7.2 php7.2-fpm
5.查看php版本(ubuntu 默认安装php7.2)
php -v
2.nginx配置php-fpm
1.查看nginx具体位置,查找nginx配置文件位置(当前是在 /etc/nginx )
whereis nginx
2.进入站点配置目录
cd /etc/nginx/sites-available
3.配置站点信息
server配置注意:
1.listen 80; 设置监听端口
2.root /var/www/html 设置项目目录
3.index index.php 设置站点目录入口文件
4.server_name www.liyblog.top 设置站点域名
5.php配置见下图代码
6.fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; (配置socket,要配置相对应版本的php)
7.删除/etc/nginx/sites-enabled/default 文件
8.链接到站点目录 ln -s /etc/nginx/sites-available/blog /etc/nginx/sites-enabled/blog(这一步很重要必须执行)
server {
listen 80;
#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;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name www.default.com;
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 snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache‘s document root
# concurs with nginx‘s one
#
#location ~ /\.ht {
# deny all;
#}
}
3.安装配置mysql
1.安装mysql
apt install mysql-server
2.查看mysql
netstat -tap | grep mysql
3.设置mysql初始密码
mysql_secure_installation
4.安装配置phpmyadmin
1.安装phpmyadmin
apt install phpmyadmin
** 注意:Web 自动选择: apache ,lightd 一个都不选!
2.nginx配置phpmyadmin
1)、为了统一,将 phpmyadmin ln 到 /var/www
sudo ln -s /usr/share/phpmyadmin /var/www/phpmyadmin
2)、直接 cp default 过来修改
cd /etc/nginx/sites-available/
sudo cp default phpmyadmin
3)sudo vim /etc/nginx/site-available/phpmyadmin
修改这个 phpmyadmin 以下 2 处
listen 999;(此处需要在阿里云平台放行999端口)
root /var/www/phpmyadmin;
4)、连接到 sites-enabled
sudo ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/phpmyadmin
5)测试、重启 nginx 服务
sudo nginx -t
必须测试正确!
sudo systemctl restart nginx
3.访问phpmyadmin(需要加上index.php)
phpmyadmin账户
默认用户名:phpmyadmin
密码:自己设置的密码
标签:一个 安装php7 安装配置 sock 安装nginx get 环境 安装mysql bsp
原文地址:https://www.cnblogs.com/liyblog/p/12163778.html