php lamp架构,lamp架构搭建

lamp架构搭建(yum)

环境:一台主机,centos7.5

lamp安装

yum -y install httpd php-fpm php-mysql mariadb-server

启动php-fpm服务

systemctl start php-fpm

配置httpd生成配置文件,提示http,php-fpm服务在本地

vim /etc/httpd/conf.d/fcgi.conf

DirectoryIndex index.php

ProxyRequests Off

ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/$1

注意:在HTTPD服务器上必须启用proxy_fcgi_module模块,充当PHP客户端

httpd –M |grep fcgi

cat /etc/httpd/conf.modules.d/00-proxy.conf

启动服务

systemctl restart httpd mariadb

编辑测试页面,测试

vim /var/www/html/index.php

$dsn=’mysql:host=localhost;dbname=mysql’;

$username=’root’;

$passwd=”;

$dbh=new PDO($dsn,$username,$passwd);

var_dump($dbh);

?>

lamp搭建(yum)

环境:三台主机,centos7.5

host1:192.168.67.110   httpd

host2:192.168.67.111   php-fpm php-mysql

host3:192.168.67.112   mariadb-server

在host1上安装httpd;host2上安装php-fpm;host3上安装mariadb-server

host1: yum -y install httpd

host2:yum -y install php-fpm php-mysql

host3: yum -y install mariadb-server

host3:启动mariadb,创建用户,允许远程连接

systemctl start mariadb

MariaDB [(none)]> grant all on *.* to test@’192.168.67.%’ identified by ‘aa12345’;

host2:编辑配置文件/etc/php-fpm.d/www.conf,并启动服务

3c8ce6380daa33c267ccb0e2e66a02de.png

systemctl start php-fpm

host1:生成配置文件,重启

vim /etc/httpd/conf.d/fcgi.conf

3c8ce6380daa33c267ccb0e2e66a02de.png

systemctl restart httpd

host2:根据host1配置,创建放置.php后缀文件目录

mkdir /data/www

host2:在网页目录下创建测试文件

vim /data/www/index.php

3c8ce6380daa33c267ccb0e2e66a02de.png

基于lamp(yum)搭建论坛

安装环境:2台主机,系统centos7.5

安装包: Discuz_X3.2_SC_UTF8.zip

host1:192.168.67.110   httpd php-fpm php-mysql

host2:192.168.67.111   mariadb-server

host1:安装httpd,php-fpm php-mysql; host2:安装mariadb-server

yum -y install httpd php-fpm php-mysql

yum -y install mariadb-server

host2:启动mariadb服务,并且创建远程连接用户

systemctl start mariadb

MariaDB [(none)]> grant all on *.* to test@’192.168.67.%’ identified by ‘aa12345’;

host1:生成配置文件,重启

vim /etc/httpd/conf.d/fcgi.conf

DirectoryIndex index.php

ProxyRequests Off

ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/$1

systemctl restart httpd

systemctl restart php-fpm

解压安装包2_SC_UTF8.zip,并把页面文件放置到/var/www/html/下

unzip Discuz_X3.2_SC_UTF8.zip

mv upload/* /var/www/html/

授权apache用户使其对/var/www/html/目录有写权限

setfacl -R -m u:apache:rwx /var/www/html/

在客户端配置安装

192.168.67.110/install/index.php

3c8ce6380daa33c267ccb0e2e66a02de.png

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/101652

你可能感兴趣的:(php,lamp架构)