博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
lnmp搭建测试
阅读量:5249 次
发布时间:2019-06-14

本文共 19825 字,大约阅读时间需要 66 分钟。

lnmp安装及排错

 

标签(空格分隔)

 

nginx已安装就在演示啦//

 

lnmp安装及排错

nginx已安装就在演示啦//

安装MySQL数据库

Debian or Ubuntu使用下面的安装命令

安装MySQL数据库

 

安装过程:

 

列表项

这里安装mysql的二进制包相对较简单写

[root@www ~]# groupadd mysql#建组

[root@www ~]# useradd -s /sbin/nologin -g mysql -M mysql

[root@www ~]# tail -1 /etc/passwd

mysql:x:1001:1001::/home/mysql:/sbin/nologin

[root@localhost ~]# id mysql

uid=1001(mysql) gid=1001(mysql) groups=1001(mysql)

---以上只要正确就好不用一样

 

[root@www ~]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz -C /usr/local/

[root@www ~]# cd /usr/local/

[root@localhost local]# mv mysql-5.5.32-linux2.6-x86_64 mysql-5.5.32

[root@www local]# ln -s mysql-5.5.32 mysql

[root@localhost local]# ls

bin  games    lib    libexec  mysql-5.5.32  nginx-1.10.2  share

etc  include  lib64  mysql    nginx         sbin          src

[root@www local]# cd /usr/local/mysql

[root@www mysql]# ls

bin      data  include         lib  mysql-test  scripts  sql-bench

COPYING  docs  INSTALL-BINARY  man  README      share    support-files

二进制安装

 

[root@localhost ~]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz -C /usr/local/

[root@localhost ~]# cd /usr/local/

[root@localhost local]# mv mysql-5.5.32-linux2.6-x86_64 mysql-5.5.32

[root@localhost local]# ln -s mysql-5.5.32 mysql

[root@localhost local]# ls

bin  games    lib    libexec  mysql-5.5.32  nginx-1.10.2  share

etc  include  lib64  mysql    nginx         sbin          src

[root@localhost local]# cd /usr/local/mysql

[root@localhost mysql]# ls

bin      data  include         lib  mysql-test  scripts  sql-bench

COPYING  docs  INSTALL-BINARY  man  README      share    support-files

初始化MySQL配置文件my.conf

 

[root@localhost ~]# cd /usr/local/mysql

[root@localhost mysql]# ls -l support-files/*.cnf

-rw-r--r--. 1 7161 wheel  4691 Jun 19  2013 support-files/my-huge.cnf

-rw-r--r--. 1 7161 wheel 19759 Jun 19  2013 support-files/my-innodb-heavy-4G.cnf

-rw-r--r--. 1 7161 wheel  4665 Jun 19  2013 support-files/my-large.cnf

-rw-r--r--. 1 7161 wheel  4676 Jun 19  2013 support-files/my-medium.cnf

-rw-r--r--. 1 7161 wheel  2840 Jun 19  2013 support-files/my-small.cnf

[root@localhost mysql]# /bin/cp support-files/my-small.cnf /etc/my.cnf

提示:

 

support-files下有my.cnf的各种配置样例。

使用cp全路径/bin/cp,可实现拷贝而不出现替换提示,即如果有重名文件会直接覆盖

本例为测试安装环境,因此选择参数配置小的my-small.cnf配置模版,如果是生产环境可以根据硬件选择更高级的配置文件,上述配置文件模版对硬件的要求从低到高依次为:

5初始化MySQL数据库

 

[root@localhost ~]# mkdir -p /usr/local/mysql/data #建立MySQL数据文件目录

[root@localhost ~]# chown -R mysql.mysql /usr/local/mysql #授权mysql用户管理MySQL的安装目录

[root@localhost ~]# yum -y install libaio #光盘源安装依赖包,否则下一步的编译会报错

[root@localhost ~]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql

#初始化MySQL数据库文件,会有很多信息提示,如果没有ERROR级别的错误,会有两个OK的字样,表示初始化成功,否则就要解决初始化的问题

初始化如下:

Installing MySQL system tables...

OK

Filling help tables...

OK

配置并启动Mysql数据库

 

[root@localhost mysql]# cp support-files/mysql.server /etc/init.d/mysqld

#拷贝MySQL启动脚本到MySQL的命令路径

[root@localhost mysql]# chmod +x /etc/init.d/mysqld

#使脚本可执行

[root@localhost mysql]# /etc/init.d/mysqld start

Starting MySQL.. SUCCESS!

成功

- 检查MySQL舒服成功命令如下:

[root@localhost mysql]# netstat -antup | grep mysql

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1702/mysqld 

- 加入开机自启动

[root@localhost mysql]# chkconfig --add mysqld

[root@localhost mysql]# chkconfig mysqld on

[root@localhost mysql]# chkconfig --list mysqld

mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

- 也可以将启动命令/etc/init.d/mysqld start 放到/etc/rc.local里面

7 配置 MySQL命令的全局使用路径:

[root@localhost mysql]# ln -s   /usr/local/mysql/bin/* /usr/local/bin/

[root@localhost mysql]# which mysqladmin

/usr/local/bin/mysqladmin

8登陆测试一下

root@localhost mysql]# mysql   #直接输入命令即可登陆

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.5.32 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;    #查看当前所有的数据库

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

4 rows in set (0.00 sec)

mysql> select user();   #查看当前的登陆用户

+----------------+

| user()         |

+----------------+

| root@localhost |

+----------------+

1 row in set (0.00 sec)

mysql> quit

Bye

    提示:

    MySQL安装完成以后,默认情况下,root账户是无密码的,这个必须要设置。

MySQL安全配置

 

为MySQL设置密码,

```

[root@localhost mysql]# mysqladmin -u root password '123123' #设置密码

[root@localhost mysql]# mysql #无法直接登陆了

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

[root@localhost mysql]# mysql -uroot -p #新的登陆方式

Enter password: #输入设置的密码

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 5

Server version: 5.5.32 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

 

##**lnmp之php服务安装和准备**

 1.检查nginx和MySQL的安装情况

 ```

 [root@localhost ~]# ls -ld /usr/local/nginx

lrwxrwxrwx. 1 root root 24 Jul  9 14:31 /usr/local/nginx -> /usr/local/nginx-1.10.2/

[root@localhost ~]# ls -ld /usr/local/mysql

lrwxrwxrwx. 1 mysql mysql 12 Jul 14 07:13 /usr/local/mysql -> mysql-5.5.32

 ```

 2检查端口及启动情况

 ```

 [root@localhost ~]# netstat -antup | grep -E "80|3306"

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1193/nginx         

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1702/mysqld

 ```

 3 测访问nginx及mysql的成功情况

 ```

 root@localhost ~]# wget 127.0.0.1    #测试Nginx

--2017-07-14 09:54:12--  http://127.0.0.1/

Connecting to 127.0.0.1:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 624 [text/html]

Saving to: “index.html”

100%[=========================================================================================>] 624         --.-K/s   in 0s     

2017-07-14 09:54:12 (2.12 MB/s) - “index.html” saved [624/624]

[root@localhost ~]# mysql -uroot -p    #测试MySQL

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.5.32 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement

mysql> quit

Bye

 ```

以上访问一切正常

-检查安装php所需的lib库

 

```[root@localhost ~]# yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel

[root@localhost ~]# yum -y install freetype-devel libpng-devel gd libcurl-devel libxslt-devel

 

安装结果如下:

<div class="md-section-divider"></div>

```[root@localhost ~]# rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel

zlib-devel-1.2.3-29.el6.x86_64

libxml2-devel-2.7.6-14.el6.x86_64

libjpeg-turbo-devel-1.2.1-1.el6.x86_64

#这里仅缺少libiconv-devel包

[root@localhost ~]# rpm -qa freetype-devel libpng-devel gd libcurl-devel libxslt-devel

freetype-devel-2.3.11-14.el6_3.1.x86_64

libpng-devel-1.2.49-1.el6_2.x86_64

libcurl-devel-7.19.7-37.el6_4.x86_64

libxslt-devel-1.1.26-2.el6_3.1.x86_64

gd-2.0.35-11.el6.x86_64

注意:yum无法安装libicom库wget要向安装上

 

root@localhost ~]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

[root@localhost ~]# ls

anaconda-ks.cfg  install.log         libiconv-1.14.tar.gz                 nginx-1.10.2.tar.gz

index.html       install.log.syslog  mysql-5.5.32-linux2.6-x86_64.tar.gz

[root@localhost ~]# tar xf libiconv-1.14.tar.gz -C /usr/src/

[root@localhost ~]# cd /usr/src/libiconv-1.14/

[root@localhost libiconv-1.14]# ./configure --prefix=/usr/local/libiconv && make && make install

安装libmcrypt库

 

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

编译安装:yum -y clean all && yum makecache

[root@localhost yum.repos.d]# yum -y install libmcrypt-devel

2安装mhash

 

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

编译安装过程略

[root@localhost yum.repos.d]# yum -y install mhash

3,安装mcrvpt加密扩展库

 

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

编译安装过程略

[root@localhost yum.repos.d]# yum -y install mcrypt

 

开始安装php服务(fastcgi)

获取php包

root@localhost ~]# wget http://cn2.php.net/get/php-5.3.28.tar.gz/from/this/mirror

 

这里解压并配置php软件按包

在此输入正文

./configure --prefix=/usr/local/php5.3.28 --with-mysql=/usr/local/mysql --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-short-tags --enable-zend-multibyte --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-ftp

 

注意这里可能因网络或其他原因会丢包报错

configure: error: Please reinstall the libcurl distribution -

easy.h should be in /include/curl/

解决方法:# RetHat CentOS or Fedora 使用下面安装命令

yum install curl curl-devel

Debian or Ubuntu使用下面的安装命令

 

apt-get install curl

apt-get install libcurl4-gnutls-dev

 

出现 thank you for using PHP

成功

解释:

[x] :--prefix=/usr/local/php5.2.28

 

表示指定PHP的安装路径为/usr/local/php5.3.28

 

[x] :--with-mysql=/usr/local/mysql

 

表示需要指定MySQL的安装路径,安装PHP需要的MySQL相关内容。当然,如果没有MySQL软件包,也可以不单独安装,这样的情况可使用--with-mysql=mysqlnd替代--with-mysql=/usr/local/mysql,因为PHP软件里已经自带了连接MySQL的客户端工具。

 

[x] :--with-fpm-user=www

 

nginx表示指定PHP-FPM进程管理的用户为www,此处最好和Nginx服务用户统一

 

[x] : --with-fpm-group=www

 

表示指定PHP-FPM进程管理的组为www,此处最好与Nginx服务用户组统一。

 

[x] :--enable-fpm

 

表示激活PHP-FPM方式服务,即以FastCGIF方式运行PHP服务。

编译PHP

 

[root@localhost php-5.3.28]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18

libmysqlclient.so.18      libmysqlclient.so.18.0.0 

[root@localhost php-5.3.28]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/

[root@localhost php-5.3.28]# touch ext/phar/phar.phar

[root@localhost php-5.3.28]# make

#make最后的正确提示

Build complete.

Don't forget to run 'make test'.

安装PHP生成文件系统

 

[root@localhost php-5.3.28]# make install

配置PHP引擎配置文件按PHP.INI

 

[root@localhost ~]# ln -s /usr/local/php5.3.28/ /usr/local/php

[root@localhost ~]# ls -l /usr/local/php

lrwxrwxrwx. 1 root root 21 Jul 14 13:06 /usr/local/php -> /usr/local/php5.3.28/

--查看PHP配置模板文件

[root@localhost ~]# cd /usr/src/php-5.3.28/

[root@localhost php-5.3.28]# ls php.ini*

php.ini-development  php.ini-production

--拷贝php配置文件到php默认目录,并更改文件名为php.ini命令如下:

[root@localhost php-5.3.28]# cp php.ini-production /usr/local/php/lib/php.ini

[root@localhost php-5.3.28]# ls -l /usr/local/php/lib/php.ini

-rw-r--r--. 1 root root 69627 Jul 14 13:25 /usr/local/php/lib/php.ini

配置PHP(fastcgi方式)的配置文件php-fpm.conf

 

[root@localhost php-5.3.28]# cp php.ini-production /usr/local/php/lib/php.ini

[root@localhost php-5.3.28]# ls -l /usr/local/php/lib/php.ini

-rw-r--r--. 1 root root 69627 Jul 14 13:25 /usr/local/php/lib/php.ini

[root@localhost php-5.3.28]# cd /usr/local/php/etc/

[root@localhost etc]# ls

pear.conf  php-fpm.conf.default

[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf

启动php服务(fastcgi方式)

1启动php服务php-fpm命令如下;

 

/usr/local/php/sbin/php-fpm

2检查php服务php-fpm进程及启动端口的情况。命令;

 

[root@localhost etc]# ps -ef | grep php-fpm

root     126611      1  0 13:36 ?        00:00:00 php-fpm: master process (/usr/local/php5.3.28/etc/php-fpm.conf)

nginx    126612 126611  0 13:36 ?        00:00:00 php-fpm: pool www         

nginx    126613 126611  0 13:36 ?        00:00:00 php-fpm: pool www         

root     126619 126548  0 13:39 pts/1    00:00:00 grep php-fpm

[root@localhost etc]# lsof -i:9000  #默认9000端口提供服务

COMMAND    PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

php-fpm 126611  root    7u  IPv4 136041      0t0  TCP localhost:cslistener (LISTEN)

php-fpm 126612 nginx    0u  IPv4 136041      0t0  TCP localhost:cslistener (LISTEN)

php-fpm 126613 nginx    0u  IPv4 136041      0t0  TCP localhost:cslistener (LISTEN)

--配置nginx支持php程序请求访问

1修改nginx配置文件

-1查看nginx当前的配置,命令:

 

 

[root@localhost etc]# cd /usr/local/nginx/conf/

[root@localhost conf]# cp nginx.conf nginx.conf.02

[root@localhost conf]# cat nginx.conf

worker_processes 1;

error_log logs/error.log;

events {

worker_connections 1024;

}

http {

include mime.types;

default_type application/octet-stream;

sendfile on;

keepalive_timeout 65;

include extra/www.conf;

include extra/mail.conf;

include extra/status.conf;

include extra/blog.conf;

}

 

模板我就用的比较简单

 

[root@localhost conf]# cat extra/blog.conf

server {

listen 80;

server_name blog.yunjisuan.com;

location / {

root html;

index index.html index.htm;

}

location ~ .*\.(php|php5)?$ {

root html/bbs;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

include fastcgi.conf;

}

}

 

检查启动nginx

 

[root@localhost conf]# /usr/local/nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx-1.10.2//conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx-1.10.2//conf/nginx.conf test is successful

[root@localhost conf]# /usr/local/nginx/sbin/nginx -s reload

 

----做好每一步的万无一失,尽量减免在工作中失误带来的不好影响--

 

测试php解析请求是否可以

-1进入指定默认站点目录后。编辑index.php

 

[root@localhost conf]# cd /var/www/html/blogcom/

[root@localhost blogcom]# echo "<?php phpinfo(); ?>" >test_info.php

[root@localhost blogcom]# cat test_info.php

<?php phpinfo(); ?>

 

调整windows下的host解析

 

192.168.226.142 www.tian.com bbs.tian.com

 

打开浏览器输入“网址域名”测试:

PHP version 5.3.28 字样开头图片即为nginx配合php解析正常。

2针对nginx请求访问php,然后对MySQL、进行测试

编辑内容如下

 

[root@localhost blogcom]# cat test_mysql.php

<?php

//$link_id=mysql_connect('主机名','用户','密码'); $link_id=mysql_connect('localhost','root','123123');

if($link_id){

echo "mysql successful by A-tian!";

}else{

echo mysql_error();

}

?>

 

测试在浏览器上输入进行测试

---mysql successful by A-tian!---成功

部署一个程序服务

1开源博客程序Wordpress单人用户博客,与51cto.com多用户博客不一样

----创建一个专用的数据库wordpress,用于存放博客数据:

 

mysql -uroot -p密码

mysql> create database wordpress;   #创建一个数据库,名字为wordpress

Query OK, 1 row affected (0.00 sec)

mysql> show databases like 'wordpress';  #查看

+----------------------+

| Database (wordpress) |

+----------------------+

| wordpress            |

+----------------------+

1 row in set (0.00 sec)

创建一个专用的worpress 管理用户

 

mysql> grant all on wordpress.* to wordpress@'localhost' identified by '123123';                    #localhost为客户端地址

Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;            #刷新权限,使得创建用户生效

Query OK, 0 rows affected (0.00 sec)

mysql> show grants for wordpress@'localhost';   #查看用户对应权限

+------------------------------------------------------------------------------------------------------------------+

| Grants for wordpress@localhost                                                                                   |

+------------------------------------------------------------------------------------------------------------------+

| GRANT USAGE ON *.* TO 'wordpress'@'localhost' IDENTIFIED BY PASSWORD '*E56A114692FE0DE073F9A1DD68A00EEB9703F3F1' |

| GRANT ALL PRIVILEGES ON `wordpress`.* TO 'wordpress'@'localhost'                                                 |

+------------------------------------------------------------------------------------------------------------------+

2 rows in set (0.00 sec)

mysql> select user,host from mysql.user;        #查看数据库里创建的wordpress用户

+-----------+-----------+

| user      | host      |

+-----------+-----------+

| root      | 127.0.0.1 |

| root      | localhost |

| wordpress | localhost |   #只允许本机通过wordpress用户访问数据库

+-----------+-----------+

3 rows in set (0.00 sec)

mysql> quit

nginx及php环境配置准备

选择配置好的支持lnmp的域名对应的主机,命令:

 

[root@localhost extra]# cat blog.conf

    server {

        listen       80;

        server_name  bbs.tian.com;

        location / {

            root   html/bbs;

            index  index.php index.html index.htm;  #补充一个首页文件index.php

        }

        location ~ .*\.(php|php5)?$ {

            root    html/bbs;

            fastcgi_pass    127.0.0.1:9000;

            fastcgi_index   index.php;

            include     fastcgi.conf;

        }

    }

[root@localhost extra]# /usr/local/nginx/sbin/nginx -s reload

--获取WordPress博客程序,并放置到blog域名对应虚拟主机的站点目录下

 

[root@localhost blogcom]# ls   #浏览www.wordpress.org下载博客程序

index.html  test_info.php  test_mysql.php  wordpress-4.7.4-zh_CN.tar.gz

[root@localhost blogcom]# tar xf wordpress-4.7.4-zh_CN.tar.gz #解压

[root@localhost blogcom]# ls

index.html  test_info.php  test_mysql.php  wordpress  wordpress-4.7.4-zh_CN.tar.gz

[root@localhost blogcom]# rm -f index.html test_info.php  test_mysql.php #删除无用文件

[root@localhost blogcom]# ls

wordpress  wordpress-4.7.4-zh_CN.tar.gz

[root@localhost blogcom]# mv wordpress/* .  #把目录里的内容移动到blogcom根目录下

[root@localhost blogcom]# /bin/mv wordpress-4.7.4-zh_CN.tar.gz /root/ #移走源程序

[root@localhost blogcom]# ls -l  #完整的blog程序内容

total 192

-rw-r--r--.  1 nobody 65534   418 Sep 24  2013 index.php

-rw-r--r--.  1 nobody 65534 19935 Jan  2  2017 license.txt

-rw-r--r--.  1 nobody 65534  6956 Apr 23 09:24 readme.html

drwxr-xr-x.  2 nobody 65534  4096 Jul 14 16:04 wordpress

-rw-r--r--.  1 nobody 65534  5447 Sep 27  2016 wp-activate.php

drwxr-xr-x.  9 nobody 65534  4096 Apr 23 09:24 wp-admin

-rw-r--r--.  1 nobody 65534   364 Dec 19  2015 wp-blog-header.php

-rw-r--r--.  1 nobody 65534  1627 Aug 29  2016 wp-comments-post.php

-rw-r--r--.  1 nobody 65534  2930 Apr 23 09:24 wp-config-sample.php

drwxr-xr-x.  5 nobody 65534  4096 Apr 23 09:24 wp-content

-rw-r--r--.  1 nobody 65534  3286 May 24  2015 wp-cron.php

drwxr-xr-x. 18 nobody 65534 12288 Apr 23 09:24 wp-includes

-rw-r--r--.  1 nobody 65534  2422 Nov 20  2016 wp-links-opml.php

-rw-r--r--.  1 nobody 65534  3301 Oct 24  2016 wp-load.php

-rw-r--r--.  1 nobody 65534 33939 Nov 20  2016 wp-login.php

-rw-r--r--.  1 nobody 65534  8048 Jan 11  2017 wp-mail.php

-rw-r--r--.  1 nobody 65534 16255 Apr  6 14:23 wp-settings.php

-rw-r--r--.  1 nobody 65534 29896 Oct 19  2016 wp-signup.php

-rw-r--r--.  1 nobody 65534  4513 Oct 14  2016 wp-trackback.php

-rw-r--r--.  1 nobody 65534  3065 Aug 31  2016 xmlrpc.php

root@localhost blogcom]# chown -R www.www ../blogcom/ #授权用户访问

[root@localhost blogcom]# ls -l  #最终博客目录和权限

total 192

-rw-r--r--.  1 www www   418 Sep 24  2013 index.php

-rw-r--r--.  1 www www 19935 Jan  2  2017 license.txt

-rw-r--r--.  1 www www  6956 Apr 23 09:24 readme.html

drwxr-xr-x.  2 www www  4096 Jul 14 16:04 wordpress

-rw-r--r--.  1 www www  5447 Sep 27  2016 wp-activate.php

drwxr-xr-x.  9 www www  4096 Apr 23 09:24 wp-admin

-rw-r--r--.  1 www www   364 Dec 19  2015 wp-blog-header.php

-rw-r--r--.  1 www www  1627 Aug 29  2016 wp-comments-post.php

-rw-r--r--.  1 www www  2930 Apr 23 09:24 wp-config-sample.php

drwxr-xr-x.  5 www www  4096 Apr 23 09:24 wp-content

-rw-r--r--.  1 www www  3286 May 24  2015 wp-cron.php

drwxr-xr-x. 18 www www 12288 Apr 23 09:24 wp-includes

-rw-r--r--.  1 www www  2422 Nov 20  2016 wp-links-opml.php

-rw-r--r--.  1 www www  3301 Oct 24  2016 wp-load.php

-rw-r--r--.  1 www www 33939 Nov 20  2016 wp-login.php

-rw-r--r--.  1 www www  8048 Jan 11  2017 wp-mail.php

-rw-r--r--.  1 www www 16255 Apr  6 14:23 wp-settings.php

-rw-r--r--.  1 www www 29896 Oct 19  2016 wp-signup.php

-rw-r--r--.  1 www www  4513 Oct 14  2016 wp-trackback.php

-rw-r--r--.  1 www www  3065 Aug 31  2016 xmlrpc.php

开始安装博客程序

1打开浏览器输入bbs.tian.com(提前做好hosts或DNS解析),回车后,出现下图

此图太多不显示。。。。。。。

 

 

最后实现博客程序URL静态化

----------实现此功能时,首先要在WordPress后台依次单击设置--->固定链接--->自定义结构,然后输入下面的代码,并保存更改-。--------

 

/archives/%post_id%.html

#说明:%post_id%是数据库对应博文内容的唯一ID,例如423

QQ20170715-225054@2x.png-409.5kB

接着在nginx配置文件的server容器中添加下面代码:

 

[root@localhost extra]# cat blog.conf

    server {

        listen       80;

        server_name  blog.yunjisuan.com;

    root    /var/www/html/blogcom;

        location / {

                index  index.php index.html index.htm;

        if (-f $request_filename/index.html){

            rewrite (.*) $1/index.html break;

        }

        if (-f $request_filename/index.php){

            rewrite (.*) $1/index.php;

        }

        if (!-f $request_filename){

            rewrite (.*) /index.php;

        }

        }

    location ~ .*\.(php|php5)?$ {

        fastcgi_pass    127.0.0.1:9000;

        fastcgi_index   index.php;

        include     fastcgi.conf;

    }

    }

检查语法并重启nginx服务,

 

[root@localhost extra]# /usr/local/nginx/sbin/nginx -t

nginx: the configuration file /usr/local/nginx-1.10.2//conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx-1.10.2//conf/nginx.conf test is successful

[root@localhost extra]# /usr/local/nginx/sbin/nginx -s reload

为静态已经设置好

排错思路

1关闭防火墙

2检查个个服务端口的启动情况

3中途有可能因为网络原因丢包,视情况而定吧

4如果勿删除了/tmp/mysql配置文件可以重启服务

5支持包一定要是先装好免得麻烦

 

+

转载于:https://www.cnblogs.com/a-tian/p/9941198.html

你可能感兴趣的文章
【转】代码中特殊的注释技术——TODO、FIXME和XXX的用处
查看>>
【SVM】libsvm-python
查看>>
C++循环单链表删除连续相邻重复值
查看>>
Jmeter接口压力测试,Java.net.BindException: Address already in use: connect
查看>>
ASP.NET使网页弹出窗口不再困难
查看>>
Leetcode Balanced Binary Tree
查看>>
Leetcode 92. Reverse Linked List II
查看>>
windown快速安装xgboost
查看>>
Linux上安装Libssh2
查看>>
九.python面向对象(双下方法内置方法)
查看>>
go:channel(未完)
查看>>
[JS]递归对象或数组
查看>>
LeetCode(17) - Letter Combinations of a Phone Number
查看>>
Linux查找命令对比(find、locate、whereis、which、type、grep)
查看>>
路由器外接硬盘做nas可行吗?
查看>>
python:从迭代器,到生成器,再到协程的示例代码
查看>>
Java多线程系列——原子类的实现(CAS算法)
查看>>
在Ubuntu下配置Apache多域名服务器
查看>>
多线程《三》进程与线程的区别
查看>>
linux sed命令
查看>>