3422 发表于 2016-2-26 10:44:34

CentOS6.x源码编译搭建LNMP环境(详细教程)

(安装Nginx
创建运行用户
useradd -u 8000 -s /sbin/nologin www
支持rewrite
yum install -y pcre-devel zlib-devel
编译参数
./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--with-http_gzip_static_module --with-http_realip_module --user=www
安装
make -j 2 && make install
加入开机启动
echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local echo "export PATH=$PATH:/usr/local/nginx/sbin" >>/etc/profile && source /etc/profile
配置并配置支持PHP
vim /usr/local/nginx/conf/nginx.conf user nginx nginx; 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; } 安装Cmake工具
yum install -y cmake创建运行用户tar xvf /root/lnmp/mysql-5.5.30.tar.gz -C .useradd -s /sbin/nologin mysql
编辑参数
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
安装
make -j 2 && make install
配置运行环境
chown mysql:mysql -R /usr/local/mysql/
cp support-files/my-large.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
修改启动脚本参数
vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
初始化数据库
/usr/local/mysql
/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
开机启动
chkconfig --add mysqld
添加客户端命令
echo "PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile && source /etc/profile
设置mysql密码mysqladmin -u root password mysql(安装libmcrypt
tar xvf libmcrypt-2.5.8.tar.gz -C /usr/local/src/
编译参数./configure --prefix=/usr/local/libmcrypt
安装make -j 2 && make install声明库文件路径
echo /usr/local/mysql/lib >>/etc/ld.so.conf && ldconfig
(安装PHP
安装php所需环境yum install -y libjpeg-turbo-devel curl-devel libxml2-devel libpng-devel freetype-devel编译参数./configure --prefix=/usr/local/php --with-fpm-user=www --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 --with-curlwrappers --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/ 安装
make -j 2 && make install
生成配置文件cp php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
生成php-fpm启动脚本cp /usr/local/src/php-5.4.14/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm chkconfig --add php-fpm


页: [1]
查看完整版本: CentOS6.x源码编译搭建LNMP环境(详细教程)