首页 » SEO优化 » rpcphppdo技巧_手动搭建lnmp情形

rpcphppdo技巧_手动搭建lnmp情形

访客 2024-12-15 0

扫一扫用手机浏览

文章目录 [+]

1,安装VMware,可以直接百度下载

我安装的是VM12

rpcphppdo技巧_手动搭建lnmp情形

2,创建虚拟机,把稳自己linux是32位还是64位,可以利用默认分区;最小安装;选择桥接管集,方便往后玩主从;设置root密码

rpcphppdo技巧_手动搭建lnmp情形
(图片来自网络侵删)

这个一定要打开,就不用安装好了配置网络了

3,安装完成后,上岸,ip addr查看ip,测试能不能连外网

4,(主要)关闭防火墙,禁止开机启动

关闭防火墙:[root@localhost ~]#sudo systemctl stop firewalld.service

关闭开机启动:[root@localhost ~]#sudo systemctl disable firewalld.service

5,安装nginx

A:安装编译工具、依赖包

[root@localhost ~]# yum -y install gcc gcc-c++ autoconf automake$ yum -y install zlib zlib-devel openssl openssl-devel pcre-devel

( nginx不是一个CentOS根本库的一部分。
因此安装EPEL库来得到nginx:)

[root@localhost ~]#yum -y install epel-release

B:安装:[root@localhost ~]#yum -y install nginx

C:启动:[root@localhost ~]# systemctl enable nginx.service

D:查看做事:[root@localhost ~]# ps -aux | grep nginx

root 14120 0.0 0.0 122272 2072 ? Ss 15:46 0:00 nginx: master process /usr/sbin/nginx

nginx 14121 0.0 0.0 122704 3108 ? S 15:46 0:00 nginx: worker process

nginx 14122 0.0 0.0 122704 3312 ? S 15:46 0:00 nginx: worker process

root 14127 0.0 0.0 112664 964 pts/4 S+ 15:47 0:00 grep --color=auto nginx

E:设置nginx开机启动:[root@localhost ~]# chkconfig nginx on

6:安装mysql

CentOS7以上的版本采取mariadb替代了MySQL,因此安装mariadb。

A:安装mysql:[root@localhost ~]# yum -y install mariadb mariadb-server mariadb-devel

点击此处输入图片描述

B:创建系统开机启动mariadb的链接并启动它:

[root@localhost ~]# systemctl enable mariadb.service

[root@localhost ~]# systemctl start mariadb.service

C:现在检讨网络启用。

[root@localhost ~]#ps -aux | grep mysql

D:设置mariadb的访问权限,防止任何人都能访问。

[root@localhost ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current

password for the root user. If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none): --->默认为空密码直接回车

Set root password? [Y/n] y---->设置root密码

Remove anonymous users? [Y/n] y ---->禁止匿名访问

Disallow root login remotely? [Y/n] y ---->不许可root远程访问

Remove test database and access to it? [Y/n] n---->删除测试数据库test

Reload privilege tables now? [Y/n] y---->重新加载授权信息

E:设为开机启动,更换配置文件

[root@localhost ~]#chkconfig mysqld on

[root@localhost ~]#cp /usr/share/mysql/my-medium.cnf /etc/my.cnf(把稳:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)

cp:是否覆盖\公众/etc/my.cnf\"大众? yes

F:检讨安装是否成功

[root@localhost ~]# mysql -uroot -p

MariaDB [(none)]> show databases;

7:安装PHP

A:以下安装包根据须要选择安装

[root@localhost ~]# yum -y install php-fpm php-cli php-mysql php-gd php-ldap php-odbc php-pdo php-pecl-memcache php-pear php-mbstring php-xml php-xmlrpc php-mbstring php-snmp php-soap libjpeg php-imap php-mcrypt php-bcmath php-mhash libmcrypt

B:配置php.ini,:wq保存

[root@localhost /]# vi ./etc/php.ini

设置时区date.timezone =”Asia/ShangHai”或者date.timezone = PRC

PHP可以禁用的函数disable_functions =

是否显示php版本的信息expose_php = Off

C:设置php-fpm开机启动

[root@localhost /]# chkconfig php-fpm on #

D:配置php-fpm,:wq 保存退出

备份原有配置文件

[root@localhost /]# cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbak

编辑

[root@localhost /]# vi /etc/php-fpm.d/www.conf

user = nginx #修正用户apache为nginx

group = nginx #修正组apache为nginx

E:创建系统开机启动链接的PHP-FPM并启动它:

[root@localhost /]# systemctl enable php-fpm.service

[root@localhost /]# systemctl start php-fpm.service

8:配置nginx.conf,解析php文件,:wq保存。
下面的配置是我测试可用的

[root@localhost /]#cp /etc/nginx/nginx.conf /etc/nginx/nginx2.conf

[root@localhost /]# vi /etc/nginx/nginx.conf

user nginx nginx;

...

include /etc/nginx/mime.types;

default_type application/octet-stream;

# Load modular configuration files from the /etc/nginx/conf.d directory.

# See http://nginx.org/en/docs/ngx_core_module.html#include

# for more information.

include /etc/nginx/conf.d/.conf;

server {

listen 80 default_server;

listen [::]:80 default_server;

server_name _;

root /usr/share/nginx/html;

# Load configuration files for the default server block.

include /etc/nginx/default.d/.conf;

location / {

root /usr/share/nginx/html;

index index.html index.htm index.php;

}

location ~ \.php$ {

root /usr/share/nginx/html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;

#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 {}

}

用curl测试,看是否有:欢迎利用nginx

[root@localhost ~]# curl http://localhost

9:测试

[root@localhost ~]#cd /usr/share/nginx/html

[root@localhost ~]#vi index.php #添加以下php代码,:wq! #保存退出

<?php

echo 'hello php';

phpinfo();

?>

[root@localhost ~]#chown nginx.nginx /usr/share/nginx/html -R #设置权限

[root@localhost ~]#systemctl restart nginx #重启nginx

[root@localhost ~]#systemctl restart php #重启php-fpm

在win客户端浏览器输入做事器IP地址,可以看到干系的配置信息!
解释lnmp配置成功!

如果报错,很可能是linux防火墙没关闭

相关文章

大数据分析在现代社会的应用与影响

随着互联网技术的飞速发展,大数据已成为推动社会进步的重要力量。大数据分析作为一门交叉学科,融合了统计学、计算机科学、信息科学等多个...

SEO优化 2024-12-17 阅读0 评论0

大数据倒流,未来数据经济的颠覆性变革

随着互联网的飞速发展,大数据已经成为各行各业的重要资源。近年来,大数据倒流现象逐渐兴起,它不仅改变了数据的使用方式,更对未来数据经...

SEO优化 2024-12-17 阅读0 评论0

大数据刘海,介绍互联网时代的隐私防线

随着互联网的快速发展,大数据时代已经来临。在这个时代,个人信息被广泛收集、分析和利用,而大数据刘海作为一种新型的隐私保护技术,逐渐...

SEO优化 2024-12-17 阅读0 评论0