Linux源码安装lnmp

2025-10-25 22:26:40

1、   刚安装的电脑很多都是有防火墙的,可能会导致安装失败,你可以先关防火墙然后装完在允许指定的端口放开在打开防火墙

  1) 临时生效,重启后复原

       开启: service iptables start

       关闭: service iptables stop

2) 永久性生效,重启后不会复原

      开启: 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.13

make && make install

安装libiconv

Libiconv

安装libmcrypt

./configure

make && make install

/sbin/ldconfig  //打开创建动态链接

cd libltdl/

./configure --enable-ltdl-install

make && make install

ln -sf /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la

ln -sf /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so

ln -sf /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4

ln -sf /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8

ldconfig

安装mhash

./configure

make && make install

ln -sf /usr/local/lib/libmhash.a /usr/lib/libmhash.a

ln -sf /usr/local/lib/libmhash.la /usr/lib/libmhash.la

ln -sf /usr/local/lib/libmhash.so /usr/lib/libmhash.so

ln -sf /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

ln -sf /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

ldconfig

安装freetype

安装curl

./configure --prefix=/usr/local/curl --enable-ares --without-nss --with-ssl

make && make install

安装pcre

./configure

make && 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=1

groupadd mysql

useradd -s /sbin/nologin -M -g mysql mysql

cp ./support-files/my-default.cnf /etc/my.cnf

chown -R mysql:mysql  /usr/local/mysql

/usr/local/mysql/bin/mysqld --initialize-insecure --basedir=/usr/local/mysql   --user=mysql

chgrp -R mysql /usr/local/mysql/

cp support-files/mysql.server /etc/init.d/mysql

chmod 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-xsl

make ZEND_EXTRA_LIBS='-liconv'

make install

mkdir -p /usr/local/php/etc

cp php.ini-production /usr/local/php/etc/php.ini

cp php-fpm.conf.default php-fpm.conf    进入php-fpm.d 中将www.conf.default 改成www.conf

添加 自启动

/etc/rc.d/rc.local

7、这个可以不必安装(但是你要使用laravel建议安装吧)

安装composer

ln -s /usr/local/php/bin/php  /usr/local/bin/php

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

curl -sS https://getcomposer.org/installer | /usr/local/php/bin/php -- --install-dir=/usr/local/bin --filename=composer

mv /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

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
相关推荐
  • 阅读量:144
  • 阅读量:110
  • 阅读量:36
  • 阅读量:154
  • 阅读量:99
  • 猜你喜欢