LNMP命令集

LNMP命令集_第1张图片

包以上传,去下载页面

nginx安装

##首先搭建Nginx详解看nginx
#gcc gcc-c++ make
mount /dev/sr0 /media/cdrom &> /dev/null
yum -y install pcre-devel openssl-devel &> /dev/null
tar xf nginx-1.10.2.tar.gz -C /usr/src
cd /usr/src/nginx-1.10.2/
##一个服务器搭建,nginx和php程序用户要相同
useradd -M -s /sbin/nologin lnmp
 ./configure --user=lnmp --group=lnmp --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module &> /dev/null
make &> /dev/null && make install &> /dev/null
ln -s /usr/local/nginx/sbin/* /usr/local/sbin
cd /usr/local/nginx/conf/
egrep -v "#|^$" nginx.conf.default > nginx.conf

MySQL安装

先安装MySQL,因为PHP安装需要先有MySQL环境不然会报错。

tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz -C /usr/local
useradd -s /sbin/nologin -M mysql
cd /usr/local/mysql-5.5.32-linux2.6-x86_64/
/bin/cp support-files/my-small.cnf /etc/my.cnf 
echo "192.168.200.143 lnmp" >> /etc/hosts
ln -s /usr/local/mysql-5.5.32-linux2.6-x86_64 /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql
yum -y install libaio &> /dev/null
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &> /dev/null
/bin/cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start
ln -s /usr/local/mysql/bin/* /usr/local/bin
mysqladmin -uroot password '123123'

开始编译安装PHP

yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd libcurl-devel libxslt-devel &> /dev/null
cd /root
tar xf libiconv-1.14.tar.gz -C /usr/src
cd /usr/src/libiconv-1.14/
./configure --prefix=/usr/local/libiconv &> /dev/null && make &> /dev/null && make install &> /dev/null
cd /root/rpm/
rpm -ihv libmcrypt-2.5.8-9.el6.x86_64.rpm &> /dev/null
rpm -ihv libmcrypt-devel-2.5.8-9.el6.x86_64.rpm &> /dev/null
rpm -ihv mhash-0.9.9.9-3.el6.x86_64.rpm &> /dev/null
rpm -ihv mcrypt-2.6.8-10.el6.x86_64.rpm &> /dev/null
cd /root
tar xf php-5.3.28.tar.gz -C /usr/src
cd /usr/src/php-5.3.28/
./configure --prefix=/usr/local/php5.3.28 --with-mysql=/usr/local/mysql --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-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --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-zend-multibyte --enable-static --with-xsl --with-fpm-user=lnmp --with-fpm-group=lnmp --enable-ftp &> /dev/null
touch ext/phar/phar.phar
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64
make &> /dev/null && make install &> /dev/null
ln -s /usr/local/php5.3.28/ /usr/local/php
cp php.ini-production /usr/local/php/lib/php.ini
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
/usr/local/php/sbin/php-fpm 
ln -s /usr/local/php/bin/* /usr/local/bin/
ln -s /usr/local/php/sbin/* /usr/local/sbin/

修改Nginx配置文件

cd /usr/local/nginx/conf/
vim nginx.conf

worker_processes  1;  
error_log logs/error.log;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on; 
    keepalive_timeout  65; 
    server {
        listen       80; 
        server_name  blog.yunjiusan.com;
        location / { 
            root   html/blog;
            index  index.html index.htm;
        }    
        location ~.*\.(php|php5)?${
            root   html/blog;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
        }   
    }   
}
cd /usr/local/nginx/html/
mkdir blog
echo "blog" > blog/index.html
/usr/local/nginx/sbin/nginx
echo "192.168.200.143 blog.yunjisuan.com" >> /etc/hosts

部署博客

#数据库部署
mysql -uroot -p123123 -e "create database wordpress"
mysql -uroot -p123123 -e "grant all on wordpress.* to 'wordpress'@'localhost' identified by '123123'"
mysql -uroot -p123123 -e "flush privileges"
cd /usr/local/nginx/conf/
vim nginx.conf

worker_processes  1;  
error_log logs/error.log;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on; 
    keepalive_timeout  65; 
    server {
        listen       80; 
        server_name  blog.yunjiusan.com;
        location / { 
            root   html/blog;
            index  index.php index.html index.htm;
        }    
        location ~.*\.(php|php5)?${
            root   html/blog;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi.conf;
        }   
    }   
}
/usr/local/nginx/sbin/nginx -s reload
cd /root
tar xf wordpress-4.7.4-zh_CN.tar.gz
cd /usr/local/nginx/html/blog/
rm -rf *
mv ~/wordpress/* .
chown -R lnmp.lnmp /usr/local/nginx/html/blog

你可能感兴趣的:(LNMP)