標籤:lnmp php軟體安裝步驟
1.1.1 解決PHP軟體的依賴關係 安裝基本的依賴包yum install zlib-devellibxml2-devel libjpeg-devellibjpeg-turbo-devel libiconv-devel -yyum install freetype-devellibpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -yrpm -qa zlib-devel libxml2-devel libjpeg-devellibjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devellibcurl-devel libxslt-devel 防報錯,所以編譯安裝libiconv軟體安裝mkdir -p /home/oldboy/tools[[email protected] init.d]# cd /home/oldboy/tools/[[email protected] tools]# lltotal 338200drwxr-xr-x 22 root root 4096 May 22 11:17 libiconv-1.14-rw-r--r-- 1 root root 4984397 May 22 08:38 libiconv-1.14.tar.gz#wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz 下載軟體[[email protected] tools]# tar xf libiconv-1.14.tar.gz[[email protected] tools]# cd libiconv-1.14[[email protected] libiconv-1.14]# ./configure --prefix=/usr/local/libiconv[[email protected] libiconv-1.14]# make[[email protected] libiconv-1.14]# make install[[email protected] libiconv-1.14]# cd ../[[email protected] tools]# #wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo[[email protected] tools]# yum -y install libmcrypt-devel mhash mcrypt[[email protected] tools]# rpm -qa libmcrypt-devel mhash mcryptmhash-0.9.9.9-3.el6.x86_64libmcrypt-devel-2.5.8-9.el6.x86_64mcrypt-2.6.8-10.el6.x86_641.1.2 下載解壓PHP軟體[[email protected] tools]# tar xf php-5.5.32.tar.gz[[email protected] tools]# cd php-5.5.32[[email protected] tools]# ./configure --prefix=/application/php-5.5.32 --with-mysql=/application/mysql/ --with-pdo-mysql=mysqlnd --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-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --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-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-ftp --enable-opcache=no#Generating files #configure: creating ./config.status #creating main/internal_functions.c #creating main/internal_functions_cli.c #+--------------------------------------------------------------------+ #| License: | #| This software is subject to the PHP License, available in this | #| distribution in the file LICENSE. By continuing this installation | #| process, you are bound by the terms of this license agreement. | #| If you do not agree with the terms of this license, you must abort | #| the installation process at this point. | #+--------------------------------------------------------------------+ # #Thank you for using PHP. 出現此介面說明配置工作就沒有問題了##防報錯 關鍵ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/touch ext/phar/phar.pharmake 開始編譯make install <- 建立目錄,產生程式檔案資訊 瞭解FastCGI 1.1.3 PHP軟體程式建立軟連結 [[email protected] php-5.5.32]# ln -s /application/php-5.5.32//application/php 1.1.4 配置php解析檔案/配置php-fpm設定檔 [[email protected] tools]#cd /home/oldboy/tools/php-5.5.32 [[email protected] tools]# cp php.ini-production/application/php/lib/php.ini開發的php.ini-production與php.ini-development生產的 檔案區別關係對比擴充:檔案比較命令 diff zdiff vimdiff windows上的檔案比較 cd /application/php/etc/ cp php-fpm.conf.default php-fpm.conf 1.1.5 啟動php-fpm程式[[email protected] php-5.5.32]# /application/php/sbin/php-fpm[[email protected] php-5.5.32]# lsof -i:9000 <--- 確認php 9000連接埠是否正確啟動COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEphp-fpm 11515 root 7u IPv4 205849 0t0 TCP localhost:cslistener (LISTEN)php-fpm 11517 www 0u IPv4 205849 0t0 TCP localhost:cslistener (LISTEN)php-fpm 11910 www 0u IPv4 205849 0t0 TCP localhost:cslistener (LISTEN)php-fpm 11912 www 0u IPv4 205849 0t0 TCP localhost:cslistener (LISTEN)[[email protected] php-5.5.32]# ps -ef|grep php-fpmroot 11515 1 0 05:45 ? 00:00:01 php-fpm:master process (/application/php-5.5.32/etc/php-fpm.conf)www 11517 11515 0 05:45 ? 00:00:17 php-fpm:pool www www 11910 11515 0 07:05 ? 00:00:16 php-fpm:pool www www 11912 11515 0 07:05 ? 00:00:17 php-fpm:pool www root 23687 23564 0 15:24 pts/0 00:00:00 grep --color=auto php-fpm1.1.6 wordpress部落格網站部署配置 1) 修改nginx設定檔,使nginx程式與php程式建立聯絡[[email protected] oldboy]# cd /application/nginx/conf/extra/[[email protected] extra]# vim blog.conf server { listen 80; server_name blog.etiantian.org; # 靜態請求處理的location location / { root html/blog; index index.php index.html index.htm; } <-- 需要注意編輯修改預設首頁檔案 # 動態請求處理的location location ~* .*\.(php|php5)?$ { root html/blog; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; } }說明:利用nginx的location區塊實現動態請求與靜態請求的分別處理 2) 編輯nginx與php連通性測試檔案,並進行測試 echo ‘<?phpphpinfo(); ?>‘ >/application/nginx/html/blog/test_info.php 測試網站 curl http://blog.etiantian.org/index.html <-- 靜態請求網站檔案資訊測試 curl http://blog.etiantian.org/test_info.php <-- 動態請求網站檔案資訊測試 說明:當php服務停止時,9000連接埠資訊消失,即停止PHP錯誤判502錯誤 linux系統測試完畢後,建議利用瀏覽器進行最終測試,測試效果更明顯些 3) 編輯php與mysql連通性測試檔案,並進行測試 a. 建立資料庫[[email protected] ~]# /etc/init.d/mysqld startStarting MySQL.. SUCCESS![[email protected] ~]# mysql -uroot -poldboy123Warning: Using a password on the commandline interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.34 MySQL CommunityServer (GPL)Copyright (c) 2000, 2016, Oracle and/or itsaffiliates. All rights reserved.Oracle is a registered trademark of OracleCorporation and/or itsaffiliates. Other names may be trademarksof their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ toclear the current input statement.mysql> show databases; 查看當前資料庫資訊mysql> create database wordpress; 建立資料庫 b. 添加使用者資訊 mysql> grant all on wordpress.* to‘wordpress‘@‘localhost‘ identified by ‘oldboy123‘; mysql> grantall on wordpress.* to ‘wordpress‘@‘172.16.1.0/255.255.255.0‘ identified by‘oldboy123‘;mysql> flush privileges; #drop [email protected]‘172.16.1.8‘; <--- 刪除使用者資訊#select user,host frommysql.user; <--- 查看使用者資訊#mysql -uwordpress -poldboy123 <--- 測試建立的使用者串連#show databases; <--- 查看當前資料庫資訊 c. 測試php與資料庫連通性[[email protected] /]# cd /application/nginx/html/blog/[[email protected] blog]# vim test_mysql.php<?php//$link_id=mysql_connect(‘主機名稱‘,‘使用者‘,‘密碼‘);//mysql -u使用者 -p密碼 -h 主機$link_id=mysql_connect(‘localhost‘,‘wordpress‘,‘oldboy123‘)ormysql_error();if($link_id){ echo "mysql successful by oldboy !\n"; }else{ echomysql_error(); }?>[[email protected] blog]# curl blog.etiantian.org/test_mysql.phpmysql successful by oldboy ! <--測試php與資料庫的連通性 4) 下載部署wordpress部落格程式(https://cn.wordpress.org/ 英文官網:https://www.wordpress.org/ ) [[email protected] tools]# wgethttps://cn.wordpress.org/wordpress-4.5.1-zh_CN.tar.gz[[email protected] tools]# tar xf wordpress-4.5.1-zh_CN.tar.gz [[email protected] tools]# mv wordpress/* /application/nginx/html/blog/[[email protected] tools]# chown -R www.www/application/nginx/html/blog/[[email protected] tools]# cd /application/nginx/html/blog[[email protected] blog]# lltotal 204-rw-r--r-- 1 www www 19 May 21 15:46index.html-rw-r--r-- 1 www www 418 May 22 12:49 index.php-rw-r--r-- 1 www www 19935 Jan 3 02:51license.txt-rw-r--r-- 1 www www 7433 May 23 09:04readme.html-rw-r--r-- 1 www www 20 May 22 12:56test_info.php-rw-r--r-- 1 www www 313 May 22 12:54test_mysql.php 注意:確認hosts檔案進行瞭解析 瀏覽器頁面進行wordpress部署 vim wp-config.php 可以修改wordpress上的資料庫連接參數信息
本文出自 “淺景塵” 部落格,請務必保留此出處http://857803451.blog.51cto.com/12777961/1931495
LNMP PHP軟體安裝步驟