源码安装 lnmp

来源:互联网 发布:怎样避免淘宝找同款 编辑:程序博客网 时间:2024/05/18 01:13
###### nginx###firewall-cmd --zone=public --add-port=80/tcp --permanentfirewall-cmd --zone=public --add-port=3306/tcp --permanentsystemctl restart firewalld# iptables -A INPUT -p tcp -s 你的ip --dport 3306 -j ACCEPT# iptables -I INPUT -p tcp --dport 80 -j ACCEPT # /etc/init.d/iptables restartsetenforce 0yum -y install gcc automake autoconf libtool make gcc-c++ cmake zlib zlib-devel openssl openssl-devel pcre pcre-develcd /usr/local/src# curl -O ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz# curl -O http://www.zlib.net/zlib-1.2.11.tar.gz# curl -O https://www.openssl.org/source/openssl-1.1.0g.tar.gz# tar -zxvf pcre-8.41.tar.gz zlib-1.2.11.tar.gz openssl-1.1.0g.tar.gzcurl -O http://nginx.org/download/nginx-1.12.2.tar.gztar -zxvf nginx-1.12.2.tar.gzgroupadd nginxuseradd -g nginx -M nginxvi /etc/passwd# nginx:x:1002:1003::/home/nginx:/sbin/nologincd /usr/local/src/nginx-1.12.2./configure --prefix=/usr/local/nginx \--pid-path=/usr/local/nginx/run/nginx.pid \--with-http_ssl_module \--user=nginx \--group=nginx# --with-http_ssl_module 主要是提供https访问支持的。# --pid-path=<path> - 在 nginx.conf 中没有指定pid指令的情况下,默认的 nginx.pid 的路径。如果没有指定,默认为 <prefix>/logs/nginx.pid。makemake install/usr/local/nginx/sbin/nginx###### php###yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-develcd /usr/local/srccurl -O https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gztar -zxvf libmcrypt-2.5.8.tar.gzcd /usr/local/src/libmcrypt-2.5.8./configure --prefix=/usr/localmakemake installcd /usr/local/srccurl -O http://ee1.php.net/distributions/php-7.1.11.tar.gztar -zxvf php-7.1.11.tar.gzcd /usr/local/src/php-7.1.11./configure --prefix=/usr/local/php7 \--with-config-file-path=/usr/local/php7/etc \--with-config-file-scan-dir=/usr/local/php7/etc/php.d \--with-mcrypt=/usr/include \--enable-mysqlnd \--with-mysqli \--with-pdo-mysql \--enable-fpm \--with-fpm-user=nginx \--with-fpm-group=nginx \--with-gd \--with-iconv \--with-zlib \--enable-xml \--enable-shmop \--enable-sysvsem \--enable-inline-optimization \--enable-mbregex \--enable-mbstring \--enable-ftp \--enable-gd-native-ttf \--with-openssl \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-zip \--enable-soap \--without-pear \--with-gettext \--enable-session \--with-curl \--with-jpeg-dir \--with-freetype-dir \--enable-opcachemakemake installcp /usr/local/src/php-7.1.11/php.ini-production /usr/local/php7/etc/php.inicd /usr/local/php7/etccp php-fpm.conf.default php-fpm.confcp php-fpm.d/www.conf.default php-fpm.d/www.conf/usr/local/php7/sbin/php-fpmvi /usr/local/nginx/conf/nginx.conf    #location ~ \.php$ {    #   root           html;    #  fastcgi_pass   127.0.0.1:9000;    #  fastcgi_index  index.php;    #  fastcgi_param  SCRIPT_FILENAME  /script$fastcgi_script_name;    #  include        fastcgi_params;    #}    location ~ \.php$ {        root           html;        fastcgi_pass   127.0.0.1:9000;        fastcgi_index  index.php;        fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/$fastcgi_script_name;        include        fastcgi_params;    }/usr/local/nginx/sbin/nginx -s reloadPATH=$PAHT:/usr/local/php7/binsource /etc/profilephp -v# 根目录:/usr/local/nginx/html/###### mysql###rm -rf /etc/my.cnf /etc/my.cnf.d/rpm -qa|grep mariadb-libsrpm -e 上面查找出来的包名 --nodepsyum install -y libaio libaio-devel bison bison-devel ncurses ncurses-devel libarchive-devel libarchive boost boost-devel lsofcd /usr/local/srccurl -O http://mirrors.neusoft.edu.cn/mariadb//mariadb-10.2.10/source/mariadb-10.2.10.tar.gztar -zxvf mariadb-10.2.10.tar.gzcd /usr/local/src/mariadb-10.2.10groupadd -r mysql # -r 系统账户,GID 会比非系统账户的最小值小。useradd -r -g mysql -s /sbin/nologin -d /usr/local/mysql -M mysqlmkdir -p /data/mysqlchown -R mysql:mysql /data/mysqlcmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/data/mysql \-DSYSCONFDIR=/etc \-DWITHOUT_TOKUDB=1 \-DWITH_INNOBASE_STORAGE_ENGINE=1 \-DWITH_ARCHIVE_STPRAGE_ENGINE=1 \-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \-DWIYH_READLINE=1 \-DWIYH_SSL=system \-DVITH_ZLIB=system \-DWITH_LOBWRAP=0 \-DMYSQL_UNIX_ADDR=/var/run/mysql/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_cimakemake installcd /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysqlcd /usr/local/mysql/cp support-files/my-large.cnf /etc/my.cnf/usr/local/mysql/support-files/mysql.server start/usr/local/mysql/bin/mysql_secure_installation###### 环境变量设置方法#### 1. export PATH=$PATH:/usr/local/webserver/php/bin 临时生效# 2. 执行vi ~/.bash_profile 修改文件中PATH一行,将/usr/local/webserver/php/bin 加入到PATH=$PATH:$HOME/bin一行之后  这种方法只对当前登录用户生效# 3. export PATH=$PATH:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/bin#    source /etc/profilevi /etc/profile# export PATH=$PATH:/usr/local/nginx/sbin:/usr/local/php7/bin:/usr/local/mysql/bin