安装nginx
1)配置官方源
1 2 3 4 5 6 7 8 |
[root@web01 ~]# vim /etc/yum.repos.d/nginx.repo [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true |
2)安装nginx
1 |
[root@web01 ~]# yum install -y nginx |
3)配置nginx
1 2 |
[root@web01 ~]# vim /etc/nginx/nginx.conf user www; |
4)添加用户
1 2 |
[root@web01 ~]# groupadd www -g 666 [root@web01 ~]# useradd www -u 666 -g 666 |
5)启动服务
1 2 3 |
[root@web01 ~]# systemctl start nginx [root@web01 ~]# systemctl enable nginx Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service. |
6)验证
1 |
[root@web01 ~]# ps -ef | grep nginx |
安装php (7版本)
1)配置第三方源
1 2 3 4 5 |
[root@web01 ~]# vim /etc/yum.repos.d/php.repo [php-webtatic] name = PHP Repository baseurl = http://us-east.repo.webtatic.com/yum/el7/x86_64/ gpgcheck = 0 |
2)卸载旧版本
1 |
[root@web01 ~]# yum remove php-mysql-5.4 php php-fpm php-common |
3)安装php
1 |
[root@web01 ~]# 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 |
4)安装方式二
1 2 3 4 5 6 7 8 9 |
#创建存放服务包的目录 [root@web01 ~]# mkdir /package [root@web01 ~]# cd /package/ #上传包 [root@web01 /package]# rz php.tar.gz #解压包 [root@web01 /package]# tar xf php.tar.gz #安装所有rpm包 [root@web01 /package]# yum localinstall -y *.rpm |
5)配置PHP
1 2 3 |
[root@web01 /package]# vim /etc/php-fpm.d/www.conf user = www group = www |
6)启动服务
1 2 |
[root@web01 /package]# systemctl start php-fpm [root@web01 /package]# systemctl enable php-fpm |
7)验证启动
1 2 3 4 |
[root@web01 /package]# ps -ef | grep php [root@web01 /package]# netstat -lntp tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 7748/php-fpm: master |
搭建wordpress
1)创建站点目录
1 |
[root@web01 ~]# mkdir /code -p |
2) 上传代码
1 2 |
[root@web01 ~]# cd /code/ [root@web01 /code]# rz wordpress-5.0.3-zh_CN.tar.gz |
3) 解压代码包
1 |
[root@web01 /code]# tar xf wordpress-5.0.3-zh_CN.tar.gz |
4)授权
1 |
[root@web01 /code/zuoye]# chown -R www.www /code/ |
5)配置nginx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[root@web01 /code]# vim /etc/nginx/conf.d/linux.blog.com.conf server { listen 80; server_name linux.blog.com; location / { root /code/wordpress; index index.php; } location ~* \.php$ { root /code/wordpress; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } |
搭建mariadb
1)安装
1 |
[root@web01 /code/zuoye]# yum install -y mariadb-server |
2)启动服务
1 2 |
[root@web01 /code/zuoye]# systemctl start mariadb [root@web01 /code/zuoye]# systemctl enable mariadb |
3)验证
1 2 |
[root@web01 /code/zuoye]# netstat -lntp tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 9887/mysqld |
4)连接
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
[root@web01 /code/zuoye]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 5.5.65-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)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.00 sec) |
5)设置数据库密码
1 2 3 4 5 6 |
#设置密码 [root@web01 /code/zuoye]# mysqladmin -u root password "123" #使用密码连接 [root@web01 /code/zuoye]# mysql -u root -p Enter password:123 |
6)创建数据库
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
[root@web01 /code]# mysql -uroot -p123 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 3 Server version: 5.5.65-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 blog; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | blog | | mysql | | performance_schema | | test | +--------------------+ 5 rows in set (0.00 sec) |
重启访问
1 2 3 4 5 6 7 8 |
#重启nginx [root@web01 /code]# systemctl restart nginx #配置本地hosts 10.0.0.7 linux.blog.com #访问 http://linux.blog.com |