LNMP部署

时间:2023-01-31 18:57:00

一.部署Nginx

1.安装依赖包

yum -y install pcre-devel zlib-devel openssl-devel

2.新建运行用户

useradd-M -s /sbin/nologin nginx

3.编译安装Nginx

tar xzvf nginx-1.12.0.tar.gz -C /usr/src/
cd /usr/src/nginx-1.12.0/
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx
make && make install
ln -s /usr/local/nginx/sbin/* /usr/local/sbin
nginx
netstat -utpln |grep 80

二.部署Mysql

1.编译安装Mysql

yum -y install cmake ncurses-devel
tar -zxvf mysql-5.5.22.tar.gz -C /usr/src
cd /usr/src/mysql-5.5.22/
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/myasql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DSYSCONFDIR=/etc/
make && make install

2.优化Mysql

cp support-files/my-mdeium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 35 mysqld on
echo "export PATH=$PATH:/usr/local/mysql/bin/" >>/etc/profile
soure /etc/profile
useradd -M -s /sbin/nologin mysql
/ usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql
/etc/init.d/mysqld start
mysqladmin -u root password '123'

三.部署PHP

1.安装依赖包

yum -y install gd libxml2 -devel libjpeg-devel libpng-devel

2.新建运行用户

useradd -M -s /sbin/noogin php

3.编译安装

tar xjvf php-5.3.28.tar.bz2 -C /usr/src/
cd /usr/src/php-5.3.28/
./configure --prefix=/usr/local/php --with-z-with-gd lib --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php --enable-mbstring --enable-fpm --with-jpeg-dir=/usr/lib
make && make install
cp php.ini-development /usr.local/php/php.ini

4.php优化

in -s /usr/local/php/bin/* /usr/local/bin/
in -s /usr/local/php/sbin/* /usr/local/sbin/
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
140 user =php
141 group =php

vim /usr/local/php/php.ini
226 short_open_tag =On
784 default_charset ="utf-8"
php-fpm

四.修改Nginx 支持动态页面

1.修改Nginx主配置文件

LNMP部署

2.编辑测试页面


LNMP部署

LNMP部署