[Linux]-LNMP Installation steps
Posted Cheney
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Linux]-LNMP Installation steps相关的知识,希望对你有一定的参考价值。
------构建nginx网站平台-----
一、安装Nginx
1、配置IP地址
(略)
2、编译安装Nginx
[[email protected] ~]# yum -y install pcre-devel zlib-devel
[[email protected] ~]# useradd -M -s /sbin/nologin nginx
[[email protected] ~]# tar -zxvf nginx-1.6.0.tar.gz -C /usr/src/
[[email protected] ~]# cd /usr/src/nginx-1.6.0/
[[email protected] nginx-1.6.0]# ./configure --prefix=/usr/local/nginx --user=nginx -
group=nginx --with-http_stub_status_module
[[email protected] nginx-1.6.0]# make && make install
[[email protected] ~]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
[[email protected] ~]# nginx -t
[[email protected] ~]# nginx
[[email protected] ~]# netstat -anpt | grep 80
3、nginx服务的控制
[[email protected] ~]# killall -s HUP nginx
[[email protected] ~]# killall -s QUIT nginx
[[email protected] ~]# nginx
4、创建nginx服务启动脚本
[[email protected] ~]# vim /etc/init.d/nginx
添加:
#!/bin/bash #### welcome to nginx #### # chkconfig: - 99 20 # description: this is nginx server PROG="/usr/local/nginx/sbin/nginx" PIDF="/usr/local/nginx/logs/nginx.pid" case "$1" in start) $PROG ;; stop) kill -s QUIT $(cat $PIDF) ;; restart) $0 stop $0 start ;; reload) kill -s HUP $(cat $PIDF) ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 ;; esac exit 0
[[email protected] ~]# chmod +x /etc/init.d/nginx
[[email protected] ~]# service nginx stop
[[email protected] ~]# service nginx start
[[email protected] ~]# netstat -anpt | grep 80
[[email protected] ~]# chkconfig --add nginx
[[email protected] ~]# chkconfig nginx on
5、验证:
[[email protected] ~]# firefox http://localhost/ &
二、安装mysql数据库
1、安装前准备:
[[email protected] ~]# rpm -e mysql-server --nodeps
[[email protected] ~]# rpm -e mysql --nodeps
[[email protected] ~]# useradd -M -u 39 -s /sbin/nologin mysql
2、安装cmake软件
[[email protected] ~]# tar -zxvf cmake-2.8.6.tar.gz -C /usr/src/
[[email protected] ~]# cd /usr/src/cmake-2.8.6/
[[email protected] cmake-2.8.6]# ./configure && gmake && gmake install
3、安装mysql软件
[[email protected] ~]# tar -zxvf mysql-5.5.22.tar.gz -C /usr/src/
[[email protected] ~]# cd /usr/src/mysql-5.5.22/
[[email protected] mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DSYSCONFDIR=/etc
DWITH_EXTRA_CHARSETS=all
[[email protected] mysql-5.5.22]# make && make install
[[email protected] ~]# cp /usr/src/mysql-5.5.22/support-files/my-medium.cnf /etc/my.cnf
[[email protected] ~]# cp /usr/src/mysql-5.5.22/support-files/mysql.server /etc/init.d/mysqld
[[email protected] ~]# chmod +x /etc/init.d/mysqld
[[email protected] ~]# chown -R mysql:mysql /usr/local/mysql
[[email protected] ~]# ln -s /usr/local/mysql/bin/* /usr/local/bin/
[[email protected] ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql -
basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
[[email protected] ~]# service mysqld restart
[[email protected] ~]# chkconfig --add mysqld
[[email protected] ~]# chkconfig mysqld on
验证:
[[email protected] ~]# mysqladmin -u root password ‘123.com‘
[[email protected] ~]# mysql -u root -p123.com
三、安装php
1、安装php软件
[[email protected] ~]#yum -y install gd libxml2-devel libjpeg-devel libpng-devel
[[email protected] ~]#tar -zxvf php-5.3.28.tar.gz -C /usr/src/
[[email protected] ~]#cd /usr/src/php-5.3.28/
[[email protected] php-5.3.28]#./configure --prefix=/usr/local/php --with-gd --with-zlib --with
mysql=/usr/local/mysql/ --with-config-file-path=/usr/local/php --enable-mbstring --enable-fpm
--with-jpeg-dir=/usr/lib
[[email protected] ~]#make && make install
注意:编译php时报错:make ZEND_EXTRA_LIBS=‘-liconv‘
[[email protected] ~]# cp /usr/src/php-5.3.28/php.ini-development /usr/local/php/php.ini
[[email protected] ~]# vim /usr/local/php/php.ini
添加:
default_charset = "utf-8" short_open_tag = On
[[email protected] ~]# ln -s /usr/local/php/bin/* /usr/local/bin/
[[email protected] ~]# ln -s /usr/local/php/sbin/* /usr/local/sbin/
2、添加优化模块
[[email protected] ~]# tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C
/usr/src/
[[email protected] ~]# cp /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php
5.3.x/ZendGuardLoader.so /usr/local/php/lib/php/
[[email protected] ~]# vim /usr/local/php/php.ini
末尾添加:
zend_extension=/usr/local/php/lib/php/ZendGuardLoader.so zend_loader.enable=1
3、创建php-fpm.conf
[[email protected] etc]# useradd -M -u 40 -s /sbin/nologin php
[[email protected] ~]# cd /usr/local/php/etc/
[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf
[[email protected] etc]# vim php-fpm.conf
可以找到的修改:
pid = run/php-fpm.pid user = php group = php pm.max_children = 50 pm.start_servers = 20 pm.min_spare_servers = 5 pm.max_spare_servers = 35
[[email protected] etc]# /usr/local/sbin/php-fpm
[[email protected] etc]# netstat -anpt | grep php-fpm
[[email protected] etc]# cp /usr/src/php-5.3.28/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[[email protected] etc]# chmod +x /etc/init.d/php-fpm
[[email protected] etc]# service php-fpm stop
[[email protected] etc]# service php-fpm start
[[email protected] etc]# chkconfig --add php-fpm
[[email protected] etc]# chkconfig php-fpm on
[[email protected] php-5.4.35]#vim /usr/local/nginx/conf/nginx.conf
修改:
location / { root html; index index.php index.html index.htm; } location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; #!!! fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi.conf; #!!! }
[[email protected] php-5.4.35]#service nginx stop
[[email protected] php-5.4.35]#service nginx start
[[email protected] php-5.4.35]#netstat -anpt | grep 80
验证:
1、验证PHP与Nginx
[[email protected] ~]#vim /usr/local/nginx/html/index1.php
添加:
<?php phpinfo( ); ?>
[[email protected] ~]#links http://192.168.1.1/ &
2、验证PHP与MySQL
[[email protected] ~]#vim /usr/local/nginx/html/index2.php
添加:
<?php $link=mysql_connect(‘localhost‘,‘root‘,‘123.com‘); if($link) echo "数据库连接,我觉得OK"; mysql_close(); ?>
[[email protected] ~]#links http://192.168.1.1/ &
四、部署SKYUC(电影)
1、设置SKYUC网站
[[email protected] ~]#yum -y install unzip
[[email protected] ~]#unzip SKYUC.v3.4.2.SOURCE.zip
[[email protected] ~]# cp -r SKYUC.v3.4.2.SOURCE/wwwroot/ /usr/local/nginx/html/skyuc
[[email protected] ~]# chown -R php:php /usr/local/nginx/html/skyuc/admincp/
[[email protected] ~]# chown -R php:php /usr/local/nginx/html/skyuc/data/
[[email protected] ~]# chown -R php:php /usr/local/nginx/html/skyuc/upload/
[[email protected] ~]# chown -R php:php /usr/local/nginx/html/skyuc/templates/
2、创建数据库
[[email protected] ~]# mysql -u root -p123.com
mysql> create database skyucdb; mysql> grant all on skyucdb.* to ‘admin‘@‘localhost‘ identified by ‘123.com‘;
3、安装:
[[email protected] ~]# firefox http://192.168.1.1/skyuc/install/index.php &
4、使用:
[[email protected] ~]# firefox http://192.168.1.1/skyuc/
5、后台管理
http://192.168.1.1/SKYUC/admincp/index.php
以上是关于[Linux]-LNMP Installation steps的主要内容,如果未能解决你的问题,请参考以下文章
Linux_Ubuntu16.04_Installation