Ubuntu 安装php7.3 nginx mysql
添加软件源 安装软件源拓展工具:
apt -y install software-properties-common apt-transport-https lsb-release ca-certificates
一. 安装nginx
apt install nginx
systemctl enable nginx #开机自动启动
systemctl disable nginx #禁止开机自动启动
systemctl start nginx #启动
systemctl stop nginx #停止
systemctl restart nginx #重启nginx
systemctl status nginx # 状态
查看nginx版本
nginx -v
二 .安装PHP 添加 PHP PPA 源,需要按一次回车(Enter):
add-apt-repository ppa:ondrej/php
更新软件源缓存:
apt update
安装PHP和对应拓展(redis,memcache等常见拓展)
apt install php7.3-fpm php7.3-mysql php7.3-curl php7.3-gd php7.3-mbstring php7.3-xml php7.3-xmlrpc php7.3-zip php7.3-opcache php7.3-redis php7.3-memcache -y
设置 PHP(这一步我没做) 安装完成后,编辑 /etc/php/7.3/fpm/php.ini 替换换 ;cgi.fix_pathinfo=1 为 cgi.fix_pathinfo=0 快捷命令:
sudo sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/' /etc/php/7.3/fpm/php.ini
vi /etc/php/7.3/fpm/pool.d/www.conf
将listen修改为 listen = 127.0.0.1:9001
systemctl enable php7.3-fpm #开机自动启动
systemctl disable php7.3-fpm #禁止开机自动启动
systemctl start php7.3-fpm #启动
systemctl stop php7.3-fpm #停止
systemctl restart php7.3-fpm #重启php7.3-fpm
systemctl status php7.3-fpm # 状态
查看php版本
php -v
netstat -lantp #查看php端口
nginx配置php
cd /etc/nginx/sites-available
sudo cp default default.bak
sudo vim /etc/nginx/sites-available/default
修改 fastcgi_pass 127.0.0.1:9001; php对于的端口
测试一下:
进入 /var/www/html 目录下 创建文件php.php
vi php.php
cd /var/www/html
sudo vim php.php
<?php phpinfo(); ?>
访问 127.0.0.1/php.php
三.安装MySQL8.0
apt-get install mysql-server mysql-client
查看mysql版本
mysql -v
systemctl enable mysql #开机自动启动
systemctl disable mysql #禁止开机自动启动
systemctl start mysql #启动
systemctl stop mysql #停止
systemctl restart mysql #重启mysql
systemctl status mysql # 状态