安装nginx
yum makecache
[root@hecs-98663 ~]# yum list | grep nginx
nginx.x86_64 1:1.24.0-1.el7.ngx @nginx-stable
yum install -y nginx
systemctl start nginx
php的rpm部署
#php-fpm php接收动态请求的程序 PHP-FPM(FastCGI Process Manager):FastCGI进程管理器
#php-mysql php链接mysql的程序
#php-gd 图形库程序(GD库可以处理图片,或者生产图片)
[root@hecs-98663 myshell]# yum install -y php-fpm php-mysql php-gd
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
软件包 php-fpm-5.4.16-48.el7.x86_64 已安装并且是最新版本
软件包 php-mysql-5.4.16-48.el7.x86_64 已安装并且是最新版本
软件包 php-gd-5.4.16-48.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@hecs-98663 myshell]# systemctl restart php-fpm
[root@hecs-98663 myshell]# systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
查看端口
[root@hecs-98663 myshell]# netstat -anpt
[root@hecs-98663 myshell]# ss -anpt
[root@hecs-98663 myshell]# ss -anpt | grep 9000
LISTEN 0 128 127.0.0.1:9000 *:* users:(("php-fpm",pid=18412,fd=0),("php-fpm",pid=18411,fd=0),("php-fpm",pid=18410,fd=0),("php-fpm",pid=18409,fd=0),("php-fpm",pid=18408,fd=0),("php-fpm",pid=18406,fd=6))
测试php
[root@hecs-98663 myshell]# vim /usr/share/nginx/html/index.php
[root@hecs-98663 myshell]# cat /usr/share/nginx/html/index.php
<?php
phpinfo();
?>
>>>
vim /etc/nginx/conf.d/default.conf
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
systemctl reload nginx
访问ip地址
nginx中配置php
location ~ \.php$ {
root /usr/share/nginx/html;
# 设置监听端口
fastcgi_pass 127.0.0.1:9000;
# 设置nginx的默认首页文件(上面已经设置过了,可以删除)
fastcgi_index index.php;
# 设置脚本文件请求的路径
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# 引入fastcgi的配置文件
include fastcgi_params;
}
数据库部署
[root@hecs-98663 ~]# yum install -y mariadb-server mariadb
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
软件包 1:mariadb-server-5.5.68-1.el7.x86_64 已安装并且是最新版本
软件包 1:mariadb-5.5.68-1.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@hecs-98663 ~]# systemctl start mariadb
[root@hecs-98663 ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
数据库配置
[root@hecs-98663 ~]# mysqladmin password "123456"
[root@hecs-98663 ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database bbs;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on bbs.* to chris@"%" identified by "123456";
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
测试数据库与php的连接
<?php
$link=mysql_connect("123.60.106.47","chris","123456");
if($link)
echo "success";
else
echo "fail";
mysql_close();
?>
上传app
wget https://cn.wordpress.org/wordpress-4.9.1-zh_CN.zip
unzip wordpress-4.9.1-zh_CN.zip
[root@hecs-98663 ~]# ls wordpress
index.php wp-admin wp-content wp-load.php wp-signup.php
license.txt wp-blog-header.php wp-cron.php wp-login.php wp-trackback.php
readme.html wp-comments-post.php wp-includes wp-mail.php xmlrpc.php
wp-activate.php wp-config-sample.php wp-links-opml.php wp-settings.php
[root@hecs-98663 ~]# rm -rf /usr/share/nginx/html/index.php
[root@hecs-98663 ~]# cp -rf wordpress/* /usr/share/nginx/html/
[root@hecs-98663 ~]# chown -R nginx.nginx /usr/share/nginx/html/*
[root@hecs-98663 ~]# chmod 777 /usr/share/nginx/html/*