首页 > 代码库 > Lnmp
Lnmp
@font-face { font-family: "Times New Roman";}@font-face { font-family: "宋体";}@font-face { font-family: "Calibri";}p.MsoNormal { margin: 0 0 0; text-align: justify; font-family: Calibri; font-size: 14px; }span.msoIns { text-decoration: underline; color: blue; }span.msoDel { text-decoration: line-through; color: red; }div.Section0 { page: Section0; }
Lamp=linux+apache/nginx+mysql/pgsql/oracle+php/jsp/xml
Mysql
1
[root@server1 ~]# tar zxf mysql-boost-5.7.17.tar.gz
[root@server1 ~]# cd mysql-5.7.17/
[root@server1 mysql-5.7.17]# ls
boost dbug libmysql rapid testclients
BUILD Docs libmysqld README unittest
client Doxyfile-perfschema libservices regex VERSION
cmake extra man scripts vio
CMakeLists.txt include mysql-test sql win
cmd-line-utils INSTALL mysys sql-common zlib
config.hNaNake libbinlogevents mysys_ssl storage
configureNaNake libbinlogstandalone packaging strings
COPYING libevent plugin support-files
[root@server1 ~]# yum install -y cmake-2.8.12.2-4.el6.x86_64.rpm
[root@server1 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all
..........
CMake Error: your C compiler: "CMAKE_C_COMPILER-NOTFOUND" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
CMake Error at cmake/os/LinuxNaNake:41 (MESSAGE):
Unsupported compiler!
Call Stack (most recent call first):
CMakeLists.txt:162 (INCLUDE)
-- Configuring incomplete, errors occurred!
[root@server1 mysql-5.7.17]# yum install -y gcc gcc-c++
[root@server1 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all
........
CMake Error at cmake/boostNaNake:81 (MESSAGE):
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>
This CMake script will look for boost in <directory>. If it is not there,
it will download and unpack it (in that directory) for you.
If you are inside a firewall, you may need to use an http proxy:
export http_proxy=http://example.com:80
Call Stack (most recent call first):
cmake/boostNaNake:238 (COULD_NOT_FIND_BOOST)
CMakeLists.txt:455 (INCLUDE)
-- Configuring incomplete, errors occurred!
[root@server1 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0
........
CMake Error at cmake/readlineNaNake:64 (MESSAGE):
Curses library not found. Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readlineNaNake:107 (FIND_CURSES)
cmake/readlineNaNake:197 (MYSQL_USE_BUNDLED_EDITLINE)
CMakeLists.txt:483 (MYSQL_CHECK_EDITLINE)
-- Configuring incomplete, errors occurred!
[root@server1 mysql-5.7.17]# yum install -y ncurses-devel
[root@server1 mysql-5.7.17]# rm -f CMakeCache.txt
[root@server1 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=boost/boost_1_59_0
.......
-- Build files have been written to: /root/mysql-5.7.17
[root@server1 mysql-5.7.17]# make
........
[100%] Built target my_safe_process
[root@server1 mysql-5.7.17]# make install
[root@server1 mysql-5.7.17]# cd /usr/local/
[root@server1 local]# ls
bin etc games include lib lib64 libexec lnmp sbin share src
[root@server1 local]# cd lnmp/
[root@server1 lnmp]# ls
mysql
[root@server1 lnmp]# cd mysql/
[root@server1 mysql]# ls
bin COPYING docs include lib man mysql-test README share support-files
[root@server1 mysql]# ll
总用量 56
drwxr-xr-x 2 root root 4096 4月 11 11:29 bin
-rw-r--r-- 1 root root 17987 11月 28 21:32 COPYING
drwxr-xr-x 2 root root 4096 4月 11 11:28 docs
drwxr-xr-x 3 root root 4096 4月 11 11:28 include
drwxr-xr-x 4 root root 4096 4月 11 11:29 lib
drwxr-xr-x 4 root root 4096 4月 11 11:28 man
drwxr-xr-x 10 root root 4096 4月 11 11:29 mysql-test
-rw-r--r-- 1 root root 2478 11月 28 21:32 README
drwxr-xr-x 28 root root 4096 4月 11 11:29 share
drwxr-xr-x 2 root root 4096 4月 11 11:29 support-files
[root@server1 mysql]# useradd -u 27 -d /usr/local/lnmp/mysql/data -s /sbin/nologin mysql
[root@server1 mysql]# id mysql
uid=27(mysql) gid=500(mysql) 组=500(mysql)
[root@server1 mysql]# groupmod -g 27 mysql
[root@server1 mysql]# id mysql
uid=27(mysql) gid=27(mysql) 组=27(mysql)
[root@server1 bin]# pwd
/usr/local/lnmp/mysql/bin/
[root@server1 bin]# vim ~/.bash_profile
@@@@@
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin
export PATH
@@@@@
[root@server1 bin]# source ~/.bash_profile
[root@server1 ~]# cd mysql-5.7.17/support-files/
[root@server1 support-files]# cp my-default.cnf /etc/my.cnf
[root@server1 support-files]# file mysql.server
mysql.server: POSIX shell script text executable
[root@server1 support-files]# cp mysql.server /etc/init.d/mysqld
[root@server1 ~]# cd /usr/local/lnmp/mysql/data
[root@server1 data]# mysqld --initialize --user=mysql --datadir /usr/local/lnmp/mysql/data/
2017-04-11T03:41:45.145850Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-04-11T03:41:45.146174Z 0 [Warning] ‘NO_ZERO_DATE‘, ‘NO_ZERO_IN_DATE‘ and ‘ERROR_FOR_DIVISION_BY_ZERO‘ sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2017-04-11T03:41:45.146181Z 0 [Warning] ‘NO_AUTO_CREATE_USER‘ sql mode was not set.
2017-04-11T03:41:48.000525Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-04-11T03:41:48.695388Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-04-11T03:41:49.051964Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: cb12a9f0-1e68-11e7-b19d-525400c740ea.
2017-04-11T03:41:49.288729Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2017-04-11T03:41:49.289401Z 1 [Note] A temporary password is generated for root@localhost: -2m(*#?0lk2X
[root@server1 data]# /etc/init.d/mysqld start
-bash: /etc/init.d/mysqld: 权限不够
[root@server1 data]# ll /etc/init.d/mysqld
-rw-r--r-- 1 root root 10916 4月 11 11:36 /etc/init.d/mysqld
[root@server1 data]# chmod +x /etc/init.d/mysqld
[root@server1 data]# /etc/init.d/mysqld start
Starting MySQL.Logging to ‘/usr/local/lnmp/mysql/data/server1.wang.com.err‘.
. SUCCESS!
[root@server1 data]# mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root: -2m(*#?0lk2X
The existing password for the user account root has expired. Please set a new password.
New password: Westos+007
Re-enter new password: Westos+007
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password: Westos+007
Re-enter new password: Westos+007
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
‘localhost‘. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named ‘test‘ that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
[root@server1 data]# mysql -p
Enter password: Westos+007
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.7.17 Source distribution
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
mysql> Bye
Nginx
[root@server1 ~]# tar zxf nginx-1.10.1.tar.gz
[root@server1 ~]# cd nginx-1.10.1
[root@server1 nginx-1.10.1]# vim auto/cc/gcc
@@@@@
178 # debug
179 #CFLAGS="$CFLAGS -g"
@@@@@
[root@server1 nginx-1.10.1]# vim src/core/nginx.h
@@@@@
14 #define NGINX_VER "nginx/"
@@@@@
[root@server1 nginx-1.10.1]# ./configure --prefix=/usr/local/lnmp/nginx --with-http_stub_status_module --with-http_ssl_module --with-threads --with-file-aio
........
checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
[root@server1 nginx-1.10.1]# yum install -y pcre-devel
[root@server1 nginx-1.10.1]# yum install -y openssl-devel
[root@server1 nginx-1.10.1]# ./configure --prefix=/usr/local/lnmp/nginx --with-http_stub_status_module --with-http_ssl_module --with-threads --with-file-aio
........
Configuration summary
+ using threads
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/usr/local/lnmp/nginx"
nginx binary file: "/usr/local/lnmp/nginx/sbin/nginx"
nginx modules path: "/usr/local/lnmp/nginx/modules"
nginx configuration prefix: "/usr/local/lnmp/nginx/conf"
nginx configuration file: "/usr/local/lnmp/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/lnmp/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/lnmp/nginx/logs/error.log"
nginx http access log file: "/usr/local/lnmp/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
[root@server1 nginx-1.10.1]# make & make install
........
make[1]: Leaving directory `/root/nginx-1.10.1‘
[1]+ Done make
[root@server1 nginx-1.10.1]# cd /usr/local/lnmp/nginx/
[root@server1 nginx]# ls
conf html logs sbin
[root@server1 nginx]# cd conf/
[root@server1 conf]# useradd -u 1000 -s /sbin/nologin nginx
[root@server1 conf]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Thread(s) per core: 1
Core(s) per socket: 1
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 44
Stepping: 1
CPU MHz: 2394.456
BogoMIPS: 4788.91
Hypervisor vendor: KVM
Virtualization type: full
L1d cache: 32K
L1i cache: 32K
L2 cache: 4096K
NUMA node0 CPU(s): 0
[root@server1 conf]# sysctl -a | grep file
fs.file-nr = 512098866
fs.file-max = 98866
[root@server1 conf]# ulimit -u nginx -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 7820
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 7820
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
[root@server1 conf]# vim /etc/security/limits.conf
@@@@@
52 nginx - nofile 65535
@@@@@
[root@server1 conf]# vim nginx.conf
@@@@@
1
2 user nginx;
3 worker_processes 1;
4
5 #error_log logs/error.log;
6 #error_log logs/error.log notice;
7 #error_log logs/error.log info;
8
9 #pid logs/nginx.pid;
10
11
12 events {
13 worker_connections 65535;
14 }
@@@@@
[root@server1 conf]# /usr/local/lnmp/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/lnmp/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/lnmp/nginx/conf/nginx.conf test is successful
[root@server1 conf]# /usr/local/lnmp/nginx/sbin/nginx
[root@server1 conf]# netstat -antlp
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 31417/nginx
[root@server1 conf]# curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
@font-face { font-family: "Times New Roman";}@font-face { font-family: "宋体";}@font-face { font-family: "Calibri";}p.MsoNormal { margin: 0 0 0; text-align: justify; font-family: Calibri; font-size: 14px; }span.msoIns { text-decoration: underline; color: blue; }span.msoDel { text-decoration: line-through; color: red; }div.Section0 { page: Section0; }
Php
[root@server1 ~]# tar jxf php-5.6.20.tar.bz2
[root@server1 ~]# yum install net-snmp-devel curl-devel libxml2-devel libpng-devel libjpeg-devel freetype-devel gmp-devel -y
[root@server1 ~]# rpm -ivh libmcrypt-2.5.8-9.el6.x86_64.rpm libmcrypt-devel-2.5.8-9.el6.x86_64.rpm
warning: libmcrypt-2.5.8-9.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%])
1:libmcrypt ########################################### [ 50%])
2:libmcrypt-devel ########################################### [100%])
[root@server1 ~]# rpm -ivh re2c-0.13.5-1.el6.x86_64.rpm
warning: re2c-0.13.5-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%])
1:re2c ########################################### [100%])
[root@server1 ~]# cd php-5.6.20
[root@server1 php-5.6.20]# ./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/php/etc --with-mysql --with-mysql-sock=/usr/local/lnmp/mysql/data/mysql.sock --with-mysqli --with-pdo-mysql --enable-mysqlnd --with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext --with-gmp --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt --with-mhash
..............
Thank you for using PHP.
config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands
[root@server1 php-5.6.20]# make & make install
........
Installing PDO headers: /usr/local/lnmp/php/include/php/ext/pdo/
[1]+ Done make
[root@server1 php-5.6.20]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini
[root@server1 php-5.6.20]# cd /usr/local/lnmp/php/etc/
[root@server1 etc]# cp php-fpm.conf.default php-fpm.conf
[root@server1 etc]# ls
pear.conf php-fpm.conf php-fpm.conf.default php.ini
[root@server1 etc]#vim php-fpm.conf
@@@@@
25 pid = run/php-fpm.pid
@@@@@
[root@server1 etc]# vim php.ini
@@@@@
925 date.timezone = Asia/Shanghai
@@@@@
[root@server1 php-5.6.20]# cd sapi/fpm/
[root@server1 fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
[root@server1 fpm]# cd /usr/local/lnmp/nginx/conf/
[root@server1 conf]# vim nginx.conf
@@@@@
43 location / {
44 root html;
45 index index.php index.html index.htm;
46 }
65 location ~ \.php$ {
66 root html;
67 fastcgi_pass 127.0.0.1:9000;
68 fastcgi_index index.php;
69 fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
70 include fastcgi.conf;
71 }
@@@@@
[root@server1 conf]# chmod +x /etc/init.d/php-fpm
[root@server1 conf]# /etc/init.d/php-fpm start
Starting php-fpm done
[root@server1 conf]# netstat -antlp
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 13592/php-fpm
[root@server1 conf]# cd /usr/local/lnmp/nginx/conf/html/
[root@server1 html]# vim index.php
@@@@@
<?php
phpinfo()?>
@@@@@
@font-face { font-family: "Times New Roman";}@font-face { font-family: "宋体";}@font-face { font-family: "Calibri";}p.MsoNormal { margin: 0 0 0; text-align: justify; font-family: Calibri; font-size: 14px; }span.msoIns { text-decoration: underline; color: blue; }span.msoDel { text-decoration: line-through; color: red; }div.Section0 { page: Section0; }
本文出自 “元小光” 博客,请务必保留此出处http://yuanxiaoguang.blog.51cto.com/11338250/1916450
Lnmp