CenOS7.6源码包安装LNMP环境

版本信息

linux Centos7.6

nginx v1.16.1

mysql 5.6

php 7.0

一、关闭防火墙,SELinux,配置yum源

# systemctl stop firewalld

# systemctl disable firewalld

# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config #永久修改

# setenfoce 0   #临时设置

# getenfore   #检查

# yum -y install epel-release

二、安装NGINX

# yum -y install wget

# yum -y install gcc gcc-c++ automake autoconf pcre pcre-devel zlib zlib-devel openssl openssl-devel

# useradd -M -s /sbin/nologin nginx

# wget http://nginx.org/download/nginx-1.16.1.tar.gz

# tar -xf nginx-1.16.1.tar.gz

# cd nginx-1.16.1

# ./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 --with-http_ssl_module --with-http_gzip_static_module --user=nginx --group=nginx

# make && make install

# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/

# nginx -t #查看配置

# nginx #启动

# ss -tuanlp|grep nginx #查看是否启动

# cd /usr/lib/systemd/system #加入systemd,按需修改

# vim nginx.service

---------------------------------------------------------------------

[Unit]

Description=nginx - high performance web server

Documentation=http://nginx.org/en/docs/

After=network.target remote-fs.target nss-lookup.target

[Service]

Type=forking

PIDFile=/usr/local/nginx/logs/nginx.pid

ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf

ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

ExecReload=/bin/kill -s HUP $MAINPID

ExecStop=/bin/kill -s QUIT $MAINPID

PrivateTmp=true

[Install]

WantedBy=multi-user.target

-----------------------------------------------------


三、安装MySQL

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.22.tar.gz

# yum -y install cmake bison git ncurses-devel gcc gcc-c++ autoconf


# groupadd mysql

# useradd -g mysql mysql

 # tar zxvf mysql-5.6.38.tar.gz 

# mkdir /usr/local/mysql

# mkdir /usr/local/mysql/data

# cd mysql-5.6.38/

# cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DMYSQL_DATADIR=/usr/local/mysql/data-DMYSQL_TCP_PORT=3306-DMYSQL_USER=mysql-DENABLE_DOWNLOADS=1

# make

# make install

配置启动脚本

# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql

# /etc/init.d/mysql status

# /etc/init.d/mysql start    #启动MySQL

# vi /etc/profile  #配置环境变量

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib

export PATH

# source /etc/profile #变量生效 

# mysql -uroot -p #设置数据库密码

密码初始化为空

创建一个数据库用户,用于客户端访问

mysql> grant all privileges on *.* to 'dev'@'%' identified by '123456';

四、安装PHP

yum -y install libxml2 libxml2-devel openssl-devel bzip2 bzip2-devel libcurl-devel libjpeg libjpeg-devel libpng-devel libicu-devel libmcrypt-devel freetype-devel postgresql-devel libtidy libtidy-devel ImageMagick-devel mhash mhash-devel pcre-devel wget

mkdir -p /usr/local/php7/conf

wget http://mirrors.sohu.com/php/php-7.0.6.tar.xz

tar -xf php-7.0.6.tar.xz

cd php-7.0.6

./configure --prefix=/usr/local/php7 --sysconfdir=/usr/local/php7/conf --with-config-file-path=/usr/local/php7/conf --enable-mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-iconv --with-freetype-dir --with-jpeg-dir --with-png-dir --enable-zip --with-zlib --with-bz2 --enable-calendar --enable-exif --with-libxml-dir --enable-xml --disable-rpath --disable-short-tags --enable-bcmath --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-tidy --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-intl --with-pdo-pgsql --enable-fpm --enable-debug

make && make install

# cp php.ini-production /usr/local/php7/conf/php.ini

# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

# chmod +x /etc/init.d/php-fpm

# chkconfig --add php-fpm #添加服务到启动列表

# chkconfig php-fpm on #开启启动

# cd /data/conf/php7/

# cp php-fpm.conf.default php-fpm.conf

# cp php.ini-production php.ini

# cp php-fpm.d/www.conf.default php-fpm.d/www.conf

#/etc/init.d/php-fpm start

四、用WordPress验证LNMP环境

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。