安装lnmp

1.安装nginx

cd ~

mkdir immoc

cd  immoc

wget http://nginx.org/download/nginx-1.14.2.tar.gz

cd ~

yum -y install gcc gcc-c++

tar -xzf nginx-1.14.2.tar.gz

cd nginx-1.14.2

yum -y install openssl openssl-devel

cd ../

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.42.tar.gz

wget http://zlib.net/zlib-1.2.11.tar.gz

tar xzf pcre-8.42.tar.gz

tar xzf zlib-1.2.11.tar.gz

cd nginx-1.14.2

./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.42 --with-zlib=../zlib-1.2.11

make

make install

cd /usr/local/nginx

pwd

./nginx

ps -aux | grep nginx

cd html

vi test.html

2.安装mysql

cd  ~

cd immoc

wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.43-linux-glibc2.12-x86_64.tar.gz

mv mysql-5.6.43-linux-glibc2.12-x86_64 mysql-5.6.43

mv mysql-5.6.43 /opt/

cd ~

yum install libaio

yum -y install autoconf

yum -y install numactl

cd /usr/local

ln -s /opt/mysql-5.6.43/ mysql 创建msyql链接

cd mysql

groupadd mysql

useradd -r -g mysql -s /bin/false mysql

scripts/mysql_install_db --user=mysql

bin/mysqld_safe --user=mysql & 回车

ps -e | grep mysqld

./bin/mysqladmin -u root -p password '123456' 回车

yum -y install mysql 安装客户端

mysql -uroot -p 输入密码 报错

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

find / -name mysql.sock

cp my.cnf /etc/

vi /etc/my.cnf

添加

[client]

socket=/tmp/mysql.sock

mysql -uroot -p 输入密码 进入msyql

cd /usr/local/nginx/html/

vi db.php

$link=mysql_connect("localhost","root","lisheng666");

if(!$link) echo "FAILD!连接错误,用户名密码不对";

else echo "OK!可以连接";

?>

use mysql;

select user, host from user;

新建用户远程连接mysql数据库

grant all on *.* to admin@'%' identified by '123456' with grant option;

flush privileges;

修改密码

update user set password=password('123456') where user='admin' and host='%';

flush privileges; 

3.安装php

cd ~

wget http://cn2.php.net/distributions/php-5.6.30.tar.bz2

tar -xjf php-5.6.30.tar.bz2

rpm -qa zlib-devel libxm12-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel libpng-devel gd-devel libcurl-devel libxslt-devel

yum install zlib-devel libxm12-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel libpng-devel gd-devel libcurl-devel libxslt-devel -y

yum -y install libevent libevent-devel

./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --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-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp --without-pear --disable-phar

make

make install

cp php.ini-development /usr/local/php/php.ini

cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf

cp sapi/fpm/php-fpm /usr/local/bin

vim /usr/local/php/php.ini

修改cgi.fix_pathinfo=0

id www-data检测是否有www-data用户

/usr/local/bin/php-fpm

ps -e | grep php-fpm

修改

location / {

    root  html;

    index  index.php index.html index.htm;

}

location ~* \.php$ {

    fastcgi_index  index.php;

    fastcgi_pass    127.0.0.1:9000;

    include        fastcgi_params;

    fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

    fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;

}

./nginx 启动

ps -e | grep nginx

./nginx -s reload

cd html/

vi index.php

输入

phpinfo();

你可能感兴趣的:(安装lnmp)