lnmp环境部署

LNMP环境部署

nginx源码编译安装

wget http://nginx.org/download/nginx-1.17.1.tar.gz -C /data/server
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel 安装编译环境
./configure 运行内部的配置脚本
make && make install 编译安装
./sbin/nginx #运行脚本打开nginx
关闭防火墙 访问IP验证

lnmp环境部署

MySQL编译安装

[[email protected] /usr/local/src]#tar -zxf mysql-5.5.22.tar.gz
yum安装ncurses-devel包
[[email protected] /usr/local/src]#yum -y install ncurses-devel
创建运行用户
[[email protected] /usr/local/src]#groupadd mysql
[[email protected] /usr/local/src]#useradd -s /sbin/nologin -M -g mysql mysql
配置mysql
cmake -DCMAKE_INSTALL_PREFIX=/data/server/mysql -DSYSCONFDIR=/etc/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
编译安装
[[email protected] /usr/local/src/mysql-5.5.22]#make -j4 && make install
设置数据库目录的权限并建立配置文件
[[email protected] /usr/local/src/mysql-5.5.22]#chown -R mysql:mysql /data/server/mysql/
[[email protected] /usr/local/src/mysql-5.5.22]#cp support-files/my-medium.cnf /etc/my.cnf
初始化数据库并设置环境变量
/data/server/mysql/scripts/mysql_install_db --user=mysql --basedir=/data/server/mysql --datadir=/data/server/mysql/data/
[[email protected] /usr/local/src/mysql-5.5.22]#echo “PATH=$PATH:/data/server/mysql/bin” >> /etc/profile
[[email protected] /usr/local/src/mysql-5.5.22]#. /etc/profile
添加系统服务
[[email protected] /usr/local/src/mysql-5.5.22]#cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] /usr/local/src/mysql-5.5.22]#chmod a+x /etc/init.d/mysqld
[[email protected] /usr/local/src/mysql-5.5.22]#chkconfig --add mysqld
开启服务,看到端口号为3306
[[email protected] /usr/local/src/mysql-5.5.22]#systemctl start mysqld
登录mysql数据库验证
mysql -u root -p

php编译安装

解压php
[[email protected] /usr/local/src]#tar zxf php-5.5.14.tar.gz
配置php
[[email protected] php-5.5.14]# ./configure --prefix=/data/server/php --with-config-file-path=/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache=no --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear
用yum安装缺少环境
yum -y install libxml2-devel
yum -y in bzip2-devel
yum -y install bzip2-devel
yum -y install libcurl-devel
yum -y install readline-devel
编译安装libmcrypt
[[email protected] /usr/local/src]#tar zxf libmcrypt-2.5.8.tar.gz
[[email protected] /usr/local/src]#cd libmcrypt-2.5.8
[[email protected] /usr/local/src/libmcrypt-2.5.8]#./configure
[[email protected] /usr/local/src/libmcrypt-2.5.8]#make && make install
安装完所有依赖环境,再次配置并编译安装
[[email protected] php-5.5.14]# ./configure --prefix=/data/server/php --with-config-file-path=/etc --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-opcache=no --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-gettext --enable-mbstring --with-iconv --with-mcrypt --with-mhash --with-openssl --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets --with-curl --with-zlib --enable-zip --with-bz2 --with-readline --without-sqlite3 --without-pdo-sqlite --with-pear
[[email protected] php-5.5.14]# make && make install
复制配置文件到data server下
[[email protected] php-5.5.14]# cp php.ini-development /data/server/php/etc/php.ini
[[email protected] php-5.5.14]#cp /data/server/php/etc/php-fpm.conf.default /data/server/php/etc/php-fpm.conf
[[email protected] php-5.5.14]#cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[[email protected] php-5.5.14]#chmod +x /etc/init.d/php-fpm
[[email protected] php-5.5.14]#/etc/init.d/php-fpm start
报错,创建www用户组和用户
[[email protected] php-5.5.14]# groupadd www
[[email protected] php-5.5.14]#useradd -s /sbin/nologin -M -g www www
[[email protected] php-5.5.14]#/etc/init.d/php-fpm start
lnmp环境部署
修改配置文件
[[email protected] /usr/local/src/php-5.5.14]#vi /data/server/nginx/conf/nginx.conflnmp环境部署
lnmp环境部署
保存并退出 编辑一个lnmp环境测试页面
[[email protected] /usr/local/src/php-5.5.14]#vi /data/server/nginx/html/li.php
lnmp环境部署
网页输入 ip /li.php验证
lnmp环境部署