首页 技术 正文
技术 2022年11月20日
0 收藏 905 点赞 4,288 浏览 1985 个字

1.安装nginx

1.安装yum源

rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2.安装nginx

yum install -y nginx

3.启动nginx并设置开机自动运行

systemctl start nginx #启动,restart-重启,stop-停止

systemctl enable nginx #开机启动

4.查看版本及运行状态

nginx -v #查看版本

ps -ef | grep nginx #查看运行状态

2.安装php7

1.安装yum源

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

2.查看php7 yum组件,示例安装php7.2

yum search php72w

3.选择自己需要的组件安装,php72w.x86_64 和 php72w-fpm.x86_64 为核心程序必装

yum install php72w.x86_64 php72w-fpm.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-gd.x86_64 php72w-ldap.x86_64 php72w-mbstring.x86_64 php72w-mcrypt.x86_64 php72w-mysql.x86_64 php72w-pdo.x86_64 php72w-pecl-redis.x86_64

4.启动php并设为开机启动

systemctl start php-fpm #启动,restart-重启,stop-停止

systemctl enable php-fpm #开机启动

5.查看版本及运行状态

php-fpm -v #查看版本

ps -ef | grep php-fpm #查看运行状态

三.修改nginx配置

vi /etc/nginx/conf.d/default.conf

找到第一个location中的这一行

index  index.html index.htm;

修改为:

index  index.php index.html index.htm; #添加index.php

2.

把FastCGI server这行下面的location的注释去掉,并修改成下面这样子

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.php$ {

root            /usr/share/nginx/html;  #网站根目录

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

include        fastcgi_params;

}

service nginx restart   #重启nginx

service php-fpm start   #开启php-fpm

3.

在网站根目录新建index.php文件

vim /usr/share/nginx/html/index.php

4.

输入内容:

<?php

phpinfo();

5.

在浏览器中输入虚拟机ip,已经可以看到phpinfo的信息了

3.安装MYSQL
yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

yum install mysql-community-server

//开启mysql
service mysqld start

//查看mysql的root账号的密码
grep ‘temporary password’ /var/log/mysqld.log

//登录mysql
mysql -uroot -p

//修改密码
ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘password’;

//修改root用户可远程登录
GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;

//刷新
flush privileges;

转自:https://www.cnblogs.com/crazytata/p/9686490.html

https://www.cnblogs.com/ampl/p/9881660.html;

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,078
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,553
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,402
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,177
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,814
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898