Ubuntu新服务器安装lnmp
版本:
nginx(无要求,最新)
mysql(5.6.xx)
php(5.6.xx)
ubuntu(16.04,其他版本也并无过多差异)
准备:
#apt-get update
#apt-get install cmake gcc libxml2 libncurses5-dev bison zlib1g-dev libpcre3 openssl libxml2-dev libjpeg-dev libpng-dev lrzsz libssl-dev libfreetype6-dev libmcrypt-dev
#wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.36.tar.gz
###http://php.net/get/php-5.6.40.tar.gz/from/a/mirror
#mkdir /data/mysql5.6
#mkdir /data/php5.6
安装mysql:
#编译安装
#tar -zxf /data/mysql-5.6.36.tar.gz
#cd /data/mysql-5.6.36
#cmake -DCMAKE_INSTALL_PREFIX=/data/mysql5.6 -DSYSCONFDIR=/etc -DMYSQL_DATADIR=/data/mysql5.6/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all
make
#make
#make install
#初始化
#rm /etc/my.cnf
#cp /data/mysql-5.6.36/support-files/my-default.cnf /etc/my.cnf
#groupadd mysql
#useradd -g mysql mysql -s /sbin/false
#/data/mysql5.6/scripts/mysql_install_db –user=mysql –basedir=/data/mysql5.6 –datadir=/data/mysql5.6/data/
#修改数据库root密码,不知道密码的情况下
#vi /etc/my.cnf
[mysqld]
skip-grant-tables
#/data/mysql5.6/support-files/mysql.server start
#/data/mysql5.6/bin/mysql
>use mysql;
>update user set password=password(“newpasswd”) where user=”root”;
>flush privileges;
#/data/mysql5.6/support-files/mysql.server stop
#/data/mysql5.6/bin/mysql -uroot -pnewpasswd
#验证成功后,需要把配置文件改回去
安装php:
#tar -zxf /data/php-5.6.40.tar.gz
#cd /data/php-5.6.40
#./configure –prefix=/data/php5.6 –with-config-file-path=/data/php5.6 –with-mysql=/data/mysql5.6 –enable-fpm –with-mysqli –with-freetype-dir –with-jpeg-dir=/usr/lib –with-png-dir –with-zlib –enable-mbstring –with-gd –with-mhash –enable-opcache –with-curl –with-iconv-dir –enable-xml –disable-rpath –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –enable-mbregex –enable-mbstring –with-mcrypt –enable-ftp –enable-gd-native-ttf –with-openssl –enable-pcntl –enable-sockets –with-xmlrpc –enable-zip –enable-soap –without-pear –with-gettext –disable-fileinfo –enable-maintainer-zts
#报以上错误的话,执行下面
#ln -s /data/mysql5.6/lib/libmysqlclient.so.18 /usr/lib/
#报以上错误的话,执行下面
#cd ext/phar/
#cp phar.php phar.phar
#另外一些我遇到的其他错都是因为少安装了各种软件插件,已经把必要的安装在上面的准备里全写上了
#make
#make install
#安装成功显示如下
#优化配置
#/data/php5.6/bin/php –ini
#cp /data/php-5.6.40/php.ini-development /data/php5.6/php.ini
#vi /data/php5.6/php.ini
expose_php = Off
date.timezone = PRC
short_open_tag = On
#useradd -M -s /sbin/nologin php
#cd /data/php5.6/etc/
#cp php-fpm.conf.default php-fpm.conf
#vi php-fpm.conf
pid = run/php-fpm.pid
user = php
group = php
#启动
#/data/php5.6/sbin/php-fpm
安装nginx:
#至于nginx没有版本要求,就直接使用apt-get安装,不用源码安装了
#apt-get install nginx
#这里列一下主要的配置
1 #server { 2 # listen 80; 3 # server_name www.xxx.cn; 4 # location / { 5 # root /data/www/html; 6 # index index.html index.htm index.php; 7 # } 8 # location ~\.php$ { 9 # root /data/www/html; 10 # fastcgi_pass 127.0.0.1:9000; 11 # fastcgi_index index.php; 12 # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 13 # include fastcgi_params; 14 # } 15 # error_page 500 502 503 504 /50x.html; 16 # location = /50x.html { 17 # root html; 18 # } 19 # 20 #}