当前位置:文档之家› LNMP搭建

LNMP搭建

基于安全与优化的LNMP一系统安装为了安全,减少系统漏洞,所以最小化安装系统二搭建LNMP环境1 安装nginx需要的软件包:libtool-ltdl-devellibjpeg-devellibpng-devellibtiff-develfontconfig-develfreetype-devellibXpm-develgettext-developenldap-serversopenssl-devellibX11-devellibgcjlibXau-devellibXdmcp-develxorg-x11-proto-develmesa-libGL-devel安装pcre-8.10[root@server lnmp]#tar zxvf pcre-8.10.tar.bz2 [root@server lnmp]#cd pcre-8.10[root@server lnmp]#./configure && make && make install 安装nginx[root@server lnmp]#useradd nginx[root@server lnmp]# tar xf nginx-0.8.46.tar.gz[root@server lnmp]# cd nginx-0.8.46[root@server nginx-0.8.46]# ./configure \--user=nginx \--group=nginx \--prefix=/usr/local/nginx/ \--with-http_stub_status_module \--with-http_ssl_module[root@server nginx-0.8.46]# make && make install2 编译安装mysql[root@server lnmp]# tar xf mysql-5.1.49.tar.gz[root@server lnmp]# cd mysql-5.1.49[root@server mysql-5.1.49]# ./configure \"--prefix=/usr/local/mysql" \"--localstatedir=/var/lib/mysql/" \"--enable-assembler" \"--with-extra-charsets=all" \"--enable-thread-safe-client" \"--with-client-ldflags=-all-static" \"--with-mysqld-ldflags=-all-static" \"--without-debug" \"--with-big-tables" \"--without-debug" \"--with-ssl"[root@server mysql-5.1.49]# make && make install[root@server mysql-5.1.49]# useradd mysql[root@server mysql-5.1.49]# /usr/local/mysql/bin/mysql_install_db --user=mysql [root@server ~]# cd /usr/local/mysql[root@server mysql]# chown -R root:mysql .[root@server mysql]# chown mysql. /var/lib/mysql -R[root@server mysql]# cp share/mysql/f /etc/f[root@server mysql]# cp share/mysql/mysql.server /etc/init.d/mysqld[root@server mysql]# chmod 755 /etc/init.d/mysqld[root@server mysql]# chkconfig --add mysqld[root@server mysql]# service mysqld start[root@server mysql]# echo 'export PATH=$PATH:/usr/local/mysql/bin' >> ~/.bashrc [root@server mysql]# . ~/.bashrcmysql安装配置完成之后,可以根据实际情况,对mysql做下优化。

3. 编译安装php需要用到的包:libiconvlibmcryptlibltdlmhashspawn-fcgilibevent[root@server libiconv-1.13.1]# ./configure --prefix=/usr[root@server libiconv-1.13.1]# make && make install编译安装libmcrypt:[root@server libmcrypt-2.5.7]# ./configure --prefix=/usr[root@server libmcrypt-2.5.7]# make && make install编译安装mhash:[root@server mhash-0.9.9.9]# ./configure --prefix=/usr/local/mhash [root@server mhash-0.9.9.9]# make && make install编译安装spawn-fcgi:[root@server spawn-fcgi-1.6.3]# ./configure[root@server spawn-fcgi-1.6.3]# make && make install编译安装ibevent:[root@server libevent-1.4.14b-stable]# ./configure --prefix=/usr [root@server libevent-1.4.14b-stable]# make && make install编译安装php:[root@server php-5.2.14]# ./configure \"--prefix=/usr/local/php" \"--enable-fastcgi" \"--enable-fpm" \"--enable-discard-path" \"--enable-force-cgi-redirect" \"--with-config-file-path=/usr/local/php/etc" \"--with-mysql=/usr/local/mysql" \"--with-mysqli=/usr/local/mysql/bin/mysql_config" \"--with-iconv-dir=/usr" \"--with-freetype-dir" \"--with-jpeg-dir" \"--with-png-dir" \"--with-gd" \"--with-zlib" \"--with-libxml-dir" \"--with-curl" \"--with-curlwrappers" \"--with-openssl" \--with-mhash=/usr/local/mhash/ \"--with-xmlrpc" \"--with-mcrypt" \"--with-ldap" \"--with-ldap-sasl" \"--enable-xml" \"--disable-rpath" \"--enable-discard-path" \"--enable-safe-mode" \"--enable-bcmath" \"--enable-shmop" \"--enable-sysvsem" \"--enable-inline-optimization" \"--enable-mbregex" \"--enable-mbstring" \"--enable-gd-native-ttf" \"--enable-ftp" \"--enable-pcntl" \"--enable-sockets" \"--enable-zip" \"--disable-debug" \"--disable-ipv6"[root@server php-5.2.14]# make ZEND_EXTRA_LIBS='-liconv'[root@server php-5.2.14]# make install[root@server php-5.2.14]# cp php.ini-dist /usr/local/php/etc/php.ini其中"--enable-discard-path" 打开这个选项,用户就不能透过浏览器读取.htaccess等和系统安全相关的文件。

"--enable-force-cgi-redirect" 若使用CGI VERSION 模式来执行PHP 的设,打开本选项会增加安全性。

例如用户读http://my.host/cgi-bin/php/secret/doc.html 遇到比较了解PHP 系统的黑客级用户可能会自已输入以下网址http://my.host/secret/doc.html 来读取相关信息。

相关主题