部署lamp
[root@kongbai ~]# yum -y install httpd*
[root@kongbai ~]# yum -y install mariadb*
[root@kongbai ~]# yum -y install php*
[root@kongbai ~]# cd /etc/httpd/conf.d
[root@kongbai conf.d]# ls
autoindex.conf manual.conf php.conf README userdir.conf welcome.conf
[root@kongbai conf.d]# cp /usr/share/doc/httpd/httpd-vhosts.conf .
[root@kongbai conf.d]# ls
autoindex.conf httpd-vhosts.conf manual.conf php.conf README userdir.conf welcome.conf
[root@kongbai conf.d]# vim httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/var/www/html"
ServerName www.example.com
</VirtualHost>
[root@kongbai conf.d]# systemctl start httpd
[root@kongbai conf.d]# systemctl stop firewalld
[root@kongbai conf.d]# setenforce 0
[root@kongbai conf.d]# getenforce
Permissive
[root@kongbai conf.d]# cd /var/www/html/
[root@kongbai html]# ls
[root@kongbai html]# echo 'hello word' >index.html
[root@kongbai html]# pwd
/var/www/html
打开网页输入IP地址就可以看到 hello word
[root@kongbai html]# cd /etc/httpd/conf.d
[root@kongbai conf.d]# vim httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/var/www/html"
ServerName www.example.com
(添加)
ProxyRequests Off
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/$1
<Directory "/var/www/html">
Options none
AllowOverride none
Require all granted
</Directory>
</VirtualHost>
[root@kongbai ~]# cd /etc/httpd
[root@kongbai httpd]# vim conf/httpd.conf
输入/AddTyoe,
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
在后面添加: AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
然后输入/index.html
在中间添加 DirectoryIndex (index.php) index.html
双击Esc 输入:wq保存
[root@kongbai httpd]# systemctl restart httpd
[root@kongbai httpd]# ss -antl
State Recv-Q Send-Q Local Address:Port
LISTEN 0 128 0.0.0.0:22
LISTEN 0 128 *:80
LISTEN 0 128 [::]:22
[root@kongbai httpd]# systemctl start mariadb
[root@kongbai httpd]# systemctl start php-fpm
[root@kongbai httpd]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2021-07-21 14:47:51 CST; 9min ago
Main PID: 24731 (php-fpm)
[root@kongbai httpd]# vim /etc/php-fpm.d/www.conf
输入/listen
在前面先输一个分号 ;listen = /run/php-fpm/www.sock
在后面一排加入ip端口号 listen = 127.0.0.1:9000
退出保存
[root@kongbai httpd]# systemctl restart php-fpm
[root@kongbai httpd]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2021-07-21 14:58:50 CST; 3s ago
Main PID: 25446 (php-fpm)
[root@kongbai httpd]# cd /var/www/html/
[root@kongbai html]# ls
index.html
[root@kongbai html]# vim index.php
<?php
phpinfo();
?>
[root@kongbai html]# ls
index.html index.php
[root@kongbai html]# mysql
MariaDB [(none)]> set password=password ("yongwangwuqian");
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> grant all on *.* to 'root'@'192.168.191.140'identified by 'yongwangwuqian';
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)
MariaDB [(none)]> create database yigejuhao;
Query OK, 1 row affected (0.001 sec)
MariaDB [(none)]> exit
Bye
[root@kongbai html]# ls
index.html index.php
|