標籤:lamp
和LAMP不同的是,提供web服務的是Nginx,並且php是作為一個獨立服務存在的,這個服務叫做php-fpm。Nginx直接處理靜態請求,動態請求會轉寄給php-fpm。因此,在靜態頁面的處理上,Nginx較Apache更勝一籌。
650) this.width=650;" src="https://s4.51cto.com/wyfs02/M02/9E/16/wKioL1mLCsWjQDqyAACMdrsi29E529.png" title="1.png" alt="wKioL1mLCsWjQDqyAACMdrsi29E529.png" />
安裝MySQL
1、下載並解壓
[[email protected] src]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz [[email protected] src]# tar zxf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz [[email protected] src]# mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql
2、建立使用者與檔案夾
[[email protected] src]# cd /usr/local/mysql[[email protected] mysql]# useradd mysql[[email protected] mysql]# mkdir /data/
3、初始化資料庫
[[email protected] mysql]# yum install -y perl perl-Data-Dumper libaio libaio-devel[[email protected] mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
4、拷貝啟動指令檔
[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf cp:是否覆蓋"/etc/my.cnf"? y[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld
5、啟動MySQL
[[email protected] mysql]# vi /etc/init.d/mysqldbasedir=/usr/local/mysqldatadir=/data/mysql[[email protected] mysql]# chkconfig --add mysqld[[email protected] mysql]# chkconfig mysqld on[[email protected] mysql]# service mysqld startStarting MySQL.Logging to ‘/data/mysql/juispan.err‘. SUCCESS!
安裝PHP
1、下載並解壓
[[email protected] mysql]# cd /usr/local/src[[email protected] src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz[[email protected] src]# tar zxf php-5.6.30.tar.gz
2、配置php
[[email protected] src]# useradd -s /sbin/nologin php-fpm[[email protected] src]# cd php-5.6.30[[email protected] php-5.6.30]# ./configure --prefix=/usr/local/php-fpm --with-config-file-path=/usr/local/php-fpm/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --with-pear --with-curl --with-openssl
在配置過程中,會遇到一個接一個的配置失敗,這裡需要耐心處理。
問題1:configure: error: xml2-config not found. Please check your libxml2 installation.
[[email protected] php-5.6.30]# yum install -y libxml2-devel
問題2:configure: error: Cannot find OpenSSL‘s <evp.h>
[[email protected] php-5.6.30]# yum install -y openssl-devel
問題3:configure: error: Please reinstall the BZip2 distribution
[[email protected] php-5.6.30]# yum install -y bzip2-devel
問題4:configure: error: jpeglib.h not found.
[[email protected] php-5.6.30]# yum install -y libjpeg-turbo-devel
問題5:configure: error: png.h not found.
[[email protected] php-5.6.30]# yum install -y libpng-devel
問題6:configure: error: freetype-config not found.
[[email protected] php-5.6.30]# yum install -y freetype-devel
問題7:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
[[email protected] php-5.6.30]# yum install -y libmcrypt-devel
問題8:configure: error: Please reinstall the libcurl distribution -easy.h should be in <curl-dir>/include/curl/
[[email protected] php-5.6.30]# yum install -y libcurl-devel
處理完以上問題後,重新設定出現以下文本:
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.config.status: creating php5.specconfig.status: creating main/build-defs.hconfig.status: creating scripts/phpizeconfig.status: creating scripts/man1/phpize.1config.status: creating scripts/php-configconfig.status: creating scripts/man1/php-config.1config.status: creating sapi/cli/php.1config.status: creating sapi/fpm/php-fpm.confconfig.status: creating sapi/fpm/init.d.php-fpmconfig.status: creating sapi/fpm/php-fpm.serviceconfig.status: creating sapi/fpm/php-fpm.8config.status: creating sapi/fpm/status.htmlconfig.status: creating sapi/cgi/php-cgi.1config.status: creating ext/phar/phar.1config.status: creating ext/phar/phar.phar.1config.status: creating main/php_config.hconfig.status: main/php_config.h is unchangedconfig.status: executing default commands
以上常值內容表示配置成功,如果不放心可以用“echo $?”確認下。
3、編譯與安裝
[[email protected] php-5.6.30]# make[[email protected] php-5.6.30]# make install
4、調整php-fpm配置
[[email protected] php-5.6.30]# cp php.ini-production /usr/local/php-fpm/etc/php.ini[[email protected] php-5.6.30]# vi /usr/local/php-fpm/etc/php-fpm.conf[global]pid = /usr/local/php-fpm/var/run/php-fpm.piderror_log = /usr/local/php-fpm/var/log/php-fpm.log[www]listen = /tmp/php-fcgi.socklisten.mode = 666user = php-fpmgroup = php-fpmpm = dynamicpm.max_children = 50pm.start_servers = 20pm.min_spare_servers = 5pm.max_spare_servers = 35pm.max_requests = 500rlimit_files = 1024[[email protected] php-5.6.30]# /usr/local/php-fpm/sbin/php-fpm -t[08-Aug-2017 21:16:46] NOTICE: configuration file /usr/local/php-fpm/etc/php-fpm.conf test is successful
5、啟動php-fpm
[[email protected] php-fpm]# cp /usr/local/src/php-5.6.30/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm[[email protected] php-fpm]# chmod 755 /etc/init.d/php-fpm [[email protected] php-fpm]# chkconfig --add php-fpm[[email protected] php-fpm]# chkconfig php-fpm on[[email protected] php-fpm]# service php-fpm startStarting php-fpm done[[email protected] php-fpm]# ps aux|grep php-fpmroot 11303 0.0 0.4 123048 4936 ? Ss 21:20 0:00 php-fpm: master process (/usr/local/php-fpm/etc/php-fpm.conf)php-fpm 11304 0.0 0.4 123048 4700 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11305 0.0 0.4 123048 4700 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11306 0.0 0.4 123048 4700 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11307 0.0 0.4 123048 4700 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11308 0.0 0.4 123048 4704 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11309 0.0 0.4 123048 4704 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11310 0.0 0.4 123048 4704 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11311 0.0 0.4 123048 4704 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11312 0.0 0.4 123048 4704 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11313 0.0 0.4 123048 4704 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11314 0.0 0.4 123048 4704 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11315 0.0 0.4 123048 4704 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11316 0.0 0.4 123048 4704 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11317 0.0 0.4 123048 4704 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11318 0.0 0.4 123048 4708 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11319 0.0 0.4 123048 4708 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11320 0.0 0.4 123048 4708 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11321 0.0 0.4 123048 4708 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11322 0.0 0.4 123048 4708 ? S 21:20 0:00 php-fpm: pool wwwphp-fpm 11323 0.0 0.4 123048 4708 ? S 21:20 0:00 php-fpm: pool wwwroot 11325 0.0 0.0 112664 972 pts/0 R+ 21:21 0:00 grep --color=auto php-fpm
本文出自 “Gorilla City” 部落格,請務必保留此出處http://juispan.blog.51cto.com/943137/1954974
LNMP-安裝MySQL和PHP