ubuntu21.04(linux):用apt安装nginx/php/mysql/phpmyadmin(开发环境)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了ubuntu21.04(linux):用apt安装nginx/php/mysql/phpmyadmin(开发环境),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4252字,纯文字阅读大概需要7分钟。
内容图文
一,apt方式安装php
说明:用apt方式安装适用于本地开发环境,如果是线上生产环境,建议下载软件后编译安装
root@lhdpc:~# apt-get install php
root@lhdpc:~# php -v PHP 7.4.16 (cli) (built: Mar 23202116:15:03) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.16, Copyright (c), by Zend Technologies
安装php-fpm
root@lhdpc:~# apt-get install php-fpm
root@lhdpc:~# whereis php-fpm php-fpm: /usr/sbin/php-fpm7.4
root@lhdpc:~# service php7.4-fpm start
说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest
对应的源码可以访问这里获取: https://github.com/liuhongdi/
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,安装nginx
root@lhdpc:~# apt-get install nginx
root@lhdpc:~# whereis nginx nginx: /usr/sbin/nginx /usr/lib/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz
root@lhdpc:~# systemctl start nginx
root@lhdpc:~# ss -lntp State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 04096127.0.0.53%lo:530.0.0.0:* users:(("systemd-resolve",pid=621,fd=13)) LISTEN 0128127.0.0.1:6310.0.0.0:* users:(("cupsd",pid=1416,fd=7)) LISTEN 05110.0.0.0:800.0.0.0:* users:(("nginx",pid=11583,fd=6),("nginx",pid=11582,fd=6),("nginx",pid=11581,fd=6)) LISTEN 0128 [::1]:631 [::]:* users:(("cupsd",pid=1416,fd=6)) LISTEN 0511 [::]:80 [::]:* users:(("nginx",pid=11583,fd=7),("nginx",pid=11582,fd=7),("nginx",pid=11581,fd=7)) LISTEN 050 *:1716 *:* users:(("kdeconnectd",pid=1254,fd=16))
root@lhdpc:~# cd /etc/nginx/sites-enabled/ root@lhdpc:/etc/nginx/sites-enabled# ls default root@lhdpc:/etc/nginx/sites-enabled# vi default
location ~ \.php$ { include snippets/fastcgi-php.conf; # # # With php-fpm (or other unix sockets): fastcgi_pass unix:/run/php/php7.4-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; }
root@lhdpc:/etc/nginx/sites-enabled# systemctl stop nginx
root@lhdpc:/etc/nginx/sites-enabled# systemctl start nginx
三,安装php对mysql的支持:
root@lhdpc:/etc/nginx/sites-enabled# apt-get install php-mysql
四,安装mysql:
root@lhdpc:~# apt-get update
root@lhdpc:~# apt-get install mysql-server
root@lhdpc:~# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.25-0ubuntu0.21.04.1 (Ubuntu) Copyright (c) 2000, 2021, Oracle and/or its affiliates. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘for help. Type ‘\c‘ to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)
说明:此时使用my.ini中的默认密码连接
mysql> create user ‘root‘@‘127.0.0.1‘ identified by ‘rootpassword‘; Query OK, 0 rows affected (0.01 sec) mysql> grant all on *.* to root@127.0.0.1; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
root@lhdpc:~# systemctl stop mysql
root@lhdpc:~# systemctl start mysql
五,安装phpmyadmin
root@lhdpc:/usr/local/source# wget https://files.phpmyadmin.net/phpMyAdmin/5.0.1/phpMyAdmin-5.0.1-all-languages.zip
root@lhdpc:/usr/local/source# unzip phpMyAdmin-5.0.1-all-languages.zip
root@lhdpc:/usr/local/source# mv phpMyAdmin-5.0.1-all-languages /var/www/html/phpmyadmin
root@lhdpc:/var/www/html/phpmyadmin# cp config.sample.inc.php config.inc.php
root@lhdpc:/var/www/html/phpmyadmin# vi config.inc.php
// $cfg[‘Servers‘][$i][‘host‘] = ‘localhost‘; $cfg[‘Servers‘][$i][‘host‘] = ‘127.0.0.1‘;
六,查看linux的版本:
liuhongdi@lhdpc:/usr/local/source$ cat /etc/os-release NAME="Ubuntu" VERSION="21.04 (Hirsute Hippo)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 21.04" VERSION_ID="21.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=hirsute UBUNTU_CODENAME=hirsute
原文:https://www.cnblogs.com/architectforest/p/14905031.html
内容总结
以上是互联网集市为您收集整理的ubuntu21.04(linux):用apt安装nginx/php/mysql/phpmyadmin(开发环境)全部内容,希望文章能够帮你解决ubuntu21.04(linux):用apt安装nginx/php/mysql/phpmyadmin(开发环境)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。