Centos下LNMP安装

Posted humor1314

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos下LNMP安装相关的知识,希望对你有一定的参考价值。

安装nginx

[[email protected] ~]# yum install -y gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre-devel   //zlib:给nginx提供gzip模块,需要的支持;OPenssl提供SSL功能;PCRE,地址重写

[[email protected] ~# tar xvf nginx-1.10.2.tar.gz -C /usr/local/src/ ; cd /usr/local/src/nginx-1.10.2

[[email protected] nginx-1.10.2]# ./configure --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module

[[email protected] nginx-1.10.2]# make && make install ;cd

[[email protected] ~]# useradd -u 8001 -M -s /sbin/nologin nginx

[[email protected] ~]# vim /usr/local/nginx/conf/nginx.conf

#user nobody;

user nginx nginx; #此行添加

…… #下面这段内容,需要去掉注释,然后修改script_filename

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;

}

[[email protected] ~]# /usr/local/nginx/sbin/nginx

[[email protected] ~]# echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local

[[email protected] ~]# setenforce 0

[[email protected] ~]# service iptables stop

iptables: Setting chains to policy ACCEPT: filter          [  OK  ]

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Unloading modules:                               [  OK  ]

[[email protected] ~]# chkconfig iptables off

 

安装mysql

[[email protected] ~]# yum remove -y mysql mysql-devel mysql-server

[[email protected] ~]# tar xvf mysql-5.6.26.tar.gz -C /usr/local/src/ ; cd /usr/local/src/mysql-5.6.26

[[email protected] mysql-5.6.26]# useradd -u 8003 -M -s /sbin/nologin mysql

[[email protected] mysql-5.6.26]# yum install -y cmake

[[email protected] mysql-5.6.26]# yum -y install ncurses-devel

[[email protected] mysql-5.6.26]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql

[[email protected] mysql-5.6.26]# make -j 4 ; make install

[[email protected] mysql-5.6.26]# chown -R mysql:mysql /usr/local/mysql/

[[email protected] mysql-5.6.26]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

[[email protected] mysql-5.6.26]# cp /usr/local/mysql/support-

files/mysql.server /etc/init.d/

[[email protected] mysql-5.6.26]# cd ; vim /etc/init.d/mysql.server

basedir=/usr/local/mysql

datadir=/usr/local/mysql/data

[[email protected] ~]# chkconfig mysql.server on

[[email protected] ~]# /usr/local/mysql/scripts/mysql_install_db

--defaults-file=/etc/my.cnf --basedir=/usr/local/mysql

--datadir=/usr/local/mysql/data --user=mysql

[[email protected] tmp]# ln -s /tmp/mysql.sock /var/lib/mysql/

[[email protected] tmp]# service mysql.server restart

 ERROR! MySQL server PID file could not be found!

Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/xuegod64.com.pid).

解决方法:

[[email protected] ~]# mv /etc/my.cnf /etc/my.cnf.backup

[[email protected] ~]# service mysql.server restart

 ERROR! MySQL server PID file could not be found!

Starting MySQL. SUCCESS!

[[email protected] ~]# /usr/local/mysql/bin/mysql_secure_installation

安装PHP

[[email protected] ~]#  tar xvf libmcrypt-2.5.8.tar.gz -C /usr/local/src/ ;

cd /usr/local/src/libmcrypt-2.5.8/

[[email protected] libmcrypt-2.5.8]# ./configure

--prefix=/usr/local/libmcrypt

[[email protected] libmcrypt-2.5.8]# make ; make install ; cd

[[email protected] ~]# tar xvf php-5.6.13.tar.bz2 -C /usr/local/src/ ;cd /usr/local/src/php-5.6.13/

[[email protected] php-5.6.13]# yum install -y php-pear libjpeg-devel libxml2 libxml2-devel curl curl-devel libpng-devel freetype-devel

[[email protected] php-5.6.13]# echo "/usr/local/mysql/lib/" >> /etc/ld.so.conf

[[email protected] php-5.6.13]# echo "/usr/local/libmcrypt/lib" >> /etc/ld.so.conf

[[email protected] php-5.6.13]# ldconfig

[[email protected] php-5.6.13]# echo "ldconfig" >> /etc/rc.local

[[email protected] php-5.6.13]# ./configure --prefix=/usr/local/php -with-config-file-path=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/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-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-mcrypt=/usr/local/libmcrypt --with-gettext

[[email protected] php-5.6.13]# make && make install

[[email protected] php-5.6.13]# cp /usr/local/src/php-5.6.13/php.ini-production /usr/local/php/php.ini

[[email protected] php-5.6.13]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

[[email protected] php-5.6.13]# cp /usr/local/src/php-5.6.13/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

[[email protected] php-5.6.13]# chmod +x /etc/init.d/php-fpm ; cd

[[email protected] ~]# chkconfig --add php-fpm

[[email protected] ~]# chkconfig php-fpm on

[[email protected] ~]# echo "<?php phpinfo(); ?>" > /usr/local/nginx/html/index.php

[[email protected] ~]# service php-fpm start

Starting php-fpm  done

以上是关于Centos下LNMP安装的主要内容,如果未能解决你的问题,请参考以下文章

CentOS7.x-lnmp环境下安装Discuz论坛

Centos下LNMP安装

Linux CentOs下安装lnmp

centos下配置LNMP环境(源码安装)

linux的centos下怎么编译安装LNMP,然后运行phpcms

docker下安装centos,并在其上搭建lnmp环境