多语言展示
当前在线:1792今日阅读:26今日分享:39

Linux源码安装lnmp

主要给一些和我有一样开发经验的PHP准备的关于Linux上边lnmp的步骤在此和大家分享一下,有需要补充的可以给我留言或者发到我的邮箱咱们一起交流
工具/原料
1

需要和lnmp所有相关的软件(当然电脑是必备的东西哦)

2

你可以在Windows安装虚拟机在安装Linux去测试一下子西安

3

推荐去这个上边下载所有相关的软件 https://lnmp.org/

方法/步骤
1

刚安装的电脑很多都是有防火墙的,可能会导致安装失败,你可以先关防火墙然后装完在允许指定的端口放开在打开防火墙  1) 临时生效,重启后复原       开启: service iptables start       关闭: service iptables stop2) 永久性生效,重启后不会复原      开启: chkconfig iptables on      关闭: chkconfig iptables off      这个文件也可以关闭防火墙:      /etc/selinux/config         SELINUX=disabled因为可以使用到yum所以你得配置dns    dns配置文件:    etc/resolv.conf配置:nameserver   执行如下命令:     nameserver 208.67.220.220\nnameserver 114.114.114.114' > /etc/resolv.conf   设置yum镜像源:    /etc/yum.repos.d/CentOS-Base-163.repo

2

检查是否安装过lnmp   rpm -qa|grep httpd   rpm -e httpd httpd-tools   rpm -qa|grep mysql   rpm -e mysql mysql-libs   rpm -qa|grep php   rpm -e php-mysql php-cli php-gd php-common php   yum -y remove httpd*   yum -y remove mysql-server mysql mysql-libs   yum -y remove php*   yum clean all

3

安装需要软件:       yum -y install make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel unzip tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils ca-certificates net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel libicu-devel libxslt libxslt-devel  这里一起性把所有的都安装了(怕后边出什么问题)

4

安装autoconf./configure --prefix=/usr/local/autoconf-2.13make && make install安装libiconvLibiconv安装libmcrypt./configuremake && make install/sbin/ldconfig  //打开创建动态链接cd libltdl/./configure --enable-ltdl-installmake && make installln -sf /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.laln -sf /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.soln -sf /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4ln -sf /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8ldconfig安装mhash./configuremake && make installln -sf /usr/local/lib/libmhash.a /usr/lib/libmhash.aln -sf /usr/local/lib/libmhash.la /usr/lib/libmhash.laln -sf /usr/local/lib/libmhash.so /usr/lib/libmhash.soln -sf /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2ln -sf /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1ldconfig安装freetype安装curl./configure --prefix=/usr/local/curl --enable-ares --without-nss --with-sslmake && make install安装pcre./configuremake && make install

5

mysql 安装:cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DMYSQL_DATADIR=/usr/local/mysql/data -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1groupadd mysqluseradd -s /sbin/nologin -M -g mysql mysqlcp ./support-files/my-default.cnf /etc/my.cnfchown -R mysql:mysql  /usr/local/mysql/usr/local/mysql/bin/mysqld --initialize-insecure --basedir=/usr/local/mysql   --user=mysqlchgrp -R mysql /usr/local/mysql/cp support-files/mysql.server /etc/init.d/mysqlchmod 755 /etc/init.d/mysql   #增加执行权限chkconfig mysql on

6

php安装;       ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-xslmake ZEND_EXTRA_LIBS='-liconv'make installmkdir -p /usr/local/php/etccp php.ini-production /usr/local/php/etc/php.inicp php-fpm.conf.default php-fpm.conf    进入php-fpm.d 中将www.conf.default 改成www.conf添加 自启动/etc/rc.d/rc.local

7

这个可以不必安装(但是你要使用laravel建议安装吧)安装composerln -s /usr/local/php/bin/php  /usr/local/bin/phpcurl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composercurl -sS https://getcomposer.org/installer | /usr/local/php/bin/php -- --install-dir=/usr/local/bin --filename=composermv /tmp/composer.phar /usr/local/bin/composer  chmod +x /usr/local/bin/composer

8

注:所有文件安装的时候(除yum)都得先去解压文件       tar -xzvf  文件名称     所以安装都必须进入解压后的文件里边执行上述操作     添加开机重启的办法(可能还有别的办法)       /etc/rc.d/rc.local   添加重启动命令       这个是链接 :note.youdao.com/noteshare?id=a496cc8963efbd5b62428e92956d376f&sub=WEB3259484554bac56e07a6833e73d694c4

9

解压 tar -zxvf nginx-1.8.0.tar.gz #进入安装目录 cd nginx-1.8.0#配置(使用openssl、pcre、zlib的源码路径) ./configure \--user=www \--group=www \--prefix=/usr/local/nginx \--with-http_ssl_module \--with-openssl=/usr/local/openssl-1.0.2d \--with-pcre=/usr/local/pcre-8.37 \--with-zlib=/usr/local/zlib-1.2.8 \--with-http_stub_status_module \--with-threads 上边的configure这部分都是可以变动的(根据自己需要安装) #编译安装 make && make install  #验证/usr/local/nginx/sbin/nginx -V

推荐信息