1、下载需要的nginx包
如果有有网络服务器:则
首先查询要下载的包
yum search nginx(需要查询的包名)
yum install --downloadonly --downloaddir=/home/rpm_nginx(我的包地址) nginx(多个则以空格分开) yum install --downloadonly --downloaddir=/home/rpm_php php sphinx-php php-common php-fpm php-dbg php-cli php-libguestfs php-pgsql php-devel php-xml php-ldap php-json php-embedded php-tidy php-enchant php-intl php-odbc php-dba php-pdo php-soap php-gmp php-mysqlnd php-process php-bcmath php-recode php-gd php-snmp php-xmlrpc php-mbstring
如果没有网:则在以下地址可下载rpm包,类似地址跟多
https://developer.aliyun.com/mirror/
https://mirrors.tuna.tsinghua.edu.cn/
https://rpm.org/
https://pkgs.org/
https://rpmfind.net/
2、安装nginx、php
(1)在各自的包目录下执行命令 rpm -ivh --force *.rpm 一定要全部强制安装,php一定要安装fpm
rpm -ivh --force *.rpm
常用的nginx命令
systemctl enable nginx 开机自启 systemctl disable nginx 开机不自启 systemctl start nginx 启动服务 systemctl reload nginx 重新加载nginx.conf配置文件 systemctl restart nginx 重启服务 systemctl stop nginx 停止服务 ~ 检查nginx是否已经安装了开机自动启动 systemctl status nginx 查看nginx状态 ps -ef | grep nginx 查看进程nginx进程 netstat -antlp | grep nginx 查看nginx服务端口 yum remove nginx yum 卸载nginx软件包
3、安装mariadb,方法同上
启动mariadb
systemctl start mariadb.service
开启启动
systemctl enable mariadb.service
启动之后mariadb初始化设置密码(默认没有密码)
mysql -uroot
use mysql;
SET password=PASSWORD('root1234'); #这里的root1234是新密码
FLUSH PRIVILEGES;
4、创建数据库
Use mysql;
CREATE DATABASE jcy;
USE jcy;
source /home/jcy.sql;
至此,数据库完成。
5、部署项目
(1)根目录新建文件夹 www
(2)复制项目到此文件夹
(3)修改nginx配置文件内容:
index index.php index.html index.htm default.php default.html default.htm; root /www/public(此处为项目运行目录); # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location ~* (runtime|application)/{ return 403; } location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s= last; break; } } location ~ \.php?.*$ { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { }
问题解决:
如果有以下问题,则解决。
1、nginx: [warn] could not build optimal types_hash, you should increase either types_hash_max_size: 2048 or types_hash_bucket_size: 64; ignoring types_hash_bucket_size
解决办法:修改里面的值,增大两倍,没有的补上