yum install nginx
systemctl start nginx
systemctl restart nginx
如果不能安装请看:nginx服务器搭建
yum install php-fpm
user = nginx 39行
group = nginx 41行
;cgi.fix_pathinfo=1 修改为 cgi.fix_pathinfo=0
systemctl start php-fpm.service
location ~\.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php,phpinfo.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
将内容复制到nginx.conf中,效果如下:
第一个location是原先就有的,
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
yum install mariadb mariadb-server mariadb-libs mariadb-devel
rpm -qa |grep maria
systemctl start mariadb
systemctl enable mariadb
systemctl status mariadb
mysql_secure_installation
Enter current password for root (enter for none): 敲回车键
Set root password? [Y/n] 按Y键
New password: 123456(真实环境中设置复杂密码)
Re-enter new password: 123456
Remove anonymous users? [Y/n] n
Disallow root login remotely?[Y/n] n
Remove test database and access to it? [Y/n] n
Reload privilege tables now? [Y/n] n
数据库基本操作
MariaDB [(none)]> mariadb的命令操作提示符
MariaDB [(none)]> show databases; 查看有哪些数据库
[(none)]> use mysql; 选择数据库
MariaDB [mysql]> show tables; 查看数据库中的表
MariaDB [mysql]> select * from 表名 查询表中所有数据
MariaDB [mysql]> select user,password from 表名 只查询表中usr与password字段的内容。
MariaDB [mysql]> exit 退出
[root@teacher mnt]# mysqldump couman --user=root --password=123456>db-01.mysql; 将couman数据库备份到当前目录下,叫db-01.mysql
首先创建一个空数据库存
MariaDB [(none)]> create database couman;
Query OK, 1 row affected (0.00 sec)
MariaDB [mysql]> exit 退出
[root@teacher mnt]# mysql -u root -p couman
vim /etc/hosts
添加:
192.168.161.131 www.book.com
192.168.161.131 www.anxing.com
mkdir /data
vim /etc/nginx/nginx.conf
末尾"}"之前添加:
include vhost/*.conf
mkdir /etc/nginx/vhost
cd /etc/nginx/vhost
vim book.conf
server{
listen 192.168.161.131:80;
server_name www.book.com;
location / {
root /data/book;
Index index.html index.php;
}
location ~ \.php$ {
root /data/book;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
vim anxing.com
server{
listen 192.168.161.131:80;
server_name www.anxing.com;
location / {
root /data/anxing;
Index index.html index.php;
}
location ~ \.php$ {
root /data/anxing;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
systemctl restart nginx
systemctl restart php-fpm
systemctl restart mariadb
systemctl stop firewalld
setenforce 0
配置多个网站,不同域名访问