"Ready to Work"
#在编译安装lnmp之前, first uninstall the existing RPM package.
The code is as follows |
Copy Code |
RPM-E httpd RPM-E MySQL Rpm-e PHP Yum-y Remove httpd yum-y Remove Mysql-server MySQL Yum-y Remove PHP Yum-y Remove Php-mysql #禁用SeLinux, SELinux may cause the compilation installation to fail, we disable it first. #sed-i ' s/selinux=enforcing/selinux=disabled/g '/etc/selinux/config #永久禁用, requires a reboot to take effect. #或 |
Setenforce 0 # temporarily disabled, no reboot required (recommended).
The code is as follows |
Copy Code |
#yum安装必要工具 Yum-y install make apr* autoconf automake curl-devel gcc gcc-c++ zlib-devel OpenSSL openssl-devel pcre-devel gd kernel ke Yutils Patch perl kernel-headers compat* MPFR cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_e Rr-devel libsepol-devel libselinux-devel krb5-devel libxpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* LIBXML2 libxml2-devel patch gettext glib2-devel bzip2-devel libuuid-devel docbook-style-xsl libxslt-devel gzip-devel fre Etype-devel
|
Download the source package and store the path as shown below:
Usr/local/src/mysql/cmake-2.8.8.tar.gz
Usr/local/src/mysql/mysql-5.5.25a.tar.gz
Usr/local/src/nginx/nginx-1.4.7.tar.gz
Usr/local/src/nginx/openssl-1.0.1e.tar.gz
Usr/local/src/nginx/pcre-8.33.tar.gz
Usr/local/src/nginx/zlib-1.2.8.tar.gz
Usr/local/src/php/libiconv-1.14.tar.gz
Usr/local/src/php/libmcrypt-2.5.8.tar.gz
Usr/local/src/php/mcrypt-2.6.8.tar.gz
Usr/local/src/php/mhash-0.9.9.9.tar.gz
Usr/local/src/php/php-5.3.28.tar.gz
Usr/local/src/php/ext/memcache-3.0.8.tgz
Usr/local/src/php/ext/mongo-1.4.4.tgz
1, Nginx related software
Nginx1.4.7
Http://nginx.org/download/nginx-1.4.7.tar.gz
Pcre (support for nginx address rewriting)
Ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz
Gzip (page compression)
Http://zlib.net/zlib-1.2.8.tar.gz
OpenSSL (HTTPS Security support component)
Http://www.openssl.org/source/openssl-1.0.1e.tar.gz
2, MySQL related software
MySQL5.5.25
Http://downloads.mysql.com/archives/get/file/mysql-5.5.25a.tar.gz
CMake (MySQL compilation tool)
Http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
3, PHP-related software
PHP5.3.28 www.111cn.net
Http://cn2.php.net/get/php-5.3.28.tar.gz/from/this/mirror
Libmcrypt (PHP's encryption extension)
Http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download
Mhash (PHP's hash function library, such as MD5,SHA,CRC, such as the checksum code used to compute messages.) )
Http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2/download
MCrypt (PHP's encryption extension)
Http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download
Libiconv (PHP character set conversion library)
Http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
"Install Nginx1.4.7"
code is as follows |
copy code |
#安装pcre库 Cd/usr/local/src/nginx TAR-XZVF./pcre-8.33.tar.gz CD./pcre-8.33 ./configure Make && make Inst All #安装zlib库 Cd/usr/local/src/nginx TAR-XZVF./zlib-1.2.8.tar.gz CD./zlib-1.2.8 /configure Make && make install #安装ssl Cd/usr/local/src/nginx tar-xzvf./openssl-1.0.1e.tar.gz #安装Nginx cd/usr/local/src/ Nginx TAR-XZVF./nginx-1.4.7.tar.gz CD./nginx-1.4.7 Mkdir/usr/local/nginx ./configure--prefix=/usr/ Local/nginx--user=www--group=www--sbin-path=/usr/local/nginx/nginx--conf-path=/usr/local/nginx/nginx.conf-- Pid-path=/usr/local/nginx/nginx.pid--with-http_ssl_module--with-pcre=/usr/local/src/nginx/pcre-8.33--with-zlib =/usr/local/src/nginx/zlib-1.2.8--with-openssl=/usr/local/src/nginx/openssl-1.0.1e Make && make Install |
Note that the configuration
The code is as follows |
Copy Code |
--with-pcre=/usr/local/src/nginx/pcre-8.33 --with-zlib=/usr/local/src/nginx/zlib-1.2.8 --with-openssl=/usr/local/src/nginx/openssl-1.0.1e
|
For the source package after the path, not the installation path, or will be an error!
After the Configure command, the following information is exported:
The code is as follows |
Copy Code |
... Configuration Summary + using PCRE library:/usr/local/src/nginx/pcre-8.33 + using OpenSSL Libr ary:/usr/local/src/nginx/openssl-1.0.1e + md5:using OpenSSL library + sha1:using OpenSSL library< br> + using zlib library:/usr/local/src/nginx/zlib-1.2.8 Nginx path prefix: "/usr/local/nginx" Nginx binary file: "/usr/local/nginx/nginx" Nginx configuration prefix: "/usr/local/nginx" Nginx configuration file: "/usr/local/nginx/nginx.conf" Nginx pid file: "/usr/local/nginx/nginx.pid" Nginx error log file: "/usr/local/nginx/logs/error.log" Nginx HTTP access log file: "/usr/local/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@localhost nginx-1.4.7]# |
Www.111cn.net
[Root@localhost nginx-1.4.7]#
The Nginx Configure command supports the following parameters: (can be viewed using the./configure--help command)
--prefix=path defines a directory that holds the files on the server, which is the Nginx installation directory. /usr/local/nginx is used by default.
--sbin-path=path sets the path of the Nginx executable file, which defaults to Prefix/sbin/nginx.
--conf-path=path set the path to the nginx.conf configuration file. Nginx allows you to start with a different configuration file, using the-C option on the command line. Default is prefix/conf/nginx.conf.
--pid-path=path sets the Nginx.pid file, the process number of the main process that will be stored. After the installation is complete, you can change the file name at any time, using the PID directive in the nginx.conf configuration file. By default, the file name is Prefix/logs/nginx.pid.
--error-log-path=path sets the name of the main error, warning, and diagnostic file. After the installation is complete, you can change the file name at any time, using the Error_log directive in the nginx.conf configuration file. By default, the file name is Prefix/logs/error.log.
--http-log-path=path the name of the log file for the HTTP server on which the master request is set. After the installation is complete, you can change the file name at any time, using the Access_log directive in the nginx.conf configuration file. By default, the file name is Prefix/logs/access.log.
--user=name the user who set up the Nginx worker process. The user directive used in the Nginx.conf configuration file can be changed at any time after the installation is complete. The default user name is nobody.
--group=name sets the user group for the Nginx worker process. The user directive used in the Nginx.conf configuration file can be changed at any time after the installation is complete. The default is not a privileged user.
--with-select_module--without-select_module Enable or disable building a module to allow the server to use the Select () method. The module will be automatically built if the platform does not support Kqueue,epoll,rtsig or/dev/poll.
--with-poll_module--without-poll_module Enable or disable building a module to allow the server to use the poll () method. The module will be automatically built if the platform does not support Kqueue,epoll,rtsig or/dev/poll.
--without-http_gzip_module-a response module that does not compile a compressed HTTP server. Compiling and running this module requires a zlib library.
--without-http_rewrite_module does not compile the rewrite module. Compiling and running this module requires PCRE library support.
--without-http_proxy_module-does not compile Http_proxy modules.
--with-http_ssl_module-uses the HTTPS protocol module. By default, the module is not built. It is necessary to establish and run the OpenSSL library for this module.
--with-pcre=path-set the source path for the Pcre library. The source code (version 4.4-8.30) of the Pcre library needs to be downloaded and decompressed from the Pcre website. The rest of the work is nginx./configure and make to complete. Regular expressions are used in location directives and ngx_http_rewrite_module modules.
--with-pcre-jit-compilation Pcre contains "Just-in-time compilation" (1.1.12, Pcre_jit directives).
--with-zlib=path-set the source path for the zlib library. To download and extract from the zlib (version 1.1.3-1.2.5). The rest of the work is nginx./configure and make complete. The Ngx_http_gzip_module module requires the use of zlib.
--with-cc-opt=parameters-setting additional parameters will be added to the cflags variable. For example, when you use a pcre library on a FreeBSD, you need to use:--with-cc-opt= "-i/usr/local/include ... if you need to increase the number of files supported by select ():--with-cc-opt="-D fd_ setsize=2048 ".
--with-ld-opt=parameters-sets the additional parameters that will be used during the link. For example, when using the Pcre Library of the system under FreeBSD, you should specify:--with-ld-opt= "-l/usr/local/lib".
After successful installation, the NGINX directory structure is as follows:
The code is as follows |
Copy Code |
[Root@localhost nginx-1.4.7]# Ll/usr/local/nginx
Total Dosage 6468
-rw-r--r--. 1 root 1034 December 8 14:48 fastcgi.conf
-rw-r--r--. 1 root 1034 December 8 14:48 Fastcgi.conf.default
-rw-r--r--. 1 root 964 December 8 14:48 fastcgi_params
-rw-r--r--. 1 root 964 December 8 14:48 Fastcgi_params.default
Drwxr-xr-x. 2 root 4096 December 8 14:48 HTML
-rw-r--r--. 1 root 2837 December 8 14:48 Koi-utf
-rw-r--r--. 1 root 2223 December 8 14:48 Koi-win
Drwxr-xr-x. 2 root 4096 December 8 14:48 logs
-rw-r--r--. 1 root 3463 December 8 14:48 mime.types
-rw-r--r--. 1 root 3463 December 8 14:48 Mime.types.default
-rwxr-xr-x. 1 root 6540149 December 8 14:48 Nginx
-rw-r--r--. 1 root 2685 December 8 14:48 nginx.conf
-rw-r--r--. 1 root 2685 December 8 14:48 Nginx.conf.default
-rw-r--r--. 1 root 596 December 8 14:48 Scgi_params
-rw-r--r--. 1 root 596 December 8 14:48 Scgi_params.default
-rw-r--r--. 1 root 623 December 8 14:48 Uwsgi_params
-rw-r--r--. 1 root 623 December 8 14:48 Uwsgi_params.default
-rw-r--r--. 1 root 3610 December 8 14:48 Win-utf
[Root@localhost nginx-1.4.7]# #添加nginx用户及用户组 Groupadd www #添加nginx用户组及用户 Useradd-g www-s/usr/sbin/nologin www #不让www用户直接登录 #配置防火墙, open port 80. Vim/etc/sysconfig/iptables Add the following rule to the 22 port below the rule 1-a input-m State--state new-m tcp-p TCP--dport 80-j ACCEPT #重启防火墙 Service Iptables Restart #启动nginx /usr/local/nginx/nginx In the browser input localhost, the following screen appears, indicating Nginx installation success! #设置nginx开机启动 Vim/etc/rc.d/init.d/nginx Edit Startup file Add the following #!/bin/bash www.111Cn.net # nginx Startup script for the Nginx HTTP Server # It is v.0.0.2 version. # Chkconfig:-85 15 # Description:nginx is a high-performance Web and proxy server. # It has a lot of features, but it ' s not for everyone. # Processname:nginx # Pidfile:/var/run/nginx.pid # config:/usr/local/nginx/conf/nginx.conf Nginxd=/usr/local/nginx/nginx Nginx_config=/usr/local/nginx/nginx.conf Nginx_pid=/usr/local/nginx/nginx.pid Retval=0 Prog= "Nginx" # Source function library. . /etc/rc.d/init.d/functions # Source Networking configuration. . /etc/sysconfig/network # Check that networking are up. [${networking} = "No"] && exit 0 [x $nginxd] | | Exit 0 # Start Nginx daemons functions. Start () { If [-e $nginx _pid]; then echo "Nginx already running ..." Exit 1 Fi Echo-n $ "Starting $prog:" Daemon $nginxd-C ${nginx_config} Retval=$? Echo [$RETVAL = 0] && Touch/var/lock/subsys/nginx Return $RETVAL } # Stop Nginx daemons functions. Stop () { Echo-n $ "Stopping $prog:" Killproc $nginxd Retval=$? Echo [$RETVAL = 0] && rm-f/var/lock/subsys/nginx $nginx _pid } Reload () { Echo-n $ "Reloading $prog:" #kill-hup ' Cat ${nginx_pid} ' Killproc $nginxd-hup Retval=$? Echo } # How we were called. Case "$" in Start Start ;; Stop Stop ;; Reload Reload ;; Restart) Stop Start ;; Status Status $prog Retval=$? ;; *) echo $ "Usage: $prog {start|stop|restart|reload|status|help}" Exit 1 Esac Exit $RETVAL |
Save, add to service, set boot up
The code is as follows |
Copy Code |
: wq! #保存退出 chmod 775/etc/rc.d/init.d/nginx #赋予文件执行权限 Chkconfig Nginx on #设置开机启动 /etc/rc.d/init.d/nginx Restart #重启 Service Nginx Restart #重启
|
"Install mysql5.5.25a"
1. Installation CMake
MySQL started with the 5.5 version, and the compiler configuration via./configure has been canceled and replaced by the CMake tool.
Therefore, we first need to compile the source code in the system to install the CMake tool.
The code is as follows |
Copy Code |
#编译安装 Cd/usr/local/src/mysql TAR-XZVF./cmake-2.8.8.tar.gz CD./cmake-2.8.8 ./configure Make && make install |
2, compile and install the configuration MySQL
The code is as follows |
Copy Code |
#切换至 the MySQL source of the Extract directory Cd/usr/local/src/mysql TAR-XZVF./mysql-5.5.25a.tar.gz CD./mysql-5.5.25a #创建所需目录 Mkdir-pv/usr/local/mysql/data #创建mysql用户和mysql组 Groupadd MySQL Useradd-g mysql-s/usr/sbin/nologin MySQL #cmake编译 Cmake-dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/usr/local/mysql/data-ddefault_charset=utf8- Ddefault_collation=utf8_unicode_ci-dwith_readline=1-dwith_ssl=system-dwith_embedded_server=1-denabled_local_ Infile=1-ddefault_collation=utf8_general_ci-dwith_myisam_storage_engine=1-dwith_innobase_storage_engine=1- Dwith_debug=0 #安装 Make && make install #复制配置文件 CP./SUPPORT-FILES/MY-MEDIUM.CNF/ETC/MY.CNF #设置权限 chmod +x/usr/local/mysql Chown-r Mysql:mysql/usr/local/mysql Chown-r Mysql:mysql/usr/local/mysql/data #配置开机自动启动 CP./support-files/mysql.server/etc/init.d/mysqld chmod +x/etc/init.d/mysqld Chkconfig--add mysqld Chkconfig--level 2345 mysqld on Chkconfig--list mysqld #查看是否已应用上 #添加MySQL的软链接以适应init脚本 Ln-sv/usr/local/mysql/bin/mysql/usr/sbin/mysql Ln-sv/usr/local/mysql/bin/mysqladmin/usr/sbin/mysqladmin Ln-sv/usr/local/mysql/bin/mysqldump/usr/sbin/mysqldump #启动Nginx Service mysqld Start #修改配置文件 Vim/etc/my.cnf Add in #在 [mysqld] Node: DataDir =/usr/local/mysql/data Log-error =/usr/local/mysql/data/error.log Pid-file =/usr/local/mysql/data/mysql.pid user = MySQL Tmpdir =/tmp #保存退出 #初始化数据库 /usr/local/mysql/scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data #修改root密码 /usr/local/mysql/bin/mysqladmin-u root-p Password "123456" # Note: The first password is best to use pure numbers, later to use phpMyAdmin to modify online! Configure firewall to open port 3306 Vim/etc/sysconfig/iptables #添加如下规则到22端口这条规则的下面即可 -A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT #重启防火墙 Service iptables Restart # or/etc/init.d/iptables restart Start MySQL Service mysqld Start # or/etc/init.d/mysqld start |
Test whether MySQL is started
#查看是否有mysql进程
The code is as follows |
Copy Code |
Ps-ef | grep MySQL
|
#查看是否有mysql端口
The code is as follows |
Copy Code |
NETSTAT-NTLP | grep 3306
|
#测试mysql, does the mysqladmin,mysqldump command work correctly?
#读取MySQL的版本信息
The code is as follows |
Copy Code |
/usr/local/mysql/bin/mysqladmin version-u Root-p
|
To this MySQL compilation installation is complete.
"Install PHP5.3.28"
###############################################################
# # #1, install PHP dependency Library
The code is as follows |
Copy Code |
########### #################################################### #安装 libmcryp cd/usr/local/src/php TAR-XZVF./ Libmcrypt-2.5.8.tar.gz CD./libmcrypt-2.5.8 ./configure--prefix=/usr Make && make install # Install Mhash cd/usr/local/src/php TAR-XZVF./mhash-0.9.9.9.tar.gz CD./mhash-0.9.9.9 ./configure--prefix= /usr make && make install #安装 mcrypt /sbin/ldconfig #搜索出可共享的动态链接库 cd/usr/local/src/php TAR-XZVF./mcrypt-2.6.8.tar.gz CD./mcrypt-2.6.8 ./configure Make && make install #安装 Lib Iconv cd/usr/local/src/php TAR-XZVF./libiconv-1.14.tar.gz CD./libiconv-1.14 ./configure--prefix=/ Usr/local/libiconv Make && make install |
################################################################
# # #2, install PHP 5.3.28
################################################################
The code is as follows |
Copy Code |
cd/usr/ local/src/php TAR-XZVF./php-5.3.28.tar.gz CD./php-5.3.28 #生成配置 ./configure--prefix=/usr/local/ php-5.3--with-config-file-path=/usr/local/php-5.3/etc--WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D--with-openssl-- With-zlib--with-bz2--with-gd--with-jpeg-dir--with-png-dir--with-gettext- With-mcrypt--with-iconv=/usr/local/libiconv--with-curl--with-curlwrappers--with-xmlrpc--with-mysql=/usr/local/ MySQL--with-pdo-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--enable-zip-- Enable-mbstring--enable-bcmath--enable-soap--enable-sockets--enable-ftp--enable-gd-native-ttf-- Enable-sysvmsg--enable-sysvsem--enable-sysvshm--enable-pcntl--enable-fpm--without-pear #编译安装 Make && make install |
Compile parameter explanation:
./configure--prefix=/usr/local/php-5.3
--with-config-file-path=/usr/local/php-5.3/etc
-- with-config-file-scan-dir=/etc/php.d # This is the time to get rid of it.
--with-openssl
--with-zlib
--with-bz2
--WITH-GD
--with-jpeg-dir
--with-png-dir
--with-gettext
--with-mhash
--with-freetype-dir
-- With-mcrypt
--with-iconv=/usr/local/libiconv
--with-curl
--with-curlwrappers
--with-xmlrpc
-- With-mysql=/usr/local/mysql
--with-pdo-mysql=/usr/local/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_ Config
--enable-zip
--enable-mbstring
--enable-bcmath
--enable-soap
--enable-sockets
--enabl E-ftp
--enable-gd-native-ttf
--enable-shmop
--enable-sysvmsg
--enable-sysvsem
--enable-sysvshm br>--enable-pcntl
--enable-fpm
--without-pear
3, configuring PHP.ini
The code is as follows |
Copy Code |
cd/usr/local/src/php/php-5.3.28 CP./php.ini-production/usr/local/php-5.3/etc/php.ini #复制php配置文件到安装目录 Mv/etc/php.ini/etc/php.ini.bak #删除/Remove system with configuration file Ln-s/usr/local/php-5.3/etc/php.ini/etc/php.ini #添加软链接 |
#编辑配置文件
Vim/usr/local/php-5.3/etc/php.ini
Find: Disable_functions =
Modified to: Disable_functions = Passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini _alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server, Escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space, POSIX_CTERMID,POSIX_GET_LAST_ERROR,POSIX_GETCWD, Posix_getegid,posix_geteuid,posix_getgid, Posix_getgrgid,posix_ Getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, Posix_getppid,posix_getpwnam, Posix_getpwuid, Posix_getrlimit, Posix_getsid,posix_getuid,posix_isatty, Posix_kill,posix_mkfifo,posix_setegid, Posix_seteuid,posix_setgid, Posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname, Posix_uname
#列出PHP可以禁用的函数, if some programs need to use this function, you can remove it and disable it.
Find:;d Ate.timezone =
Modified as: Date.timezone = PRC #设置时区
Find: expose_php = On
Modified to: expose_php = off #禁止显示php版本的信息
4. Configure PHP-FPM
The code is as follows |
Copy Code |
cp/usr/local/php-5.3/etc/php-fpm.conf.default/usr/local/php-5.3/etc/php-fpm.conf #拷贝模板文件为php-fpm configuration file
Vim/usr/local/php-5.3/etc/php-fpm.conf #编辑 user = www #设置php-fpm running account is www Group = www #设置php-fpm run Group is www PID = Run/php-fpm.pid #取消前面的分号 #设置 php-fpm Boot
CP/USR/LOCAL/SRC/PHP/PHP-5.3.28/SAPI/FPM/INIT.D.PHP-FPM/ETC/RC.D/INIT.D/PHP-FPM #拷贝php-fpm to startup directory
chmod +x/etc/rc.d/init.d/php-fpm #添加执行权限
Chkconfig PHP-FPM on #设置开机启动 |
5, configure Nginx support PHP
vi/usr/local/nginx/nginx.conf #编辑配置文件, you need to make the following modifications
User www www. #首行user去掉注释, modify Nginx run group for www www; must be with/usr/local/ The User,group configuration in the php-5.3/etc/php-fpm.conf is the same, otherwise PHP runs wrong.
Index index.php index.html index.htm; #添加index. php
The code is as follows |
Copy Code |
# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # Location ~. php$ { root HTML; Fastcgi_pass 127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_param script_filename $document _root$fastcgi_script_name; Include Fastcgi_params; } |
#取消FastCGI the location of the server section and note that the Fastcgi_param row's arguments are changed to $document_root$fastcgi_script_name, otherwise the absolute path is used.
#补充: Delete a profile under the/ETC/PHP.D folder
code is as follows |
copy code |
Service PHP-FPM start # start PHP-FPM Service nginx restart # restart Nginx |