首页 > 代码库 > Centos下LNMP安装
Centos下LNMP安装
安装nginx
[root@xuegod64 ~]# yum install -y gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre-devel //zlib:给Nginx提供gzip模块,需要的支持;OPenssl提供SSL功能;PCRE,地址重写
[root@xuegod64 ~# tar xvf nginx-1.10.2.tar.gz -C /usr/local/src/ ; cd /usr/local/src/nginx-1.10.2
[root@xuegod64 nginx-1.10.2]# ./configure --prefix=/usr/local/nginx --with-http_dav_module --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module
[root@xuegod64 nginx-1.10.2]# make && make install ;cd
[root@xuegod64 ~]# useradd -u 8001 -M -s /sbin/nologin nginx
[root@xuegod64 ~]# vim /usr/local/nginx/conf/nginx.conf
#user nobody;
user nginx nginx; #此行添加
…… #下面这段内容,需要去掉注释,然后修改script_filename
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
[root@xuegod64 ~]# /usr/local/nginx/sbin/nginx
[root@xuegod64 ~]# echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local
[root@xuegod64 ~]# setenforce 0
[root@xuegod64 ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@xuegod64 ~]# chkconfig iptables off
安装mysql
[root@xuegod64 ~]# yum remove -y mysql mysql-devel mysql-server
[root@xuegod64 ~]# tar xvf mysql-5.6.26.tar.gz -C /usr/local/src/ ; cd /usr/local/src/mysql-5.6.26
[root@xuegod64 mysql-5.6.26]# useradd -u 8003 -M -s /sbin/nologin mysql
[root@xuegod64 mysql-5.6.26]# yum install -y cmake
[root@xuegod64 mysql-5.6.26]# yum -y install ncurses-devel
[root@xuegod64 mysql-5.6.26]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql
[root@xuegod64 mysql-5.6.26]# make -j 4 ; make install
[root@xuegod64 mysql-5.6.26]# chown -R mysql:mysql /usr/local/mysql/
[root@xuegod64 mysql-5.6.26]# cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
[root@xuegod64 mysql-5.6.26]# cp /usr/local/mysql/support-
files/mysql.server /etc/init.d/
[root@xuegod64 mysql-5.6.26]# cd ; vim /etc/init.d/mysql.server
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
[root@xuegod64 ~]# chkconfig mysql.server on
[root@xuegod64 ~]# /usr/local/mysql/scripts/mysql_install_db
--defaults-file=/etc/my.cnf --basedir=/usr/local/mysql
--datadir=/usr/local/mysql/data --user=mysql
[root@xuegod64 tmp]# ln -s /tmp/mysql.sock /var/lib/mysql/
[root@xuegod64 tmp]# service mysql.server restart
ERROR! MySQL server PID file could not be found!
Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/xuegod64.com.pid).
解决方法:
[root@xuegod64 ~]# mv /etc/my.cnf /etc/my.cnf.backup
[root@xuegod64 ~]# service mysql.server restart
ERROR! MySQL server PID file could not be found!
Starting MySQL. SUCCESS!
[root@xuegod64 ~]# /usr/local/mysql/bin/mysql_secure_installation
安装PHP
[root@xuegod64 ~]# tar xvf libmcrypt-2.5.8.tar.gz -C /usr/local/src/ ;
cd /usr/local/src/libmcrypt-2.5.8/
[root@xuegod64 libmcrypt-2.5.8]# ./configure
--prefix=/usr/local/libmcrypt
[root@xuegod64 libmcrypt-2.5.8]# make ; make install ; cd
[root@xuegod64 ~]# tar xvf php-5.6.13.tar.bz2 -C /usr/local/src/ ;cd /usr/local/src/php-5.6.13/
[root@xuegod64 php-5.6.13]# yum install -y php-pear libjpeg-devel libxml2 libxml2-devel curl curl-devel libpng-devel freetype-devel
[root@xuegod64 php-5.6.13]# echo "/usr/local/mysql/lib/" >> /etc/ld.so.conf
[root@xuegod64 php-5.6.13]# echo "/usr/local/libmcrypt/lib" >> /etc/ld.so.conf
[root@xuegod64 php-5.6.13]# ldconfig
[root@xuegod64 php-5.6.13]# echo "ldconfig" >> /etc/rc.local
[root@xuegod64 php-5.6.13]# ./configure --prefix=/usr/local/php -with-config-file-path=/usr/local/php --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir --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-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-mcrypt=/usr/local/libmcrypt --with-gettext
[root@xuegod64 php-5.6.13]# make && make install
[root@xuegod64 php-5.6.13]# cp /usr/local/src/php-5.6.13/php.ini-production /usr/local/php/php.ini
[root@xuegod64 php-5.6.13]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@xuegod64 php-5.6.13]# cp /usr/local/src/php-5.6.13/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@xuegod64 php-5.6.13]# chmod +x /etc/init.d/php-fpm ; cd
[root@xuegod64 ~]# chkconfig --add php-fpm
[root@xuegod64 ~]# chkconfig php-fpm on
[root@xuegod64 ~]# echo "<?php phpinfo(); ?>" > /usr/local/nginx/html/index.php
[root@xuegod64 ~]# service php-fpm start
Starting php-fpm done
Centos下LNMP安装