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

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

linux服務(wù)器下LNMP安裝與配置方法

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

現(xiàn)在很多朋友都選擇了linux服務(wù)器下配置LNMP(linux+nginx+mysql+php),這里分享下LNMP安裝與配置方法,需要的朋友可以參考下

 

Nginx與apache、lighttp性能綜合對(duì)比,如下圖:

linux服務(wù)器下LNMP安裝與配置方法

注意:關(guān)閉rpm默認(rèn)安裝的apache和mysql

1.準(zhǔn)備php函數(shù)的rpm包

yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

2.準(zhǔn)備lnmp其他的源代碼包

wget
wget
wget
wget
wget
wget
wget
wget
wget
wget
wget
wget
wget
wget

3.安裝php-5.2.14源代碼包所需要的函數(shù)支持包

復(fù)制代碼 代碼如下:


tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure --prefix=http://www.3lian.com/usr/local
make
make install
cd ../

(libiconv庫為需要做轉(zhuǎn)換的應(yīng)用提供了一個(gè)iconv()的函數(shù),以實(shí)現(xiàn)一個(gè)字符編碼到另一個(gè)字符編碼的轉(zhuǎn)換)

復(fù)制代碼 代碼如下:


tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../

(libmcrypt是加密算法擴(kuò)展庫。支持DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER+等算法。)

復(fù)制代碼 代碼如下:


tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
(加密算法支持)
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure
make
make install
cd ../

4. 編譯安裝MySQL 5.5.3-m3

復(fù)制代碼 代碼如下:


groupadd mysql
useradd -g mysql mysql

tar zxvf mysql-5.5.3-m3.tar.gz
cd mysql-5.5.3-m3
./configure --prefix=http://www.3lian.com/usr/local/mysql --without-debug --enable-thread-safe-client --with-pthread --enable-assembler --enable-profiling --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-extra-charsets=all --with-plugins=all --with-mysqld-user=mysql --without-embedded-server --with-server-suffix=-community --with-unix-socket-path=http://www.3lian.com/tmp/mysql.sock
Make
#編譯
Make install
#安裝
Cp /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
#準(zhǔn)備mysql配置文件
Vi /etc/my.cnf
[client]
default-character-set=utf8
#修改客戶端和連接字符集
[mysqld]
character-set-server=utf8
#修改服務(wù)器和數(shù)據(jù)庫字符集
collation-server = utf8_general_ci
#修改服務(wù)器校驗(yàn)字符集                   登陸mysql后可以s查看字符集

Setfacl -m u:mysql:rwx -R /usr/local/mysql
Setfacl -m d:u:mysql:rwx -R /usr/local/mysql
#設(shè)置權(quán)限
/usr/local/mysql/bin/mysql_install_db --user=mysql
#安裝mysql和test數(shù)據(jù)庫
/usr/local/mysql/bin/mysqld_safe --user=mysql &
#啟動(dòng)mysql服務(wù)
/usr/local/mysql/bin/mysqladmin -uroot password  123
#修改mysql登錄密碼為123
/usr/local/mysql/bin/mysql -uroot -p123
#用mysql登錄

5. 編譯安裝PHP(FastCGI模式。使用fastCGI管理php,加快php解析速度)

復(fù)制代碼 代碼如下:


tar zxvf php-5.2.14.tar.gz
gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1
#-p  1    是數(shù)字
#解壓并打補(bǔ)丁,讓php支持fpm來方便管理php-cgi進(jìn)程(使用php-fpm管理fastCGI)
# gzip   -c  保留源文件   -d  解壓
cd php-5.2.14/
./configure --prefix=http://www.3lian.com/usr/local/php --with-config-file-path=http://www.3lian.com/usr/local/php/etc --with-mysql=http://www.3lian.com/usr/local/mysql --with-mysqli=http://www.3lian.com/usr/local/mysql/bin/mysql_config --with-iconv-dir=http://www.3lian.com/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=http://www.3lian.com/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
make ZEND_EXTRA_LIBS='-liconv'
#編譯過程設(shè)定變量(編譯過程需要)
make install
cp /lnmp/php-5.2.14/php.ini-dist  /usr/local/php/etc/php.ini
cd ../

6.準(zhǔn)備編譯安裝PHP5擴(kuò)展模塊

復(fù)制代碼 代碼如下: