【Nginx】LNMP環境下的後續配置

來源:互聯網
上載者:User
本文為點點點細雨原創,謝絕轉載

前言

完成了基本的配置後,我們可以直接在nginx上運行php環境了,那麼,接下來要做的就是後續的一些操作

配置網卡

由於現在的上網方式從分配固定的ip變成了自動分配,所以需要重新修改網卡配置

查看虛擬機器設定,虛擬機器採用的是Mac上的這個



然後修改網卡設定檔,改成對應的mac地址以及dhcp

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth1HWADDR=00:1C:42:29:8E:5BTYPE=Ethernet#UUID=6bfb6ea6-4db0-483c-8964-593fea939a82ONBOOT=yes#NM_CONTROLLED=yesBOOTPROTO=dhcpIPV6INT=yesIPV6_AUTOCONF=yes

重啟網路服務,查看ip

[root@localhost ~]# service network restart正在關閉介面 eth0:                                        [確定]關閉環回介面:                                             [確定]彈出環回介面:                                             [確定]彈出介面 eth0:正在決定 eth1 的 IP 資訊...完成。                                                           [確定][root@localhost ~]# ifconfigeth1      Link encap:Ethernet  HWaddr 00:1C:42:29:8E:5B          inet addr:192.168.199.143  Bcast:192.168.199.255  Mask:255.255.255.0          inet6 addr: fe80::21c:42ff:fe29:8e5b/64 Scope:Link          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:355362 errors:0 dropped:0 overruns:0 frame:0          TX packets:75013 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000          RX bytes:81823948 (78.0 MiB)  TX bytes:11663119 (11.1 MiB)lo        Link encap:Local Loopback          inet addr:127.0.0.1  Mask:255.0.0.0          inet6 addr: ::1/128 Scope:Host          UP LOOPBACK RUNNING  MTU:16436  Metric:1          RX packets:578 errors:0 dropped:0 overruns:0 frame:0          TX packets:578 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:629817 (615.0 KiB)  TX bytes:629817 (615.0 KiB)

完成,接下來就會採用這個IP進行ssh操作了

安裝PHP擴充

下面首先需要安裝PHP擴充的部分,可以參考的是自己以前安裝yar的文章,不過這次就不看自己以前的文章了,畢竟現在使用centos

PHP官網

http://php.net/manual/zh/book.yar.php
我們根據官網的推薦方式進行安裝
http://pecl.php.net/package/yar

Msgpack

安裝php-devel

[root@localhost ~]# yum install php-devel

安裝 msgpack

[root@localhost ~]# yum install gcc cc[root@localhost ~]# pecl channel-update pecl.php.net[root@localhost ~]# pecl install channel://pecl.php.net/msgpack-0.5.5Build process completed successfullyInstalling '/usr/lib64/php/modules/msgpack.so'Installing '/usr/include/php/ext/msgpack/php_msgpack.h'install ok: channel://pecl.php.net/msgpack-0.5.5configuration option "php_ini" is not set to php.ini locationYou should add "extension=msgpack.so" to php.ini

修改php.ini

[root@localhost ~]# vim /etc/php.ini #寫入擴充so[root@localhost ~]# service php-fpm restart停止 php-fpm:                                             [確定]正在啟動 php-fpm:                                         [確定]

Yar

[root@localhost ~]# pecl install yarconfigure: error: Please reinstall the libcurl distribution - easy.h should be in /include/curl/[root@localhost ~]# yum install libcurl[root@localhost ~]# yum install wget

re2c

[root@localhost ~]# wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download[root@localhost ~]# tar zxf download[root@localhost ~]# cd re2c-0.13.5[root@localhost re2c-0.13.5]# yum install bison[root@localhost re2c-0.13.5]# yum install gcc gcc-c++ gcc-g77[root@localhost re2c-0.13.5]# make && make install

重裝curl

[root@localhost ~]# yum  install curl-devel

安裝完成

[root@localhost ~]# pecl install yarBuild process completed successfullyInstalling '/usr/lib64/php/modules/yar.so'install ok: channel://pecl.php.net/yar-1.2.4configuration option "php_ini" is not set to php.ini locationYou should add "extension=yar.so" to php.ini

php.ini

[root@localhost ~]# service php-fpm restart停止 php-fpm:                                             [確定]正在啟動 php-fpm:[28-Dec-2014 21:27:16] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/yar.so' - /usr/lib64/php/modules/yar.so: undefined symbol: php_json_encode in Unknown on line 0                                                           [確定]
這個問題以前遇到過,就是說在載入yar之前需要載入json,但是json這個時候並沒有載入上去,繼續修改php.ini

[root@localhost ~]# service php-fpm restart停止 php-fpm:                                             [確定]正在啟動 php-fpm:[28-Dec-2014 21:29:40] NOTICE: PHP message: PHP Warning:  Module 'json' already loaded in Unknown on line 0                                                           [確定]

這說明json已經載入過了,也就不需要載入了,所以我們去掉第二次載入的部分

[root@localhost php.d]# vi /etc/php.d/json.ini; Enable json extension module;extension=json.so

重啟php-fpm

[root@localhost php.d]# service php-fpm restart停止 php-fpm:                                             [確定]正在啟動 php-fpm:                                         [確定]

完成


後記

Nginx下的php配置就這麼完成啦,接下來就是Nginx的詳細配置了。

yar不支援mac,好桑心。

加油~


以上就介紹了【Nginx】LNMP環境下的後續配置,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.