lnmp搭建測試
lnmp安裝及排錯
標籤(空格分隔)
nginx已安裝就在演示啦//
lnmp安裝及排錯
nginx已安裝就在演示啦//
安裝MySQL資料庫
Debian or Ubuntu使用下面的安裝命令
安裝MySQL資料庫
安裝過程:
列表項
這裡安裝mysql的二進位制包相對較簡單寫
[[email protected] ~]# groupadd mysql#建組
[[email protected] ~]# useradd -s /sbin/nologin -g mysql -M mysql
[[email protected] ~]# tail -1 /etc/passwd
mysql:x:1001:1001::/home/mysql:/sbin/nologin
[[email protected] ~]# id mysql
uid=1001(mysql) gid=1001(mysql) groups=1001(mysql)
---以上只要正確就好不用一樣
[[email protected] ~]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz -C /usr/local/
[[email protected] ~]# cd /usr/local/
[[email protected] local]# mv mysql-5.5.32-linux2.6-x86_64 mysql-5.5.32
[[email protected] local]# ln -s mysql-5.5.32 mysql
[[email protected] local]# ls
bin games lib libexec mysql-5.5.32 nginx-1.10.2 share
etc include lib64 mysql nginx sbin src
[[email protected] local]# cd /usr/local/mysql
[[email protected] mysql]# ls
bin data include lib mysql-test scripts sql-bench
COPYING docs INSTALL-BINARY man README share support-files
二進位制安裝
[[email protected] ~]# tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz -C /usr/local/
[[email protected] ~]# cd /usr/local/
[[email protected] local]# mv mysql-5.5.32-linux2.6-x86_64 mysql-5.5.32
[[email protected] local]# ln -s mysql-5.5.32 mysql
[[email protected] local]# ls
bin games lib libexec mysql-5.5.32 nginx-1.10.2 share
etc include lib64 mysql nginx sbin src
[[email protected] local]# cd /usr/local/mysql
[[email protected] mysql]# ls
bin data include lib mysql-test scripts sql-bench
COPYING docs INSTALL-BINARY man README share support-files
初始化MySQL配置檔案my.conf
[[email protected] ~]# cd /usr/local/mysql
[[email protected] 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
[[email protected] mysql]# /bin/cp support-files/my-small.cnf /etc/my.cnf
提示:
support-files下有my.cnf的各種配置樣例。
使用cp全路徑/bin/cp,可實現拷貝而不出現替換提示,即如果有重名檔案會直接覆蓋
本例為測試安裝環境,因此選擇引數配置小的my-small.cnf配置模版,如果是生產環境可以根據硬體選擇更高階的配置檔案,上述配置檔案模版對硬體的要求從低到高依次為:
5初始化MySQL資料庫
[[email protected] ~]# mkdir -p /usr/local/mysql/data #建立MySQL資料檔案目錄
[[email protected] ~]# chown -R mysql.mysql /usr/local/mysql #授權mysql使用者管理MySQL的安裝目錄
[[email protected] ~]# yum -y install libaio #光碟源安裝依賴包,否則下一步的編譯會報錯
[[email protected] ~]# /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資料庫
[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld
#拷貝MySQL啟動指令碼到MySQL的命令路徑
[[email protected] mysql]# chmod +x /etc/init.d/mysqld
#使指令碼可執行
[[email protected] mysql]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!
成功
- 檢查MySQL舒服成功命令如下:
[[email protected] mysql]# netstat -antup | grep mysql
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1702/mysqld
- 加入開機自啟動
[[email protected] mysql]# chkconfig --add mysqld
[[email protected] mysql]# chkconfig mysqld on
[[email protected] 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命令的全域性使用路徑:
[[email protected] mysql]# ln -s /usr/local/mysql/bin/* /usr/local/bin/
[[email protected]alhost mysql]# which mysqladmin
/usr/local/bin/mysqladmin
8登陸測試一下
[email protected] 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() |
+----------------+
+----------------+
1 row in set (0.00 sec)
mysql> quit
Bye
提示:
MySQL安裝完成以後,預設情況下,root賬戶是無密碼的,這個必須要設定。
MySQL安全配置
為MySQL設定密碼,
```
[[email protected] mysql]# mysqladmin -u root password '123123' #設定密碼
[[email protected] mysql]# mysql #無法直接登陸了
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[[email protected] 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的安裝情況
```
[[email protected] ~]# ls -ld /usr/local/nginx
lrwxrwxrwx. 1 root root 24 Jul 9 14:31 /usr/local/nginx -> /usr/local/nginx-1.10.2/
[[email protected] ~]# ls -ld /usr/local/mysql
lrwxrwxrwx. 1 mysql mysql 12 Jul 14 07:13 /usr/local/mysql -> mysql-5.5.32
```
2檢查埠及啟動情況
```
[[email protected] ~]# 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的成功情況
```
[email protected] ~]# 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]
[[email protected] ~]# 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庫
```[[email protected] ~]# yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel
[[email protected] ~]# yum -y install freetype-devel libpng-devel gd libcurl-devel libxslt-devel
安裝結果如下:
<div class="md-section-divider"></div>
```[[email protected] ~]# 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包
[[email protected] ~]# 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要向安裝上
[email protected] ~]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
[[email protected] ~]# 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
[[email protected] ~]# tar xf libiconv-1.14.tar.gz -C /usr/src/
[[email protected] ~]# cd /usr/src/libiconv-1.14/
[[email protected] 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
[[email protected] 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
編譯安裝過程略
[[email protected] 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
編譯安裝過程略
[[email protected] yum.repos.d]# yum -y install mcrypt
開始安裝php服務(fastcgi)
獲取php包
[email protected] ~]# 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
[[email protected] php-5.3.28]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18
libmysqlclient.so.18 libmysqlclient.so.18.0.0
[[email protected] php-5.3.28]# ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
[[email protected] php-5.3.28]# touch ext/phar/phar.phar
[[email protected] php-5.3.28]# make
#make最後的正確提示
Build complete.
Don't forget to run 'make test'.
安裝PHP生成檔案系統
[[email protected] php-5.3.28]# make install
配置PHP引擎配置檔案按PHP.INI
[[email protected] ~]# ln -s /usr/local/php5.3.28/ /usr/local/php
[[email protected] ~]# ls -l /usr/local/php
lrwxrwxrwx. 1 root root 21 Jul 14 13:06 /usr/local/php -> /usr/local/php5.3.28/
--檢視PHP配置模板檔案
[[email protected] ~]# cd /usr/src/php-5.3.28/
[[email protected] php-5.3.28]# ls php.ini*
php.ini-development php.ini-production
--拷貝php配置檔案到php預設目錄,並更改檔名為php.ini命令如下:
[[email protected] php-5.3.28]# cp php.ini-production /usr/local/php/lib/php.ini
[[email protected] 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
[[email protected] php-5.3.28]# cp php.ini-production /usr/local/php/lib/php.ini
[[email protected] 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
[[email protected] php-5.3.28]# cd /usr/local/php/etc/
[[email protected] etc]# ls
pear.conf php-fpm.conf.default
[[email protected] 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程序及啟動埠的情況。命令;
[[email protected] 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
[[email protected] 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當前的配置,命令:
[[email protected] etc]# cd /usr/local/nginx/conf/
[[email protected] conf]# cp nginx.conf nginx.conf.02
[[email protected] 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;
}
模板我就用的比較簡單
[[email protected] 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
[[email protected] 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
[[email protected] conf]# /usr/local/nginx/sbin/nginx -s reload
----做好每一步的萬無一失,儘量減免在工作中失誤帶來的不好影響--
測試php解析請求是否可以
-1進入指定預設站點目錄後。編輯index.php
[[email protected] conf]# cd /var/www/html/blogcom/
[[email protected] blogcom]# echo "<?php phpinfo(); ?>" >test_info.php
[[email protected] 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、進行測試
編輯內容如下
[[email protected] 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 [email protected]'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 [email protected]'localhost'; #檢視使用者對應許可權
+------------------------------------------------------------------------------------------------------------------+
| Grants for [email protected] |
+------------------------------------------------------------------------------------------------------------------+
| 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的域名對應的主機,命令:
[[email protected] 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;
}
}
[[email protected] extra]# /usr/local/nginx/sbin/nginx -s reload
--獲取WordPress部落格程式,並放置到blog域名對應虛擬主機的站點目錄下
[[email protected] blogcom]# ls #瀏覽www.wordpress.org下載部落格程式
index.html test_info.php test_mysql.php wordpress-4.7.4-zh_CN.tar.gz
[[email protected] blogcom]# tar xf wordpress-4.7.4-zh_CN.tar.gz #解壓
[[email protected] blogcom]# ls
index.html test_info.php test_mysql.php wordpress wordpress-4.7.4-zh_CN.tar.gz
[[email protected] blogcom]# rm -f index.html test_info.php test_mysql.php #刪除無用檔案
[[email protected] blogcom]# ls
wordpress wordpress-4.7.4-zh_CN.tar.gz
[[email protected] blogcom]# mv wordpress/* . #把目錄裡的內容移動到blogcom根目錄下
[[email protected] blogcom]# /bin/mv wordpress-4.7.4-zh_CN.tar.gz /root/ #移走源程式
[[email protected] 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
[email protected] blogcom]# chown -R www.www ../blogcom/ #授權使用者訪問
[[email protected] 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
接著在nginx配置檔案的server容器中新增下面程式碼:
[[email protected] 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服務,
[[email protected] 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
[[email protected] extra]# /usr/local/nginx/sbin/nginx -s reload
為靜態已經設定好////////
排錯思路
1關閉防火牆
2檢查個個服務埠的啟動情況
3中途有可能因為網路原因丟包,視情況而定吧
4如果勿刪除了/tmp/mysql配置檔案可以重啟服務
5支援包一定要是先裝好免得麻煩
+