Ubuntu 下 LNMP 开发环境源码安装

分享 紫云互联 ⋅ 于 2017-11-03 11:35:00 ⋅ 3950 阅读

安装Nginx

wget http://nginx.org/download/nginx-1.8.0.tar.gz wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.8.tar.gz wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz tar zxvf zlib-1.2.8.tar.gz tar zxvf pcre-8.37.tar.gz tar zxvf nginx-1.8.0.tar.gz cd nginx-1.8.0 ./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_dav_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-pcre=../pcre-8.37 --with-zlib=../zlib-1.2.8 --with-debug --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi make make install

--prefix #nginx安装目录,默认在/usr/local/nginx
--pid-path #pid问件位置,默认在logs目录
--lock-path #lock问件位置,默认在logs目录
--with-http_ssl_module #开启HTTP SSL模块,以支持HTTPS请求。
--with-http_dav_module #开启WebDAV扩展动作模块,可为文件和目录指定权限
--with-http_flv_module #支持对FLV文件的拖动播放
--with-http_realip_module #支持显示真实来源IP地址
--with-http_gzip_static_module #预压缩文件传前检查,防止文件被重复压缩
--with-http_stub_status_module #取得一些nginx的运行状态
--with-mail #允许POP3/IMAP4/SMTP代理模块
--with-mail_ssl_module #允许POP3/IMAP/SMTP可以使用SSL/TLS
--with-pcre=../pcre-8.37 #注意是未安装的pcre路径
--with-zlib=../zlib-1.2.8 #注意是未安装的zlib路径
--with-debug #允许调试日志
--http-client-body-temp-path #客户端请求临时文件路径
--http-proxy-temp-path #设置http proxy临时文件路径
--http-fastcgi-temp-path #设置http fastcgi临时文件路径
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi #设置uwsgi 临时文件路径
--http-scgi-temp-path=/var/tmp/nginx/scgi #设置scgi 临时文件路径

SSL modules require the OpenSSL library
yum -y install openssl openssl-devel

sudo apt-get update sudo apt-get install libssl-dev

nginx服务管理脚本

touch /etc/init.d/nginx chmod +x /etc/init.d/nginx vim /etc/init.d/nginx ! /bin/sh

BEGIN INIT INFO

Provides: nginx Required-Start: $local_fs $remote_fs $network $syslog Required-Stop: $local_fs $remote_fs $network $syslog Default-Start: 2 3 4 5 Default-Stop: 0 1 6 Short-Description: starts the nginx web server Description: starts nginx using start-stop-daemon

END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/nginx/sbin/nginx
NAME=nginx
DESC=nginx
DAEMON_OPTS=''
test -x $DAEMON || exit 0

Include nginx defaults if available if [ -f /etc/default/nginx ] ; then . /etc/default/nginx fi

set -e
. /lib/lsb/init-functions

test_nginx_config() { if $DAEMON -t $DAEMON_OPTS then return 0 else return $? fi }

case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON || true
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON || true
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON || true
sleep 1
start-stop-daemon --start --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON || true
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON || true
echo "$NAME."
;;
status)
status_of_proc -p /var/run/$NAME.pid "$DAEMON" nginx && exit 0 || exit $?
;;
*)
echo "Usage: $NAME {start|stop|restart|reload|force-reload|status}" >&2
exit 1
;;
esac
exit 0

添加开机自启动
update-rc.d nginx defaults

安装MySQL

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.27.tar.gz

mysql5.5之后使用cmake进行配置

sudo apt-get install git,cmake,libncurses5-dev

http://www.cnblogs.com/mophee/archive/2013/03/19/2969456.html

groupadd mysql useradd mysql -g mysql -M -s /sbin/nologin mkdir -p /usr/local/mysql mkdir -p /usr/local/mysql/data mkdir -p /usr/local/mysql/log mkdir -p /usr/local/mysql/tmp chown -R mysql:mysql /usr/local/mysql tar axvf mysql-5.6.27 cd mysql-5.6.27

yum install cmake -y
cmake .
make
make install
今天安装mysql-5.5.3-m3的时候,报下面的错误:
-- Could NOT find OpenSSL (missing: OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR)
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:83 (MESSAGE):
Curses library not found. Please install appropriate package,

remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:118 (FIND_CURSES)
cmake/readline.cmake:214 (MYSQL_USE_BUNDLED_READLINE)
CMakeLists.txt:257 (MYSQL_CHECK_READLINE)

-- Configuring incomplete, errors occurred!

解决办法:
rm -f CMakeCache.txt
yum -y install ncurses-devel

然后再使用cmake .编译就可以了.
make && make install
检查有没有错误

cmake –graphviz . cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DINSTALL_DATADIR=/usr/local/data -DSYSCONFDIR=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1

重新cmake删除CMakeCache.txt

make make install chown -R mysql:mysql /usr/local/mysql/data chmod -R 755 /usr/local/mysql/data /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data cp support-files/mysql.server /etc/init.d/mysqld update-rc.d mysqld defaults service mysqld start cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

ln -s /usr/local/mysql/data/mysql.socket /tmp/mysql.sock

安装PHP

wget http://cn2.php.net/get/php-5.6.15.tar.gz/from/this/mirror -O php-5.6.15.tar.gz tar zxvf php-5.6.15.tar.gz cd php-5.6.15

安装php依赖包

apt-get install libxml2,libxml2-dev ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --enable-fpm --enable-mbstring --disable-fileinfo make make test make install cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /tmp/php-5.6.15/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm update-rc.d php-fpm defaults

make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
内存小于1G所导致.
./configure后接--disable-fileinfo

[pool www] cannot get gid for group 'nobody'

vim /usr/local/php/etc/php-fpm.conf

user=www-data
group=www-data

版权声明:原创作品,允许转载,转载时务必以超链接的形式表明出处和作者信息。否则将追究法律责任。来自海汼部落-紫云互联,http://hainiubl.com/topics/205
回复数量: 0
    暂无评论~~
    • 请注意单词拼写,以及中英文排版,参考此页
    • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`, 更多语法请见这里 Markdown 语法
    • 支持表情,可用Emoji的自动补全, 在输入的时候只需要 ":" 就可以自动提示了 :metal: :point_right: 表情列表 :star: :sparkles:
    • 上传图片, 支持拖拽和剪切板黏贴上传, 格式限制 - jpg, png, gif,教程
    • 发布框支持本地存储功能,会在内容变更时保存,「提交」按钮点击时清空
    Ctrl+Enter