技術(shù)員聯(lián)盟提供win764位系統(tǒng)下載,win10,win7,xp,裝機(jī)純凈版,64位旗艦版,綠色軟件,免費(fèi)軟件下載基地!

當(dāng)前位置:主頁 > 教程 > 服務(wù)器類 >

LNMP服務(wù)器環(huán)境配置詳解

來源:技術(shù)員聯(lián)盟┆發(fā)布時(shí)間:2018-08-06 12:06┆點(diǎn)擊:

  服務(wù)器配置

  1.購買好vps后登錄服務(wù)器首先修改密碼passwd root

  2.修改ssh的超時(shí)時(shí)間

 代碼如下      
vi /etc/ssh/sshd_config
ClientAliveInterval 60
ClientAliveCountMax 30
 

  3.安裝setup

 代碼如下      

#安裝setuptool
yum install setuptool
#可以發(fā)現(xiàn)執(zhí)行setup后不全,再安裝一個(gè)用于系統(tǒng)服務(wù)管理
yum install ntsysv
#再安裝個(gè)防火墻,以及setup中配套的防火墻設(shè)置、網(wǎng)絡(luò)設(shè)置
yum install iptables
#安裝setup中配套的防火墻設(shè)置
yum install system-config-securitylevel-tui
#安裝setup中配套的網(wǎng)絡(luò)設(shè)置
yum install system-config-network-tui

 

  4.格式化磁盤,掛載磁盤

  客戶端環(huán)境:Mac OSX

  遠(yuǎn)程連接方式:運(yùn)行 Terminal,輸入命令 ssh username@ip

  硬盤分區(qū)及掛載操作步驟:

  1. 查看未掛載的硬盤(名稱為/dev/xvdb)

 代碼如下      
# fdisk -l
Disk /dev/xvdb doesn't contain a valid partition table
2. 創(chuàng)建分區(qū)
# fdisk /dev/xvdb
...
輸入n
Command (m for help):n
輸入p
Command action
e extended
p primary partition (1-4)
p
輸入1
Partition number (1-4): 1
回車
First cylinder (1-2610, default 1):
Using default value 1
回車
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):
Using default value 2610
輸入w
Command (m for help): w
The partition table has been altered!
3. 格式化分區(qū)
# mkfs.ext3 /dev/xvdb1
4. 建立掛載目錄
# mkdir /data
5. 掛載分區(qū)
# mount /dev/xvdb1 /data
6. 設(shè)置開機(jī)自動掛載
vi /etc/fstab
在vi中輸入i進(jìn)入INERT模式,將光標(biāo)移至文件結(jié)尾處并回車,將下面的內(nèi)容復(fù)制/粘貼,然后按Esc鍵,輸入:x保存并退出
/dev/xvdb1 /data ext3 defaults 0 0
7. 確認(rèn)是否掛載成功
重啟服務(wù)器
# reboot
查看硬盤分區(qū)
# df
/dev/xvdb1 20635700 176196 19411268 1% /data
 

  5.首先安裝gcc

  6.安裝nginx

 代碼如下      
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz
tar zxvf pcre-8.31.tar.gz
cd pcre-8.31/
./configure
make && make install
cd ../
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/web/soft/pcre-8.31':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
如果出現(xiàn)這樣的錯(cuò)誤,則表示系統(tǒng)沒有編譯gcc
yum install gcc即可解決此問題
libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] 錯(cuò)誤 1
make[1]: Leaving directory `/web/soft/pcre-8.31'
make: *** [all] 錯(cuò)誤 2
缺少gcc-c++
yum install gcc-c++
可編譯通過
 

  二.安裝nginx

 代碼如下      

官方網(wǎng)址:
wget
tar zxvf nginx-1.2.5.tar.gz
cd nginx-1.2.5/
./configure --user=www --group=www --prefix=http://www.3lian.com/web/server/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install
cd ../
錯(cuò)誤提示總結(jié):
安裝提示錯(cuò)誤libpcre.so.1,則需要執(zhí)行命令ln -s /usr/local/lib/libpcre.so.1 /lib64
如果沒有安裝pcre庫,則在編譯安裝nginx的時(shí)候會提示./configure: error: the HTTP rewrite module requires the PCRE library.
如果提示錯(cuò)誤nginx: [emerg] getpwnam("www") failed 則表示系統(tǒng)中沒有www用戶 用groupadd -f www useradd -g www www
如果提示錯(cuò)誤./configure: error: SSL modules require the OpenSSL library. 則需要安裝openssl
ssl官網(wǎng)地址:
wget
編譯安裝ssl后重新安裝nginx
./configure --user=www --group=www --prefix=http://www.3lian.com/web/server/nginx --with-http_stub_status_module --with-openssl=http://www.3lian.com/usr/local/ssl
如果系統(tǒng)沒有安裝gcc,則需要先安裝gcc. 命令yum install gcc*
其他錯(cuò)誤:
編譯Nginx提示gzip module requires the zlib library
新手在嘗試安裝nginx時(shí),常常會因?yàn)槿鄙僖蕾嚱M件,導(dǎo)致nginx相應(yīng)模塊無法安裝,在執(zhí)行“./configure”時(shí)常出現(xiàn)錯(cuò)誤。
若在“./configure”后方加入了“--with-http_gzip_static_module”(添加gzip壓縮模塊)提示以下錯(cuò)誤:
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using –without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using –with-zlib= option.
則需要安裝“zlib-devel”即可。SSH執(zhí)行以下命令:
yum install -y zlib-devel或者去官方網(wǎng)站下載zlib安裝wget


 

 

  7.安裝mysql

 代碼如下      
 rpm -ivh mysql.rpm  

  8.安裝php參見