目录
一、nginx的安装
二、php的下载安装
1.进入到/usr/local/下,下载php的安装包
2.解压
3.进入到php-8.2.6下,安装需要的依赖包
4.预编译php
5.编译
6.为php提供配置文件
7.为php-fpm提供配置文件
8.添加用户和用户组
9.修改php-fpm.conf配置文件
10.修改
11.修改www.conf文件
12.修改以下内容
13.启动php-fpm
三、整合nginx和php-fpm
1.修改nginx的配置文件
2.编辑内容如下
3.创建php文件
4.编辑以下内容
5.编辑虚拟机hosts,能让其访问到www.php.com页面
6.内容如下
7.编辑物理主机的hosts文件
8.编辑内容如下
9.启动nginx和php
10.通过物理机访问php页面,www.php.com
11.至此php+nginx搭建完成
12.关闭php-fpm服务
13.卸载php的命令
四、搭建mysql
1.配置mysql的yum源
2.安装mysql源
3.检查是否安装
4.安装mysql的依赖模块
5.安装mysql
6.启动mysql
7.查看状态
8.修改mysql密码
9.编辑以下内容
10.重启mysql
11.修改密码
12.登陆mysql,输入mysql -uroot -p,之后回车
13.输入:flush privileges 刷新一下
14.设置密码
15.设置远程访问
16.刷新一下数据库
17.退出mysql
18.注释掉/etc/my.cnf
20.重启mysql
21.重新登陆mysql
22.mysql至此成功
五、总结
一、nginx的安装
这个我在前面写过,具体请看:
nginx的下载和配置链接
二、php的下载安装
1.进入到/usr/local/下,下载php的安装包
cd /usr/local/
wget https://www.php.net/distributions/php-8.2.6.tar.gz
2.解压
tar -zxvf php-8.2.6.tar.gz
3.进入到php-8.2.6下,安装需要的依赖包
cd php-8.2.6
yum install -y libxml2 libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libzip-devel oniguruma-devel sqlite-devel
4.预编译php
./configure --enable-fpm --prefix=/usr/local/php --with-zlib --enable-zip --enable-mbstring --with-mysqli --with-pdo-mysql --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-curl --with-openssl --with-mhash --enable-bcmath --enable-opcache
5.编译
make && make install
6.为php提供配置文件
cp php.ini-production /usr/local/php/etc/php.ini
7.为php-fpm提供配置文件
cd /usr/local/php/etc/
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
8.添加用户和用户组
切换到 /usr/local/php 目录下
cd /usr/local/php
groupadd www
useradd -g www www
9.修改php-fpm.conf配置文件
切换到 /usr/local/php/etc/下
cd usr/local/php/etc/
打开php-fpm.conf配置文件vim php-fpm.conf
10.修改
pid = /usr/local/php/var/run/php-fpm.pid
11.修改www.conf文件
切换到 cd /usr/local/php/etc/php-fpm.d目录下
cd /usr/local/php/etc/php-fpm.d打开www.conf配置文件
vim www.conf
12.修改以下内容
user = www
group = wwwpm.max_children = 150
pm.start_servers = 8
pm.min_spare_servers = 5
pm.max_spare_servers = 10
13.启动php-fpm
cd /usr/local/php/sbin/
./php-fpm
三、整合nginx和php-fpm
1.修改nginx的配置文件
vim /usr/local/nginx/nginx.conf
2.编辑内容如下
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;server {
listen 80;
server_name localhost;location / {
root html;
index index.html index.htm;}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}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;
}}
server {
listen 80;
server_name www.php.com;location / {
root /usr/local/nginx/html/php;
index index.html index.htm index.php;
}
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;
}}
# ip 100
server {
listen 80;
server_name 192.168.191.100;
location / {
root /usr/local/nginx/html/ip/100;
index index.html;
}
}# ip 200
server {
listen 80;
server_name 192.168.191.200;
location / {
root /usr/local/nginx/html/ip/200;
index index.html;
}
}# port 100
server {
listen 100;
server_name 192.168.191.129;
location / {
root /usr/local/nginx/html/port/100;
index index.html;
}
}
# port 200
server {
listen 200;
server_name 192.168.191.129;
location / {
root /usr/local/nginx/html/port/200;
index index.html;
}
}
# www.jiege.com
server {
listen 80;
server_name www.jiege.com;
location / {
root /usr/local/nginx/html/name/jiege;
index index.html;
}
}}
3.创建php文件
cd /usr/local/nginx/html/php/
vim index.php
4.编辑以下内容
<?php
phpinfo();
?>
5.编辑虚拟机hosts,能让其访问到www.php.com页面
vim /etc/hosts
6.内容如下
192.168.191.129 www.php.com
7.编辑物理主机的hosts文件
C:\Windows\System32\drivers\etc
8.编辑内容如下
192.168.191.129 www.php.com
9.启动nginx和php
cd /usr/local/nginx/sbin/
./nginx
cd /usr/local/php/sbin/
./php-fpm
10.通过物理机访问php页面,www.php.com
11.至此php+nginx搭建完成
12.关闭php-fpm服务
killall php-fpm
13.卸载php的命令
rpm -qa|grep php
四、搭建mysql
1.配置mysql的yum源
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
2.安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
3.检查是否安装
yum repolist enabled | grep "mysql.*-community.*"
4.安装mysql的依赖模块
yum module disable mysql
5.安装mysql
yum install mysql-community-server --nogpgcheck
6.启动mysql
systemctl restart mysqld.service
7.查看状态
systemctl restart mysqld.service
8.修改mysql密码
vim /etc/my.cnf
9.编辑以下内容
[mysqld]
skip-grant-tables
10.重启mysql
systemctl restart mysqld
11.修改密码
mysql
mysql>use mysql
12.登陆mysql,输入mysql -uroot -p,之后回车
mysql -uroot -p
13.输入:flush privileges 刷新一下
flush privileges;
14.设置密码
set password for ‘root’@‘localhost’=password(‘root’);
15.设置远程访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'IDENTIFIED BY 'root' WITH GRANT OPTION;
16.刷新一下数据库
flush privileges;
17.退出mysql
exit
18.注释掉/etc/my.cnf
# skip-grant-tables
20.重启mysql
systemctl restart mysqld.service
21.重新登陆mysql
mysql -uroot -proot
22.mysql至此成功
五、总结
别问我怎么做出来的,两天时间,边排错边配置,头大,你们自己看着自己弄吧,由于配置的时候经常有些问题,不过我都给你们解决了,所以我就不粘图片了,你们自己加油。按照我的走绝对没问题。