centos下源码搭建lnmp环境

xiaoxiao2021-02-28  81

以上来自阿里云centOS 7.0 x64系统的nginx1.8.0+php5.6.18+mysql5.6.29环境搭建手稿

yum update //更新源

//安装编译php需要的依赖 yum install -y gcc gcc-c++ yum install -y autoconf yum install -y libxml2-devel yum install -y libjpeg-devel

yum install -y libpng-devel yum install -y freetype-devel yum install -y libcurl-devel yum install -y libmcrypt-devel

注意:如果这里出现错误,执行 yum install epel-release yum update后重新执行刚才出错的指令。 继续安装: yum -y install perl perl-devel

yum install -y openssl openssl-devel

mkdir /usr/local/dev cd /usr/local/dev //安装其他所需要的依赖 apr安装:下载地址:http://mirrors.hust.edu.cn/apache//apr/apr-1.5.2.tar.gz wget http://mirrors.hust.edu.cn/apache//apr/apr-1.5.2.tar.gz tar -zxvf apr-1.5.2.tar.gz cd apr-1.5.2 ./configure –prefix=/usr/local/apr make && make install apr-util安装:下载地址:http://mirrors.cnnic.cn/apache//apr/apr-util-1.5.4.tar.gz cd /usr/local/dev wget http://mirrors.cnnic.cn/apache//apr/apr-util-1.5.4.tar.gz tar -zxvf apr-util-1.5.4.tar.gz cd apr-util-1.5.4 ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr make && make install zlib安装:下载地址:http://zlib.net/zlib-1.2.8.tar.gz cd /usr/local/dev wget http://zlib.net/zlib-1.2.8.tar.gz tar zlib-1.2.8.tar.gz cd zlib-1.2.8 ./configure –prefix=/usr/local/zlib make && make install pcre安装:下载地址:http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz cd /usr/local/dev wget http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz tar -zxvf pcre-8.37.tar.gz cd pcre-8.37 ./configure –prefix=/usr/local/pcre make && make install libzip安装 下载地址:http://www.nih.at/libzip/libzip-1.1.2.tar.gz cd /usr/local/dev wget http://www.nih.at/libzip/libzip-1.1.2.tar.gz tar -zxvf libzip-1.1.2.tar.gz cd libzip-1.1.2/ ./configure –prefix=/usr/local/libzip 如果出现错误:configure: error: ZLIB version too old, please install at least v1.1.2 编译参数换成:./configure –prefix=/usr/local/libzip –with-zlib=/usr/local/zlib make && make install

可选依赖(可跳过): libdatrie安装:https://github.com/wulijun/php-ext-trie-filter cd /usr/local/dev wget http://linux.thai.net/pub/thailinux/software/libthai/libdatrie-0.2.9.tar.xz xz -d libdatrie-0.2.9.tar.xz tar -xvf libdatrie-0.2.9.tar cd libdatrie-0.2.9/ ./configure –prefix=/usr/local/libdatrie make && make install

下面安装nginx:

// 安装nginx 下载地址 http://nginx.org/download/nginx-1.8.0.tar.gz cd /usr/local/dev wget http://nginx.org/download/nginx-1.8.0.tar.gz tar -zxvf nginx-1.8.0.tar.gz cd nginx-1.8.0 ./configure –prefix=/usr/local/nginx –with-pcre=/usr/local/dev/pcre-8.37 –with-http_auth_request_module –with-http_gzip_static_module –with-http_secure_link_module –with-zlib=/usr/local/dev/zlib-1.2.8 –with-openssl=/usr/local/dev/openssl-1.0.2j make make install

nginx配置: cd /usr/local/nginx mkdir vhost vim conf/nginx.conf [ user nobody 改为 user www www; 并去掉前面的#号 取消注释error_log logs/error.log; 取消注释:pid logs/nginx.pid; 取消注释:gzip on,在下面加:     gzip_comp_level 5; gzip_types text/xml text/plain text/css application/javascript application/x-javascript application/rss+xml; gzip_http_version 1.1; gzip_disable “MSIE [1-6].”; client_max_body_size 30m; include ../vhost/*.conf; 删除下面的事例配置,保存 ] vim vhost default.conf 添加一下内容: server { listen 80; server_name 127.0.0.1; root /www/wwwroot/empty; charset utf-8; access_log logs/default.access.log; index index.php index.html index.htm; location / { if (!-e $request_filename) { rewrite ^(.*) /index.php?s=$1; } }

location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; include fastcgi_params; }

} ………………………………………………………………………………………………….. /usr/local/nginx/sbin/nginx 启动nginx /usr/local/nginx/sbin/nginx -s reload 重启nginx 如果重启过程中提示找不到nginx.pid文件 ,说明配置文件路径找不到,需要执行: /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 就可以了。 mkdir -p /www/wwwroot/empty

/* mysql下载 http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz cd /usr/local wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz tar -zxvf mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz ln -s mysql-5.6.29-linux-glibc2.5-x86_64 mysql groupadd mysql useradd -r -g mysql -s /sbin/nologin mysql cd mysql mkdir logs scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql –datadir=/usr/local/mysql/data

chown -R mysql.mysql * vim my.cnf [ [mysqld] basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3306 character_set_server = utf8 explicit_defaults_for_timestamp = true log-error = /usr/local/mysql/logs/mysqld.log socket=/tmp/mysql.sock

[mysql] default_character_set = utf8 socket=/tmp/mysql.sock

[client] default_character_set = utf8

[safe_mysqld] err-log=/usr/local/mysql/logs/mysqld.log pid-file=/usr/local/mysql/logs/mysqld.pid

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

] rm -f /etc/my.cnf ln -s /usr/local/mysql/my.cnf /etc/ 启动:bin/mysqld_safe & ln -s /usr/local/mysql/bin/mysql /usr/bin/ 添加软连接

//安装php 下载地址: http://cn2.php.net/get/php-5.6.18.tar.gz/from/this/mirror cd /usr/local/dev wget http://cn2.php.net/get/php-5.6.18.tar.gz/from/this/mirror mv mirror php-5.6.18.tar.gz tar -zxvf php-5.6.18.tar.gz cd php-5.6.18 ./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/conf –with-config-file-scan-dir=/usr/local/php/conf/extension –enable-inline-optimization –disable-debug –disable-rpath –enable-shared –enable-opcache –enable-fpm –with-fpm-user=www –with-fpm-group=www –with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-pdo-mysql=/usr/local/mysql/bin/mysql_config –with-gettext –enable-mbstring –with-iconv –with-mcrypt –with-mhash –enable-bcmath –enable-soap –with-libxml-dir –enable-pcntl –enable-shmop –enable-sysvmsg –enable-sysvsem –enable-sysvshm –enable-sockets –with-curl –with-zlib=/usr/local/zlib –with-gd –with-jpeg-dir=/usr/local/jpeg6 –with-png-dir=/usr/local/png –with-libxml-dir=/usr/local/libxml –with-zlib-dir=/usr/local/zlib –with-libzip=/usr/local/libzip –with-freetype-dir=/usr/local/freetype –enable-opcache=no –with-ldap make && make install

centos6.5下执行会报找不到libmysqlclient.so.18的错误,解决方案如下: ln -s /usr/local/mysql-5.6.29-linux-glibc2.5-x86_64/lib/libmysqlclient.so.18 /usr/lib64/ 有时候会报错找不到ext/phar/phar.phar 则执行: mkdir ext/phar/phar.phar -p

mkdir -p /usr/local/php/conf/extension cp php.ini-development /usr/local/php/conf/php.ini cp sapi/fpm/php-fpm /usr/bin/ cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

ln -s /usr/local/php/bin/php /usr/bin

其他安装: php libdatrie扩展: wget https://github.com/wulijun/php-ext-trie-filter/archive/master.zip unzip master.zip /usr/local/php/bin/phpize ./configure –with-php-config=/usr/local/php/bin/php-config –with-trie_filter=/usr/local/libdatrie make && make install make -p /usr/local/php/conf/extension vim /usr/local/php/conf/extension/trie_filter.ini [ extension=trie_filter.so ] 其他PHP扩展也都是这样安装,其他扩展下载地址: https://pecl.php.net/package-stats.php

php-fpm /usr/local/nginx/sbin/nginx

上面的php源码包和mysql源码包,特别是mysql,建议在本地使用迅雷下载好后使用scp命令或者在服务器上安装vsftpd把下载好的源码包上传到服务器,mysql的源码包下载非常慢

转载请注明原文地址: https://www.6miu.com/read-19296.html

最新回复(0)