ubuntu最基础的LNMP环境搭建
2021/7/22 7:10:19
本文主要是介绍ubuntu最基础的LNMP环境搭建,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
下载源码
wget http://nginx.org/download/nginx-1.8.0.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz
wget http://cn2.php.net/get/php-5.6.16.tar.gz/from/this/mirror
wget http://www.memcached.org/files/memcached-1.4.25.tar.gz
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.28.tar.gz
以上版本太老,几年前用的可自行下载。
一.nginx安装
1.解压安装,先安装pcre
# useradd -M -s /sbin/nologin nginx # tar -zxvf pcre-8.38.tar.gz # apt-get install make gcc g++ # ./configure && make -j2 && make install
解压nginx包
# tar -zxvf nginx-1.8.0.tar.gz
安装依赖
# apt-get install openssl libssl-dev
# ./configure --prefix=/user/local/nginx --conf-path=/etc/nginx.conf --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre
&& make && make install
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
出现错误
# /user/local/nginx/sbin/nginx 直接运行启动
* Starting Nginx Server...
/user/local/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
[fail]
跟进情况执行一下操作
# ln -s /usr/local/lib/libpcre.so.1 /lib64 64位
# ln -s /usr/local/lib/libpcre.so.1 /lib 32位
3.配置
#user nobody user nginx; //修改名字 location / { root html; index index.php index.html index.htm; } 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; } location ~ /\.ht { deny all; }
二.安装mysql
1. 解压安装
# useradd -M -s /sbin/nologin mysql # apt-get install libncurses5-dev cmake openssl libssl-dev gcc g++ # mkdir -p /app/mysql # tar -zxvf mysql-5.6.28.tar.gz # cmake -DCMAKE_INSTALL_PREFIX=/app/mysql -DSYSCONFDIR=/app/mysq/etc/ -DMYSQL_DATADIR=//app/mysq/mysql_data -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DENABLE_DOWNLOADS=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/src/boost_1_59_0 # make && make install
2.启动脚本
# cp support-files/mysql.server /etc/init.d/mysqld # mkdir /app/mysq/etc/ # cp support-files/my-default.cnf /app/mysql/etc/my.cnf # chmod +x /etc/init.d/mysqld # update-rc.d mysqld defaults # chown mysql.mysql /data/mysdl/mysql_data/ # ./scripts/mysql_install_db -basedir=/app/mysq -datadir=/app/mysq/mysql_data --defaults-file=/app/mysql/etc/my.cnf --user=mysql # ./bin/mysql_secure_installation //执行之前启动mysql服务 //输入用户名/密码 # /etc/init.d/mysqld restart # vim /etc/profile //使其可以直接使用mysql命令 export PATH=$PATH:/app/mysql/bin source /etc/profile
连接进入mysql
是否出现套接字的错误
创建一个软连接
三 安装php
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install php70w*
1.解压,编译
useradd -M -s /sbin/nologin php-fpm # apt-get install libxml2 libxml2-dev # apt-get install curl libsasl2-dev # apt-get install libcurl4-gnutls-dev libjpeg-dev libpng12-dev libfreetype6-dev libmcrypt-dev //之后会安装的很多包 # tar -zxvf php-5.6.16.tar.gz # cd php-5.6.16 # ./configure --prefix=/app/php --with-config-file-path=/app/php/etc --with-mysql --with-mysqli --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap=/usr/lib/x86_64-linux-gnu --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-pear --enable-pdo --with-pdo-mysql --with-gettext --enable-exif --enable-wddx --enable-calendar --enable-ftp --enable-dba --enable-sysvmsg --enable-sysvshm --enable-debug --enable-maintainer-zts --enable-embed --with-pcre-regex --enable-gd-jis-conv # make && make test && make install
出现缺少ldap 问题
find / -iname libldap* //查找出ldap的具体位置,以so 结尾的文件 在编译的选项后面加上路径
找不到ldap.h 软连接。
ln -s /usr/include/ldap.h /usr/lib/x86_64-linux-gnu/
configure: WARNING: unrecognized options: --with-curlwrappers //问题
2.启动脚本
# cp php.ini-production /app/php/etc/php.ini //不知道在哪里拷贝,使用find命令查 # cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm # chmod u+x /etc/init.d/php-fpm # update-rc.d php-fpm defaults # cd /app/php/etc/ # cp php-fpm.conf.default php-fpm.conf
3.配置方法
vim php-fpm.conf 修改用户及组
/etc/init.d/php-fpm start
这篇关于ubuntu最基础的LNMP环境搭建的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-16Maven资料入门指南
- 2024-11-16Maven资料入门教程
- 2024-11-16MyBatis Plus资料:新手入门教程与实践指南
- 2024-11-16MyBatis-Plus资料入门教程:快速上手指南
- 2024-11-16Mybatis资料入门教程:新手必看指南
- 2024-11-16MyBatis资料详解:新手入门与初级实战指南
- 2024-11-16MyBatisPlus资料:初学者入门指南与实用教程
- 2024-11-16MybatisPlus资料详解:初学者入门指南
- 2024-11-16MyBatisX资料:新手入门与初级教程
- 2024-11-16RESTful接口资料详解:新手入门指南