1、檢查並安裝組件
yum -y install gcc automake autoconf libtool make gcc-c++ glibc
2、安裝庫
yum -y install libxslt-devel \ 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-devel libidn libidn-devel openssl openssl-devel
3、安裝libmcrypt
cd /usr/local/src wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz tar zxvf libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7 ./configure --prefix=/usr/local/libmcrypt make && make install vi /etc/ld.so.conf.d/local.conf 添加 “/usr/local/libmcrypt/lib” ldconfig -v
4、安裝libmcrypt
配置php-fpm
wget http://cn2.php.net/get/php-5.6.11.tar.gz/from/this/mirror tar zxvf php-5.6.11.tar.gz cd php-5.6.11 ./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt=/usr/local/libmcrypt \ --enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath \ --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets \ --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \ --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli \ --with-gd --with-jpeg-dir --with-openssl make && make install
php-fpm.conf
cd /usr/local/php/etc cp php-fpm-default.conf php-fpm.conf
將user = nobody group = nobody 修改為user = phpz group = phpz創建用戶phpz和用戶組phpz
vi php-fpm.conf
建立php.ini
groupadd phpz useradd -g phpz phpz
設定php-fpm.pid
cp /usr/local/src/php-5.6.11/php.ini-production /usr/local/php/lib/php.ini
指令:kill -USR2 `cat var/run/php-fpm.pid`
4、安裝Nginx
vi php-fpm.conf
cd /usr/local/src
:
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz tar zxvf pcre-8.36.tar.gz
下載並解壓openssl-1.0.1g.tar.gz:
.tar.gz:wget http://zlib.net/zlib-1.2.8.tar.gz tar zxvf zlib-1.2.8.tar.gz
wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz tar zxvf openssl-1.0.1g.tar.gz
wget http://nginx.org/download/nginx-1.4.7.tar.gz tar zxvf nginx-1.4.7.tar.gz
請求,首先到nginx的安裝目錄cd /usr/local/nginx,修改vi conf/nginx.conf 文件,找到如下內容:
取消註釋,再將/scripts$fastcgi_script_name 修改為$document_root$fastcgi_script_script_namename一個php檔案vi /usr/bin/pod2man #注释第69行 cd /usr/local/src/nginx-1.4.7 ./configure --prefix=/usr/local/nginx \ --with-http_ssl_module \ --with-pcre=/usr/local/src/pcre-8.36 \ --with-zlib=/usr/local/src/zlib-1.2.8 \ --with-openssl=/usr/local/src/openssl-1.0.1g
cd /usr/local/nginx ./sbin/nginx
啟動php-fpm ,重啟nginx
cd /usr/local/nginx/html vi index.php
<?php echo phpinfo(); ?>
/usr/local/php/sbin/php-fpm /usr/local/nginx/sbin/nginx -s reload
cd /usr/local/src wget http://mirrors.sohu.com/mysql/MySQL-Cluster-7.4/mysql-cluster-gpl-7.4.7.tar.gz
解壓mysql-cluster-gpltar如下:
yum -y install cmake
安裝MySQL:
groupadd mysql useradd -r -g mysql mysql
安裝需要一段時間,可以喝杯茶
初始化資料庫,先切換目錄到MySQL的安裝目錄:
tar zxvf mysql-cluster-gpl-7.4.7.tar.gz
cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DMYSQL_TCP_PORT=3306 \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/run/mysql.sock \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_SSL=yes
make && make install
cd /usr/local/mysql/
chown -R mysql . chgrp -R mysql .
要對MySQL進行設定
我自己設定為安裝目錄下的「run/」資料夾,因此要把這個資料夾的所屬使用者設定為「mysql 」:
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql
chown -R root . chown -R mysql data chown -R mysql data/mysql chown -R mysql.mysql /usr/local/mysql/data
My
cp support-files/my-medium.cnf /etc/my.cnf
chown -R mysql ./run
彈出提示時輸入密碼即可。進入後的介面應該類似這樣:
恭喜您,已成功搭建Lnmp環境。
總結:
Linux:CentOS-7-x86_64-DVD-1503-01.iso
PHP:php-5.6.11.tar.gz
Nginx:php-5.6.11.tar.gzNginx:SQLmuster-14.7sql -gpl-7.4.7.tar.gz
如有任何疑問,請在原文評論中提出。轉載請註明出處(原文網址):
http://home.php-z.com/blog-1-39.html以上就介紹了Lnmp環境搭建,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。