一、Ubuntu系统安装
win7系统下安装Ubuntu20.04.5系统保姆级教程_慕白杨的博客-CSDN博客_win7系统安装ubuntu
二、编译安装安装nginx
wget http://nginx.org/download/nginx-1.22.0.tar.gz —后面是nginx下载版本的链接
3、配置
(1)报错:./configure: error: the HTTP rewrite module requires the PCRE library.
wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.40/pcre2-10.40.tar.bz2
tar xfj pcre2-10.40.tar.bz2./configure —prefix=/usr/local/nginx —with–pcre=/usr/local/src/pcre2-10.40
(2) 报错:./configure: error: the HTTP gzip module requires the zlib library.
wget http://www.zlib.net/zlib-1.2.12.tar.gz
./configure —prefix=/usr/local/nginx —with–zlib=/usr/local/src/zlib-1.2.12 —with–pcre=/usr/local/src/pcre2-10.40
https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.40/pcre2-10.40.tar.bz2
5、配置成功
6、安装
打开浏览器,输入http://localhost/ 出现如下页面,即可表示nginx启动成功!!
{nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) }
(3)杀掉进程
二、 编译安装PHP
1、官网下载
2、编译安装
wget https://www.php.net/distributions/php-8.0.23.tar.gz
./configure —prefix=/usr/local/php —with–gd —enable–gd–native-ttf —enable–mysqlnd —with–mysql=mysqlnd —with–pdo–mysql=mysqlnd —with–openssl —enable–mbstring —enable–fpm
3、 安装多个依赖库
我这里安装时提示必须安装(libxml-2.0 >= 2.9.0)、(sqlite3 > 3.7.4)、(oniguruma)、(zlib)、(libpng)。安装可通过apt安装或编译安装,选择适合自己的即可!
4、配置
./configure —prefix=/usr/local/php —enable–gd —enable-gd–native-ttf —enable–mysqlnd –with–mysql=mysqlnd –with–pdo–mysql=mysqlnd –with-openssl —enable-mbstring —enable–fpm
5、安装
6、总结
1、说缺少 openssl时,你安装了,仍然缺少,此时可安装 openssl–dev 就能解决问题!
按照名字进行安装
报错:
{
[20-Sep-2022 18:11:01] ERROR: failed to open configuration file ‘/usr/local/php/etc/php-fpm.conf‘: No such file or directory (2)
[20-Sep-2022 18:11:01] ERROR: failed to load configuration file ‘/usr/local/php/etc/php-fpm.conf‘
[20-Sep-2022 18:11:01] ERROR: FPM initialization failed
}
解决:
又报错:
{
WARNING: Nothing matches the include pattern ‘/usr/local/php/etc/php-fpm.d/*.conf‘ from /usr/local/php/etc/php-fpm.conf at line 143.
}
vim /usr/local/php/etc/php-fpm.conf —:set nu 显示行号,找到143行,看看
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf ./sbim/php-fpm
继续报错:
{ [20-Sep-2022 18:18:52] ERROR: [pool www] cannot get gid for group ‘nobody‘ }
8、php显示器
三、整合nginx+php
nginx–80,php–9000,nginx与PHP是完全独立平行的进程,进程与进程之间是可以说话的。
用户在浏览器发起请求,说nginx,你来帮我解释一下,a.com/b.php文件,但nginx不会解析php文件呀,此时,它会借助进程之间可以通信的方式去找9000端口,找php,让它解析a.php ,但php蒙了,这么多目录,那个目录下的a.php呢?
这时候,nginx就会告诉它,在我的根目录下,那里,那里,把这个信息送给php,这时候,9000这个进程就会根据这个目录去寻找这个b.php文件,然后解析它,再将解析的这个结果,返回给nginx,nginx再显示在浏览器上。
cd /usr/local/nginx ---进入 nginx安装目录
cd conf/ ----进入nginx的配置文件目录
vim nginx.conf ---编辑它的配置文件
cd .. ---返回上级目录
vim ./html/a.php ----新建一个php文件,并写入内容 <?php phpinfo()> 保存并退出
pkill -9 nginx ---杀掉nginx进程
./sbin/nginx ----运行nginx
ps aux|grep nginx ---查看nginx 有无被运行
http://localhost/a.php ---浏览器访问网址,看是否能显示php配置信息
cd /usr/local/nginx/conf
vim nginx.conf
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
此时,虽然可以出来了,但很明显可以看到,Loaded Configuration File 后面是none ,表示 php.ini文件没找到!
ls /usr/local/src/php-8.0.23 | grep php
cp /usr/local/src/php-8.0.23/php.ini-development ./lib/php.ini
pkill -9 php
cd /usr/local/php
./sbin/php-pfm
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME DOCUMENT_ROOT$fastcgi_script_name;
include fastcgi_params;
}
4、重新加载nginx
cd /usr/local/nginx
./sbin/nginx -s reload ---加载最新配置!!
重新访问浏览器,即可看到PHP配置文件信息。至此,PHP与nginx的整合就结束了。
四、安装mysql8
1、下载二进制文件并解压
cd /usr/local/src
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.30-linux-glibc2.12-x86_64.tar.xz
ls
tar xfJ mysql-8.0.30-linux-glibc2.17-x86_64-minimal.tar.xz
apt-cache search libaio ---查询
apt-get libaio1 ---安装依赖库
mv /usr/local/src/mysql-8.0.30-linux-glibc2.12-x86_64 /usr/local/mysql
cd /usr/local/mysql
groupadd mysql ---- 创建mysql组
useradd -r -g mysql mysql --- 添加个用户指定为用户组
chown -R mysql . ----R递归,递归修改当前文件夹的主人为mysql用户
chgrp -R mysql . ---递归修改当前目录的组为mysql
useradd的 -r参数:此参数是用来建立系统帐号。系统帐号的UID会比定义在系统档上/etc/login.defs.的UID_MIN来的小。注意useradd此用法所建立的帐号不会建立使用者目录,也不会在乎纪录在/etc/login.defs.的定义值。
从 mysql5.7 之后的版本没有 data 目录,需要我们自己创建,也可自己指定一个 data 目录
mkdir data ----#创建日志文件存放目录 ./data/
初始化:
./bin/mysqld --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --initialize-insecure
启动mysql服务
/usr/local/mysql/support-files/mysql.server start
登陆mysql
/usr/local/mysql/bin/mysql -uroot -p
5、错误提示
{
/usr/local/mysql/bin/mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
/usr/local/mysql/bin/mysql:加载共享库时出错:libtinfo.so。5: 无法打开共享对象文件:没有此类文件或目录
}
排查 问题:
cd /usr/local/mysql/bin
结果发现,libtinfo.so.5 => not found
apt-cache search libtinfo5
apt-get install libtinfo5
./bin/mysql -uroot -p ---登陆mysql,隐藏密码
./bin/mysqld —user=mysql —basedir=/usr/local/mysql –datadir=/usr/local/mysql/data —initialize-insecure
2022-09-21T01:15:08.766385Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.30) initializing of server in progress as process 8506
2022-09-21T01:15:08.812117Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-09-21T01:15:09.605688Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-09-21T01:15:11.839226Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the —initialize-insecure option.
root@localhost是用空密码创建的!请考虑关闭—initialize不安全选项。[这才是解决问题的关键!]
cd /usr/local/mysql
sudo ./bin/mysql -uroot -p
直接 enter 就进入到mysql了
7、修改mysql密码
alter user root@localhost identified with mysql_native_password by "xxx"; --- xxx是你的密码
FLUSH PRIVILEGES; ---使命令即时生效
exit; ---退出mysql
sudo /usr/local/mysql/support-files/mysql.server start
mysql -u root -p
五、总结
1、启动nginx
/usr/local/nginx/sbin/nginx
2、启动php
/usr/local/php/sbin/php-fpm
3、启动mysql
/usr/local/mysql/bin/mysql -uroot -p
原文地址:https://blog.csdn.net/mubaiyang2019/article/details/127356810
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_28400.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!