LNMP安装

编译安装

1·php下载地址:cn2.php.net

  • 1.1、安装:

tar jxvf php-7.0.5.tar.bz2

./configure --prefix=/app/php --with-config-file-path=/app/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic

  • 1.2、报错1:yum install libxml2-devel

configure error xml2-config not found. please check your libxml2 installation

  • 1.3、报错2:yum install openssl-devel openssl.x86_64

error: Cannot find OpenSSL's <evp.h>

yum install db4-devel

error: jpeglib.h not found.

2·nginx下载地址:nginx.org

  • 2.1、安装:

    tar -zvxf nginx-1.9.14.tar.gz 

    ./configure --prefix=/app/nginx/(指定路径)

  • 2.2、报错1:提示是要你安装PCRE这个包 直接用yum安装:yum install -y pcre-devel

./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option.

  • 2.3、报错2:提示你安装zlib包:yum install -y zlib-devel

./configure: error: the HTTP gzip module requires the zlib library.You can either disable the module by using --without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using --with-zlib=<path> option.

Paste_Image.png
  • 2.4、关键一步:make && make install

成功

  • 2.5、系统配置

/xx/nginx/sbin/nginx -h #帮助   

/xx/nginx/sbin/nginx -v #显示版本   

/xx/nginx/sbin/nginx -V #显示版本和配置信息   

/xx/nginx/sbin/nginx -t #测试配置   

/xx/nginx/sbin/nginx -q #测试配置时,只输出错误信息   

/xx/nginx/sbin/nginx -s stop #停止服务器   

/xx/nginx/sbin/nginx -s reload #重新加载配置   

/xx/nginx/sbin/nginx -s quit #不知道,估计和stop差不多   

/xx/nginx/sbin/nginx -s reopen #不知道,估计和reload类似   

/xx/nginx/sbin/nginx -p /nginx/path #默认为/usr/local/nginx(nginx安装路径),修改后影响log目录和html目录  

/xx/nginx/sbin/nginx -c /configure/file/path #配置文件路径,默认为conf/nginx.conf,有多个配置文件时很有用,用这个可以启动多个不同的nginx监听不同端口 

3.nginx 开启监控。

  • 3.1、效果:
Paste_Image.png

» Active connections: 对后端发起的活动连接数.
» Server accepts handled requests: Nginx总共处理了5个连接,成功创建5次握手(证明中间没有失败的),总共处理了9个请求.» Reading: Nginx 读取到客户端的Header信息数.» Writing: Nginx 返回给客户端的Header信息数.» Waiting: 开启keep-alive的情况下,这个值等于 active – (reading + writing),意思就是Nginx已经处理完成,正在等候下一次请求指令的驻留连接.}

  • 3.2、配置前准备

    首先/xx/nginx/sbin/nginx -V 查看nginx是有该模块。(yum安装nginx就自己已经安装完毕,编译安装就需要手动指定了。)

Paste_Image.png

如果没有:

重新使用参数配置一下:


    ./configure --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module

  make

  这里只需要make编译一下 #不需要用make insyall,否则会覆盖安装。

  • 3.3、第二步

killall nginx

必须执行,否则会出现 unknown directive "xxxxx"  

mv /xx/nginx/sbin/nginx /xx/nginx/sbin/nginx.bak  

cp ./objs/nginx /xx/nginx/sbin/  

  • 3.4、修改nginx-conf配置

server { #添加如下配置,只要是在server下都行

            location /nginx_status { #这个location后面 的/nginx_status 就是你访问地址的后缀,比如:http://地址/nginx_status 这样才能看到你所想要的效果 
stub_status on;

            access_log off;

            #加入访问限制

            #allow 60.195.252.106;

            #allow 60.195.249.83;

            #deny all;

}

  • 3.5、访问:

http://地址/nginx_status

4·mysql下载地址:yum install mysql-server -y 这里直接用yum安装。

yum安装后可能会出现个问题就是无法启动mysql报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

这个时候首先你要查看下
/var/lib/mysql/ 这个目录下是否有mysql.sock 这个文件。
如果没有 就在/etc /my.cnf中添加socket=/var/lib/mysql/mysql.sock这段 然后使用/etc/init.d/mysqld start 来启动。
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql

卸载:

清空相关mysql的所有目录以及文件rm -rf /usr/lib/mysqlrm -rf /usr/share/mysql
rm -rf /usr/lib/mysql
rm -rf /usr/share/mysql
rm -rf /usr/my.cnf
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容