标签:lnmp安装
[root@localhosttools]# cat /etc/redhat-release
CentOSrelease 6.9 (Final)
[root@localhosttools]# uname -a
Linuxlocalhost 2.6.32-696.el6.x86_64 #1 SMP Tue Mar 21 19:29:05 UTC 2017 x86_64x86_64 x86_64 GNU/Linux
[root@localhost~]# mkdir /server/tools –p
[root@localhosttools]# wget -q http://nginx.org/download/nginx-1.10.3.tar.gz
[root@localhosttools]# ls -l
total 892
-rw-r--r-- 1root root 911509 Jan 31 2017nginx-1.10.3.tar.gz
yum install -y pcre-devel openssl-devel
[root@localhosttools]# tar xf nginx-1.10.3.tar.gz
[root@localhosttools]# cd nginx-1.10.3
[root@localhostnginx-1.10.3]# useradd www -s /sbin/nologin –M
./configure --prefix=/application/nginx-1.10.3--user=www --group=www --with-http_stub_status_module --with-http_ssl_module
make&& make install
[root@localhostnginx-1.10.3]# ln -s /application/nginx-1.10.3/ /application/nginx
[root@localhostnginx-1.10.3]# ln -s /application/nginx/sbin/nginx /usr/sbin/ #可以在任意目录执行Nginx启动命令
[root@localhostnginx-1.10.3]# nginx
[root@localhostnginx-1.10.3]# ps -ef|grep nginx
root 3722 1 0 08:24 ? 00:00:00 nginx: master process nginx
www 3723 3722 0 08:24 ? 00:00:00 nginx: worker process
root 3728 1247 0 08:25 pts/0 00:00:00 grep nginx
1.10 查看启动情况
在浏览器输入服务器的ip地址,返回下面界面代表Nginx安装成功。
[root@localhosttools]# ls
libiconv-1.14.tar.gz nginx-1.10.3 php-5.5.32.tar.gz
mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz nginx-1.10.3.tar.gz wordpress-4.7.3-zh_CN.tar.gz
[root@localhosttools]# tar xf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz
[root@localhosttools]# useradd mysql -s /sbin/nologin –M
[root@localhosttools]# mkdir -p /application/
[root@localhosttools]# mv /server/tools/mysql-5.6.34-*-x86_64 /application/mysql-5.6.34
[root@localhosttools]# ln -s /application/mysql-5.6.34//application/mysql
[root@localhosttools]# chown -R mysql.mysql /application/mysql/data
[root@localhosttools]# /application/mysql/scripts/mysql_install_db--basedir=/application/mysql --datadir=/application/mysql/data --user=mysql
注意:此过程中出现两个OK为安装成功
[root@localhosttools]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhosttools]# chmod +x /etc/init.d/mysqld
[root@localhosttools]# sed -i‘s#/usr/local/mysql#/application/mysql#g‘ /application/mysql/bin/mysqld_safe/etc/init.d/mysqld
[root@localhosttools]# \cp/application/mysql/support-files/my-default.cnf /etc/my.cnf
[root@localhosttools]# /etc/init.d/mysqld start
StartingMySQL..... SUCCESS!
[root@localhosttools]# ps -ef|grep mysql
root 3818 1 0 08:43 pts/0 00:00:00 /bin/sh/application/mysql/bin/mysqld_safe --datadir=/application/mysql/data--pid-file=/application/mysql/data/localhost.pid
mysql 3934 3818 4 08:43 pts/0 00:00:01 /application/mysql/bin/mysqld--basedir=/application/mysql --datadir=/application/mysql/data--plugin-dir=/application/mysql/lib/plugin --user=mysql --log-error=/application/mysql/data/localhost.err--pid-file=/application/mysql/data/localhost.pid
[root@localhosttools]# echo ‘export PATH=/application/mysql/bin:$PATH‘ >>/etc/profile
[root@localhosttools]# source /etc/profile
[root@localhosttools]# which mysql
/application/mysql/bin/mysql
[root@localhosttools]# mysql #登录mysql
Welcome tothe MySQL monitor. Commands end with ;or \g.
Your MySQLconnection id is 1
Serverversion: 5.6.34 MySQL Community Server (GPL)
Copyright (c)2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is aregistered trademark of Oracle Corporation and/or its
affiliates.Other names may be trademarks of their respective
owners.
Type ‘help;‘or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
[root@localhosttools]# mysqladmin -uroot password oldboy123#在命令行设置
Warning:Using a password on the command line interface can be insecure.
[root@localhosttools]# mysql -u root -poldboy123 #通过密码登录
Warning: Usinga password on the command line interface can be insecure.
Welcome tothe MySQL monitor. Commands end with ;or \g.
Your MySQLconnection id is 3
Serverversion: 5.6.34 MySQL Community Server (GPL)
Copyright (c)2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is aregistered trademark of Oracle Corporation and/or its
affiliates.Other names may be trademarks of their respective
owners.
Type ‘help;‘or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
[root@localhosttools]# yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devellibiconv-devel –y
[root@localhosttools]# yum install freetype-devel libpng-devel gd-devel libcurl-devellibxslt-devel libxslt-devel –y
cd /server/tools
tar zxf libiconv-1.14.tar.gz
[root@localhosttools]# cd libiconv-1.14
[root@localhostlibiconv-1.14]# ./configure --prefix=/usr/local/libiconv
[root@localhostlibiconv-1.14]# make && make install
安装与加密相关的3个软件
wget -O /etc/yum.repos.d/epel.repohttp://mirrors.aliyun.com/repo/epel-6.repo
[root@localhostlibiconv-1.14]# yum -y install libmcrypt-devel mhash mcrypt
[root@localhost tools]# tar xf php-5.5.32.tar.gz
[root@localhost tools]# cd php-5.5.32
./configure \
--prefix=/application/php-5.5.32 \
--with-mysql=/application/mysql/ \
--with-pdo-mysql=mysqlnd \
--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-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--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-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-ftp \
--enable-opcache=no
为防止在make时报错做一下操作
[root@localhost php-5.5.32]# ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
[root@localhost php-5.5.32]# touch ext/phar/phar.phar
[root@localhost php-5.5.32]# make && makeinstall
ln -s -f phar.phar /application/php-5.5.32/bin/phar
Installing PDO headers: /application/php-5.5.32/include/php/ext/pdo/
[root@localhost php-5.5.32]# ln -s /application/php-5.5.32//application/php
[root@localhost php-5.5.32]# cd/server/tools/php-5.5.32
[root@localhost php-5.5.32]# cp php.ini-production/application/php/lib/php.ini
php.ini-production 与 php.ini-development 文件区别关系对比
扩展:文件比较命令 diff zdiff vimdiff windows上的文件比较
[root@localhost php-5.5.32]# cd /application/php/etc/
[root@localhost etc]# cp php-fpm.conf.defaultphp-fpm.conf
[root@localhost etc]# /application/php/sbin/php-fpm
[root@localhost etc]# lsof -i:9000
COMMAND PIDUSER FD TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 125951 root 7u IPv4 125162 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 125952 www 0u IPv4 125162 0t0 TCP localhost:cslistener (LISTEN)
php-fpm 125953 www 0u IPv4 125162 0t0 TCP localhost:cslistener (LISTEN)
[root@localhost conf]# egrep -v "#|^$"nginx.conf.default >nginx.conf
[root@localhost conf]# vim nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
includeextra/blog.conf;
}
[root@localhost ~]# cd /application/nginx/conf/
[root@localhost conf]# mkdir extra
[root@localhost conf]# cd extra/
[root@localhost extra]# vim blog.conf
server {
listen 80;
server_name blog.bai.com;
location/ {
root html/blog;
index index.php index.htmlindex.htm;
}
error_page 500 502 503 504 /50x.html;
location= /50x.html {
root html;
}
location~* .*\.(php|php5)?$ {
root html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
检查语法重启Nginx.
[root@localhost extra]# nginx -t
nginx: the configuration file /application/nginx-1.10.3/conf/nginx.confsyntax is ok
nginx: configuration file/application/nginx-1.10.3/conf/nginx.conf test is successful
[root@localhost extra]# nginx -s reload
在windows本地做域名解析
10.0.0.152 blog.bai.org
[root@localhost blog]# pwd
/application/nginx/html/blog
[root@localhost blog]# cat test_info.php
<?php phpinfo(); ?>
访问网页:http://blog.bai.org/test_info.php,出现下面网页即成功。
[root@localhost blog]# cat test_mysql.php
<?php
//$link_id=mysql_connect(‘主机名‘,‘用户‘,‘密码‘);
//mysql -u用户 -p密码 -h 主机
$link_id=mysql_connect(‘localhost‘,‘root‘,‘oldboy123‘)or mysql_error();
if($link_id){
echo "mysql successful by root !\n";
}else{
echo mysql_error();
}
?>
[root@localhost blog]# /etc/init.d/mysqld start
Starting MySQL..... SUCCESS!
访问网页,出现下面界面。表示连接成功。
[root@localhost blog]# cd /server/tools/
[root@localhost tools]# tar xfwordpress-4.7.3-zh_CN.tar.gz
[root@localhost tools]# cd wordpress
[root@localhost wordpress]# ls
index.php wp-activate.php wp-comments-post.php wp-cron.php wp-load.
license.txt wp-admin wp-config-sample.php wp-includes wp-login
readme.html wp-blog-header.php wp-content wp-links-opml.php wp-mail.
[root@localhost wordpress]# mv ./*/application/nginx/html/blog/
[root@localhost wordpress]# chown -R www.www/application/nginx/html/blog/
[root@localhost wordpress]# mysql -u root -poldboy123-e "create database wordpress;"
Warning: Using a password on the command lineinterface can be insecure.
[root@localhost wordpress]# mysql -u root -poldboy123-e "show databases;"
Warning: Using a password on the command lineinterface can be insecure.
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| wordpress |
+--------------------+
[root@localhost wordpress]# mysql -u root -poldboy123-e "grant all on wordpress.* to wordpress@‘10.0.0.%‘ identified by‘oldboy123‘;"
Warning: Using a password on the command lineinterface can be insecure.
[root@localhost wordpress]# mysql -u root -poldboy123-e "flush privileges;"
本文出自 “10997527” 博客,请务必保留此出处http://11007527.blog.51cto.com/10997527/1965201
标签:lnmp安装
原文地址:http://11007527.blog.51cto.com/10997527/1965201