搭建wecenter网站www.gcy.com
1.部署nginx
参见web服务部署nginx过程,修改配置文件
[root@test01 conf]# vim conf.d/blog.conf
server {
listen 80;
server_name blog.wsm.com;
location / {
root html/gcy;
index index.php index.html index.htm;
}
location ~* \.(php|php5)$ { #添加location 匹配正则 以.php .php5结尾
root html/blog; #站点目录
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
2.部署MySQL
启动mariadb
systemctl start mariadb
- 创建数据库
create database wecenter; - 添加用户
MariaDB [(none)]> grant all on wecenter.* to wecenter@'172.16.1.%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all on wecenter.* to wecenter@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
- 查看用户
select user,host from mysql.user;
MariaDB [(none)]> selet user, host from mysql.user;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'selet user, host from mysql.user' at line 1
MariaDB [(none)]> select user, host from mysql.user;
+-----------+------------+
| user | host |
+-----------+------------+
| root | 127.0.0.1 |
| wecenter | 172.16.1.% |
| wordpress | 172.16.1.% |
| root | ::1 |
| root | localhost |
| wecenter | localhost |
| wordpress | localhost |
| root | web |
+-----------+------------+
8 rows in set (0.00 sec)
- 更新一下权限信息
flush privileges ;
3.部署PHP
先配置php yum源安装
yum remove php-mysql-5.4 php php-fpm php-common #移除系统中已存在的数据库及php等
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
- 安装以下工具
yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb
- 修改php-fpm.d配置文件
[root@test01 ~]# vim /etc/php-fpm.d/www.conf
[root@test01 ~]# grep -n '=.www' /etc/php-fpm.d/www.conf
8:user = www
10:group = www
- systemctl restart php-fpm 重启
检查端口与进程,端口为9000
[root@test01 ~]# ss -lntup |grep php-fpm
tcp LISTEN 0 128 127.0.0.1:9000 *:* users:(("php-fpm",pid=32779,fd=9),("php-fpm",pid=32778,fd=9),("php-fpm",pid=32777,fd=9),("php-fpm",pid=32776,fd=9),("php-fpm",pid=32775,fd=9),("php-fpm",pid=32774,fd=7))
[root@test01 ~]# ps -ef |grep php
root 32774 1 0 06:37 ? 00:00:00 php-fpm: master process (/etc/php-fpm.conf)
www 32775 32774 0 06:37 ? 00:00:00 php-fpm: pool www
www 32776 32774 0 06:37 ? 00:00:00 php-fpm: pool www
www 32777 32774 0 06:37 ? 00:00:00 php-fpm: pool www
www 32778 32774 0 06:37 ? 00:00:00 php-fpm: pool www
www 32779 32774 0 06:37 ? 00:00:00 php-fpm: pool www
root 32785 11511 0 06:39 pts/1 00:00:00 grep --color=auto php
4.联合测试
- 测试nginx是否正常-静态
[root@test01 conf]# curl -H Host:www.gcy.com 10.0.0.7
love gcy
- 测试php是否正常-显示动态 nginx + php
写入一个测试文件
[root@test01 blog]# cat /application/nginx-1.14.2/html/gcy/info.php
<?php
phpinfo();
?>
浏览器访问www.gcy.com/info.php显示页面
图片.png
表示成功
- 测试php与mariadb
写入一个测试文件
[root@web01 blog]#cat /application/nginx-1.14.2/html/blog/mysql.php
<?php
$servername = "localhost";
$username = "wecenter";
$password = "123456";
// 创建连接
$conn = mysqli_connect($servername, $username, $password);
// 检测连接
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "php连接MySQL数据库成功";
?>
浏览器访问www.gcy.com/mysql.php显示页面
图片.png
########LNMP部署完成########
- 下载wecenter 搭建网站 放入程序代码
unzip -d WeCenter WeCenter_3-3-2.zip
mv WeCenter/* /application/nginx/html/gcy/
chown -R www.www /application/nginx/html/gcy/
- 浏览器访问www.gcy.com
![]()
跳转到此页面
填写信息成功访问
图片.png
显示数据库内容
MariaDB [(none)]> show tables from wecenter;
+-----------------------------------+
| Tables_in_wecenter |
+-----------------------------------+
| aws_gcyactive_data |
| aws_gcyanswer |
| aws_gcyanswer_comments |
| aws_gcyanswer_thanks |
| aws_gcyanswer_uninterested |
| aws_gcyanswer_vote |
| aws_gcyapproval |
| aws_gcyarticle |
...
网友评论