使用二進制免編譯包(發佈前編譯後再打包);爲安裝順利可先使用yum安裝wget,perl-Data-Dumper,libaiophp
cd /usr/local/srccss
wget http://mirrors.163.com/mysql/Downloads/MySQL-5.6/mysql-5.6.39-linux-glibc2.12-x86_64.tar.gzmysql
tar zxvf mysql-5.6.39-linux-glibc2.12-x86_64.tar.gzlinux
mv mysql-5.6.39-linux-glibc2.12-x86_64 /usr/local/mysqlnginx
cd /usr/local/mysqlweb
useradd mysqlsql
mkdir /data/vim
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql #初始化api
#若報FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:安全
#Data::Dumper
#則需先 yum -y install perl-Data-Dumper
#若報Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No #such file or directory
#則需先 yum -y install libaio
cp support-files/my-default.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld ; 定義basedir(mysql程序目錄/usr/local/mysql)和datadir(/data/mysql)
chkconfig --add mysqld #加入系統服務
/etc/init.d/mysqld start
#/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql & #命令行方式啓動
php安裝:
在lnmp裏面php的安裝和lamp的安裝是有差異的。lnmp架構裏php須要開啓php-fpm服務,是一個獨立的服務。
useradd -s /sbin/nologin php-fpm
cd /usr/local/src
wget http://cn2.php.net/distributions/php-5.6.32.tar.gz
tar zxvf php-5.6.32.tar.gz
cd php-5.6.32
#先確保已安裝:openssl-devel;libxml2-devel;bzip2-devel;libjpeg-turbo-devel;libpng-devel;freetype-devel;epel-release;php-mcrypt;libmcrypt-devel 這幾個包
./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
make && make install
#若報錯:libtool: link: `ext/opcache/ZendAccelerator.lo' is not a valid libtool object;則執行make distclean #從新初始化安裝
ls /usr/local/php-fpm/sbin/php-fpm #檢查服務是否存在。
cp /usr/local/src/php-5.6.30/php.ini-production /usr/local/php-fpm/etc/php.ini
vim /usr/local/php-fpm/etc/php-fpm.conf #建立php-fpm.conf文件並添加如下內容:
[global] pid = /usr/local/php-fpm/var/run/php-fpm.pid error_log = /usr/local/php-fpm/var/log/php-fpm.log [www] listen = /tmp/php-fcgi.sock listen.mode = 666 user = php-fpm group = php-fpm pm = dynamic pm.max_children = 50 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35 pm.max_requests = 500 rlimit_files = 1024
cp /usr/local/src/php-5.6.30/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm;chkconfig --add php-fpm;chkconfig php-fpm on
service php-fpm start
/usr/local/php-fpm/sbin/php-fpm -t #檢測php配置文件的語法是否有問題
Nginx官網 nginx.org,最新版1.13,最新穩定版1.12
Nginx應用場景:web服務、反向代理、負載均衡
Nginx著名分支:淘寶基於Nginx開發的Tengine,使用上和Nginx同樣,和Nginx的最大區別在於Tenging增長了一些定製化模塊,在安全限速方面表現突出,支持對js,css合併
Nginx核心+lua相關的組件和模塊組成了一個支持lua的高性能web容器openresty