lnamp完整版[linux+apache2.4+php5.6.6+mysql5.6]
Lnamp环境安装实录 将采用的开源软件:
Apache [WEB动态脚本服务器,做nginx的反向代理 8080端口]
Tengine [WEB静态文件服务器 80端口]
MySQL
PHP
.Apache安装 A.apr安装
wget -c http://mirror.bjtu.edu.cn/apache/apr/apr-1.5.1.tar.gz
tar -zxvf apr-...tar.gz
cd apr-1.5. ./configure --prefix=/usr/local/apr
make
make install B.apr-util安装 wget -c wget http://mirror.bjtu.edu.cn/apache/apr/apr-util-1.5.4.tar.gz tar -zxvf apr-util-1.5..tar.gz cd apr-util-1.5. ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make make install C.pcre安装 wget -c ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz tar -zxvf pcre-8.36.tar.gz cd pcre-8.36 ./configure --prefix=/usr/local/pcre make make install D.apache安装 wget -c http://mirror.symnds.com/software/Apache//httpd/httpd-2.4.10.tar.gz tar -zxvf httpd-2.4..tar.gz cd httpd-2.4. ./configure --prefix=/usr/local/apache --enable-so-rewrite=shared --with-mpm=prefork
--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre 如果提示openssl(旧版),运行 yum install openssl-devel yum update openssl make make install E.把apache加入系统service,开机自启动 cp /usr/local/apache/bin/apachectl /etc/init.d/httpd vim /etc/init.d/httpd # beyound # chkconfig: # description: Apache is a World Wide Web server. chmod +x /etc/init.d/httpd /sbin/chkconfig --add httpd /sbin/chkconfig --list httpd ln -s /sbin/chkconfig /usr/bin/chkconfig ln -s /sbin/service /usr/bin/service .MySQL安装 A.准备工作 安装一些必须的软件: yum install cmake automake autoconf libtool gcc g++ bison yum install ncurses-devel mkdir -p /data/mysql mkdir -p /var/run/mysqld groupadd mysql //添加一个mysql标准组 useradd -g mysql mysql //添加mysql用户并加到mysql组中 B.下载安装 wget -c http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.11.tar.gz/from/http://cdn.mysql.com/ tar -zxvf mysql-5.6..tar.gz cd mysql-5.6. cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql #安装路径 -DMYSQL_DATADIR=/data/mysql/ #数据文件存放位置 -DSYSCONFDIR=/etc #my.cnf路径 -DWITH_MYISAM_STORAGE_ENGINE= #支持MyIASM引擎 -DWITH_INNOBASE_STORAGE_ENGINE= #支持InnoDB引擎 -DWITH_MEMORY_STORAGE_ENGINE= #支持InnoDB引擎 -DWITH_READLINE= #快捷键功能(我没用过) -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock #连接数据库socket路径 -DMYSQL_TCP_PORT= #端口 -DENABLED_LOCAL_INFILE= #允许从本地导入数据 -DWITH_PARTITION_STORAGE_ENGINE= #安装支持数据库分区 -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk #安装需要的字符集 -DDEFAULT_CHARSET=utf8 #默认字符 -DDEFAULT_COLLATION=utf8_general_ci #默认字符集-DMYSQL_USER=mysql 如果安装过程中报错,解决错误后重新cmake前需删除CMakeCache.txt文件 make make install C.配置 配置文件 这一步中需要注意的是my.cnf的加载顺序,Linux优先级从高到低
/etc/my.cnf->/etc/mysql/my.cnf->SYSCONFDIR/my.cnf->$MYSQL_HOME/my.cnf,
高优先级的my.cnf设置会覆盖低优先级的my.cnf,所以一般把config文件copy到etc中即可。 #如果/etc下没有my.cnf cp support-files/my-medium.cnf /etc/my.cnf vim /etc/my.cnf [client] default-character-set=utf8 port= [mysqld_safe] log-error=/var/log/www/mysql/mysqld.log pid-file=/var/run/mysqld/mysqld.pid [mysqld] datadir=/var/lib/mysql #socket=/var/lib/mysql/mysql.sock socket=/tmp/mysqld.sock user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links= wait-timeout = max_connections = max_allowed_packet=64M slow_query_log slow_query_log_file=/var/log/www/mysql/slow.log log-error = /var/log/www/mysql/error.log #数据目录的权限 chown mysql.mysql -R /data/mysql chown -R mysql:mysql /var/run/mysqld chmod +x /usr/local/mysql chown -R mysql.mysql /usr/local/mysql #数据初始化 /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf
--basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql #设置软连接使mysql, mysqldump, mysqladmin这三个bin命令能在shell中直接运行 ln -s /usr/local/mysql/bin/mysql /usr/bin ln -s /usr/local/mysql/bin/mysqldump /usr/bin ln -s /usr/local/mysql/bin/mysqladmin /usr/bin #启动MySQL /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf
--user=mysql --datadir=/data/mysql & #配置开机自启动 vim /etc/rc.local 添加 /usr/local/mysql/bin/mysqld_safe
--defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql & #修改mysql密码 UPDATE user SET password=PASSWORD("newpassword") WHERE user='root'; FLUSH PRIVILEGES; create database db_test; B.创建一个新用户用于管理 db_test 数据库 insert into mysql.user(Host,User,Password)
values("localhost","admin",password("newpassword")); flush privileges; C.赋予权限 grant all privileges on db_test.* to db_test@localhost identified by 'newpassword';
.Tengine[Nginx]安装 A.准备工作 需要下载的东西 wget -c http://zlib.net/zlib-1.2.8.tar.gz tar -zxvf zlib-1.2..tar.gz wget -c http://www.openssl.org/source/openssl-1.0.1e.tar.gz tar -zxvf openssl-1.0.1e.tar.gz wget http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz tar zxvf ngx_cache_purge-2.3.tar.gz groupadd www //添加一个www标准组 useradd -g www www //添加www用户并加到www组中 B.下载安装 wget -c http://tengine.taobao.org/download/tengine-2.1.0.tar.gz tar -zxvf tengine-2.1..tar.gz cd tengine-2.1. ./configure --user=www --group=www --prefix=/usr/local/nginx
--with-http_stub_status_module --with-http_sub_module --with-http_realip_module
--with-http_flv_module --with-http_dav_module --with-http_gzip_static_module
--with-http_addition_module --with-http_ssl_module
--with-openssl=../openssl-1.0.1h
--with-pcre=../pcre-8.36
--with-zlib=../zlib-1.2.
--add-module=/usr/local/src/ngx_cache_purge-2.3 make make install C.配置 vim /etc/init.d/nginx #! /bin/sh # Author: rui ding # Modified: Geoffrey Grosenbach http://topfunky.com # Modified: Clement NEDELCU # Reproduced with express authorization from its contributors set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="nginx daemon" NAME=nginx DAEMON=/usr/local/nginx/sbin/$NAME SCRIPTNAME=/etc/init.d/$NAME # If the daemon file is not found, terminate the script. test -x $DAEMON || exit start() {
$DAEMON || echo -n " already running"
} stop() { $DAEMON -s quit || echo -n " not running"
} reload() {
$DAEMON -s reload || echo -n " could not reload"
} case "$1" in start) echo -n "Starting $DESC: $NAME" start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" stop echo "."
;; reload) echo -n "Reloading $DESC configuration..." reload echo "reloaded."
;; restart) echo -n "Restarting $DESC: $NAME" stop # Sleep for two seconds before starting again, this should give the # Nginx daemon some time to perform a graceful stop. sleep start
echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >& exit ;; esac exit chmod +x /etc/init.d/nginx service nginx start service nginx reload service nginx restart service nginx stop vim /etc/rc.local 添加一行 /usr/local/nginx/sbin/nginx & .PHP编译安装 A.yum安装相关库包 yum install gd-devel php-gd yum install zlib zlib-devel yum install freetype-devel freetype-demos freetype-utils yum install libpng libpng-devel libpng10 libpng10-devel yum install libjpeg libjpeg-devel yum install ImageMagick yum install flex yum install ImageMagick-devel yum install libxml2 libxml2-devel yum install libxml2 curl curl-devel yum -y install libtool libtool-ltdl-devel yum install mhash-devel yum install patch B.可能需要源码编译的包 wget -c ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz tar -zxvf libmcrypt-2.5..tar.gz cd libmcrypt-2.5. ./configure --prefix=/usr/local/libmcrypt make && make install wget -c http://iweb.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz tar -zxvf mhash-0.9.9.9.tar.gz cd mhash-0.9.9.9 ./configure --prefix=/usr/local/libmhash make && make install C.编译安装 wget -c http://cn2.php.net/get/php-5.6.6.tar.gz/from/this/mirror tar -zxvf php-5.6..tar.gz cd php-5.6. ./configure --prefix=/usr/local/php
--with-config-file-path=/usr/local/php/etc
--with-mysql=/usr/local/mysql/
--with-mysqli=/usr/local/mysql/bin/mysql_config
--with-apxs2=/usr/local/apache/bin/apxs
--with-iconv-dir=/usr/local
--with-freetype-dir
--with-jpeg-dir --with-png-dir --with-zlib
--with-libxml-dir=/usr --enable-xml --disable-rpath
--enable-discard-path --enable-safe-mode --enable-bcmath
--enable-shmop --enable-sysvsem --enable-sysvshm
--enable-sysvmsg --enable-inline-optimization
--with-curl --with-curlwrappers --enable-mbregex --enable-fpm
--enable-fastcgi --enable-force-cgi-redirect
--enable-mbstring --with-mcrypt=/usr/local/libmcrypt
--with-gd --enable-gd-native-ttf --with-openssl
--with-mhash --enable-pcntl --enable-sockets
--with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap
--enable-ftp --enable-sigchild
--with-pear --enable-cli --enable-exif
--enable-calendar --with-bz2 --enable-pdo
--with-pdo-mysql --enable-freetype --disable-fileinfo configure: error: Cannot find ldap.h yum install openldap yum install openldap-devel Configure: error: Please reinstall the BZip2 distribution
centos: yum install bzip2 bzip2-devel 错误:configure: error: Cannot find ldap libraries in /usr/lib 解决办法:cp -frp /usr/lib64/libldap* /usr/lib/ 错误:configure: error: Unable to find your mysql installation 解决办法:ln -s /usr/local/mysql/bin/mysql_config /usr/bin/mysql_config 编译出错后重新编译时需先make clean再make make make install 修改apache的配置文件httpd.conf vim /usr/local/apache/conf/httpd.conf
然后在文本最后面添加 LoadModule php5_module modules/libphp5.so
(注意,在apache安装目录下,modules下有libphp5.so,这是php安装时添加进去的,如果没有,php,你需要重装下) AddType application/x-httpd-php .php
AddType application/x-httpd-php .html cp php.ini-production /usr/local/php/etc/php.ini .环境整合 A.整合apache mkdir -p /home/www/test.com chown -R www.www /home/www apache将被nginx代理,因此将apache的默认监听端口改为8080 vim /usr/local/apache/conf/httpd.conf 将hosts定向到 Include conf/extra/httpd-vhosts.conf Listen User www Group www <IfModule dir_module> DirectoryIndex index.php index.html index.htm </IfModule> vim /usr/local/apache/conf/extra/httpd-vhosts.conf 将里面的*:80全部改成yourdomain.name: 并添加虚拟hosts <VirtualHost *:> ServerAdmin webmaster@a.test.com DocumentRoot "/home/www/test.com" DirectoryIndex index.php index.html ServerName a.test.com <Directory "/home/www/test.com"> AllowOverride None Options None Require all granted </Directory> ErrorLog "/var/log/www/apache/a.test.com-error_log" CustomLog "/var/log/www/apache/a.test.com-access_log" common </VirtualHost> vim /home/www/test.com/phpinfo.php <?php
echo phpinfo();
?> service httpd start
访问http://a.test.com:8080/phpinfo.php B.配置php-fpm cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #开启php-fpm慢脚本日志 request_slowlog_timeout = slowlog = /var/log/www/php/php-fpm.log.slow #脚本等待时间 request_terminate_timeout = pid = /usr/local/php/var/run/php-fpm.pid error_log = /var/log/www/php/php-fpm.log.error log_level = notice user = www group = www listen = 127.0.0.1: pm = dynamic pm.max_children = pm.start_servers = pm.min_spare_servers = pm.max_spare_servers = pm.max_requests = /usr/local/php/sbin/php-fpm #将php-fpm整合成系统服务 vim /etc/init.d/php-fpm #! /bin/sh ### BEGIN INIT INFO # Provides: php-fpm # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Default-Start: # Default-Stop: # Short-Description: starts php-fpm # Description: starts the PHP FastCGI Process Manager daemon ### END INIT INFO prefix=/usr/local/php exec_prefix=${prefix} php_fpm_BIN=${exec_prefix}/sbin/php-fpm php_fpm_CONF=${prefix}/etc/php-fpm.conf php_fpm_PID=${prefix}/var/run/php-fpm.pid php_opts="--fpm-config $php_fpm_CONF" wait_for_pid () { try= while test $try -lt ; do case "$1" in 'created') if [ -f "$2" ] ; then try='' break fi ;; 'removed') if [ ! -f "$2" ] ; then try='' break fi ;; esac echo -n . try=`expr $try + ` sleep done } case "$1" in start) echo -n "Starting php-fpm " $php_fpm_BIN $php_opts if [ "$?" != ] ; then echo " failed" exit fi wait_for_pid created $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit else echo " done" fi ;; stop) echo -n "Gracefully shutting down php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit fi kill -QUIT `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed. Use force-quit" exit else echo " done" fi ;; force-quit) echo -n "Terminating php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit fi kill -TERM `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit else echo " done" fi ;; restart) $ stop $ start ;; reload) echo -n "Reload service php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit fi kill -USR2 `cat $php_fpm_PID` echo " done" ;; *) echo "Usage: $0 {start|stop|force-quit|restart|reload}" exit ;; esac chmod +x /etc/init.d/php-fpm service php-fpm start service php-fpm stop service php-fpm reload service php-fpm restart #开机启动 vim /etc/rc.local 添加一行 /usr/local/php/sbin/php-fpm & C.Nginx整合 mkdir /usr/local/nginx/conf/vhosts vim /usr/local/nginx/conf/nginx.conf user www www; worker_processes ; error_log /var/log/www/nginx/error.log crit; #error_log /var/log/www/nginx/error.log notice; #error_log /var/log/www/nginx/error.log info; #pid logs/nginx.pid; worker_rlimit_nofile ; events { use epoll; worker_connections ; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; server_names_hash_bucket_size ; client_header_buffer_size 32k; large_client_header_buffers 32k; client_max_body_size 8m; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout ; fastcgi_connect_timeout ; fastcgi_send_timeout ; fastcgi_read_timeout ; fastcgi_buffer_size 64k; fastcgi_buffers 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; gzip on; gzip_min_length 1k; gzip_buffers 16k; gzip_http_version 1.0; gzip_comp_level ; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; include vhosts/*.conf; }
vim /usr/local/nginx/conf/vhosts/a.test.com.conf #反向代理 upstream www.test { a.test.com:8080; } server { listen 80; server_name www.test.com; charset utf-8; root /home/www/www.test; location / { index index.php index.html index.htm; if (!-e $request_filename) { #rewrite ^(.*)$ /index.php?s=$1 last; #break; } } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { #開啟支持php fastcgi_pass 127.0.0.1:9000; #php fastcgi服務地址及端口 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } service nginx reload D.Apache+nginx+php反向代理 vim /usr/local/nginx/conf/vhosts/a.test.com.conf #反向代理 upstream www.test{ server a.test.com:8080; } server { listen 80; server_name www.test.com; charset utf-8; root /home/www/test.com; location / { index index.php index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { #fastcgi_pass 127.0.0.1:9000; #php fastcgi服務地址及端口 #fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #include fastcgi_params; proxy_pass http://www.test; #apache反向代理 proxy_pass_header User-Agent; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 512k; proxy_buffers 4 512k; proxy_busy_buffers_size 512k; proxy_temp_file_write_size 512k; } } service nginx reload 再访问 http://www.test.com/phpinfo.php 系统已经用apache来解析动态请求了,反向代理配置正确 完成
lnamp完整版[linux+apache2.4+php5.6.6+mysql5.6]的更多相关文章
- discuz X3.1+Apache2.2+php-5.2.17+mysql5.6.14+Discuz_X3.1
discuz X3.1+Apache2.2.25+php-5.2.17+mysql5.6.14+Discuz_X3.1 一.准备 1.httpd-2.2.25-win32-x86-no_ssl.msi ...
- Linux+Apache2.4+PHP5.6+MySQL5.6源码安装步骤
一.安装Apache 若要安装apache服务器软件,需要安装以下几个依赖软件 apr-1.4.6.tar.gz 下载地址:http://apr.apache.org/ apr-util-1.4.1. ...
- 【PHP】linux+php5.1.6+mysql5.0.2+apache2.0.55安装配置说明(转)
linux+php5.1.6+mysql5.0.2+apache2.0.55安装配置说明:一.mysql5.0.2的安装配置过程及说明:1. #tar -zvxf mysql-5.0.2-alpha. ...
- linux centos7环境下安装apache2.4+php5.6+mysql5.6 安装及踩坑集锦(三)
linux centos7环境下安装apache2.4+php5.6+mysql5.6 安装及踩坑集锦(三) 安装PHP 1.yum方式安装PHP方法同安装apache一样传送门:linux cent ...
- linux centos7环境下安装apache2.4+php5.6+mysql5.6 安装及踩坑集锦
linux centos7环境下安装apache2.4+php5.6+mysql5.6 安装及踩坑集锦(一) 一.Linux下安装MySQL 1.下载 下载地址:http://dev.mysql.co ...
- Linux学习总结(1)——Linux命令大全完整版
Linux命令大全完整版 目 录I 1. linux系统管理命令1 adduser1 chfn(change finger information)1 chsh(change shell)1 d ...
- linux centos7环境下安装apache2.4+php5.6+mysql5.6 安装及踩坑集锦(二)
linux centos7环境下安装apache2.4+php5.6+mysql5.6 安装及踩坑集锦(二) 安装apache web容器 . yum方式安装apache 注意apache在linux ...
- Ubuntu 16.04 环境下配置apache2.4 + php5.6
相信用惯了Windows的朋友一开始接触Linux是很崩溃的,因为很多东西都是通过命令行来完成的,包括安装绝大多数的开发工具以及环境,那么在Ubuntu下其实可以直接通过apt-get指令来安装apa ...
- Ubuntu+Apache+PHP+Mysql环境搭建(完整版)
Ubuntu+Apache+PHP+Mysql环境搭建(完整版) 一.操作系统Ubuntu 14.04 64位,阿里云服务器 二.Apache 1.安装Apache,安装命令:sudo apt-get ...
随机推荐
- leetcode-mid-others-169. Majority Element¶
mycode 54.93% class Solution(object): def majorityElement(self, nums): """ :type num ...
- ACL 2019 分析
ACL 2019 分析 word embedding 22篇! Towards Unsupervised Text Classification Leveraging Experts and Word ...
- 微博获取原图时重定向到图片的url
微博获取原图时重定向到图片的url,所以获取的是乱码 jsoup默认是执行重定向的. //根据Url获取页面对应的Document public static Document getDoc1(Str ...
- C# .Net动态调用webService实现思路及代码
加载: using System; using System.Collections.Generic; using System.Linq; using System.Web; using Syste ...
- fiddler之入门(安装配置)
在工作中常常需要进行数据的抓包和发包,此时就可以用到fiddler这个工具了. fiddler是一个http协议调试代理工具,通过http代理,让数据从其通过,来坚挺本地计算机与访问网络之间的所有ht ...
- 【FIORI系列】SAP OpenUI5 (SAPUI5) js框架简单介绍
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[FIORI系列]SAP OpenUI5 (SA ...
- LeetCode算法题-Peak Index in a Mountain Array(Java实现)
这是悦乐书的第329次更新,第352篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第199题(顺位题号是852).如果以下属性成立,我们将数组A称为山: A.length ...
- 【Linux 环境搭建】ubuntu 的samba配置
在/etc/samba/smb.conf的文件末尾增加下面的内容然后重启samba [home] comment = James Harden path = / browseable = yes wr ...
- [转帖]TLS握手:回顾1.2、迎接1.3
TLS握手:回顾1.2.迎接1.3 novsec2019-05-10共26541人围观 ,发现 2 个不明物体网络安全 *本文原创作者:novsec,本文属于FreeBuf原创奖励计划,未经许可禁止转 ...
- javascript中的继承-寄生组合式继承
前文说过,组合继承是javascript最常用的继承模式,不过,它也有自己的不足:组合继承无论在什么情况下,都会调用两次父类构造函数,一次是在创建子类原型的时候,另一次是在子类构造函数内部.子类最终会 ...