如何进行centos7_Lnmp的编译安装,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
在翠屏等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站建设、网站制作 网站设计制作按需设计,公司网站建设,企业网站建设,品牌网站制作,营销型网站,外贸网站建设,翠屏网站建设费用合理。编译安装nginx+php+mysql,操作如下
环境:centos7.3
软件:nginx-1.12.1 + mysql-5.7.19 + php-7.1.8
yum -y remove php mysql httpd ## 添加epel源:(如果是版本6的操作系统请用第二条) rpm -ivh https://mirrors.ustc.edu.cn/epel/7/x86_64/e/epel-release-7-10.noarch.rpm --force rpm -ivh https://mirrors.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm --force ## centos源: rpm -ivh http://mirrors.163.com/centos/6.9/os/x86_64/Packages/centos-release-6-9.el6.12.3.x86_64.rpm --force ==================================================================================
1. 创建用户 useradd mysql 2.下载安装包、依赖的库: wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19.tar.gz yum install cmake gcc-c++ ncurses-devel perl boost-devel bison-devel bison -y 3.安装boost插件: 注:如果只为安装mysql其实可以不用安装的,解压就好,到时安装mysql时引用目录,不过percona-xtrabackup需要用到,所以我安装了。 wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz ./bootstrap.sh ./b2 install 4.编译安装: cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/var/data/mysql -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/var/downloads/boost_1_59_0 -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=1 make && make install 5.配置/etc/my.cnf 仅作测试,没加任何优化参数。 cat > /etc/my.cnf << EOF [client] socket=/var/data/mysql/mysql.sock [mysqld] basedir=/usr/local/mysql datadir=/var/data/mysql socket=/var/data/mysql/mysql.sock symbolic-links=0 log-error=/var/log/mysql.log pid-file = /tmp/mysql.pid EOF 6.添加环境变量:vi /etc/profile echo -e '\n\nPATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile && source /etc/profile 7.初始化数据&更改相应权限: /usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/var/data/mysql chown -R mysql:mysql /var/data/mysql 8、配置开机启动项(centos7操作姿势) cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld systemctl enable mysqld 9.启动数据库: systemctl start mysqld 10.创建密码(推荐使用中等 MEDIUM 级别)、添加其它用户(可选): mysql_secure_installation CREATE DATABASE `lampdb` ; grant all privileges on lampdb.* to 'lamp@%' identified by 'Hi.lamp@888'; flush privileges;
1.下载并安装依赖包: wget http://mirrors.sohu.com/php/php-7.1.8.tar.gz yum clean all yum install libjpeg libjpeg-devel curl-devel gcc gcc-c++ libxml2-devel openssl openssl-devel libpng-devel freetype-devel libmcrypt libmcrypt-devel -y 2.添加用户: useradd -s /sbin/nologin php 3.编译php: ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --with-mcrypt=/usr/include --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-gd --with-iconv --with-zlib --enable-xml --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --with-mhash make && make install 4.复制相关配置文件(仅测试用,生产请用专业的配置文件): cp /var/downloads/php-7.1.8/php.ini-production /usr/local/php/etc/php.ini cp /var/downloads/php-7.1.8/sapi/fpm/init.d.php-fpm /etc/init.d/php cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf chmod u+x /etc/init.d/php mkdir -p /var/data/php/log/ 5.启动服务: /etc/init.d/php start /etc/init.d/php status
1.下载nginx: wget https://nginx.org/download/nginx-1.12.1.tar.gz yum install openssl openssl-devel pcre-devel zlib-devel -y yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel 2.添加用户: useradd -s /sbin/nologin nginx 3.编译安装: ./configure --prefix=/usr/local/nginx --without-http_memcached_module --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module make && make install 4.配置Nginx支持php-fpm模块 vim /usr/local/nginx/conf/nginx.conf location / { root html; index index.html index.htm index.php; } 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; } 5.添加环境变量: echo -e '\n\nPATH=/usr/local/nginx/sbin:$PATH' >> /etc/profile && source /etc/profile 6.启动Nginx /usr/local/nginx/sbin/nginx 5.详细可以参考这里: http://www.cnblogs.com/zhang-shijie/p/5294162.html http://www.cnblogs.com/lyongde/p/4201484.html ========================================================== 访问验证: 验证php:建立测试页面test1.php vi /usr/local/apache/htdocs/test1.php 浏览器输入:http://116.196.xx.xxx/test1.php
安装PHP需要的依赖: 1.安装libiconv: wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz ./configure --prefix=/usr/local/libiconv make && make install 2.安装libmcrypt wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz ./configure make && make install 3.安装 Mhash 下载地址(下载后上传到服务器): https://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download?use_mirror=nchc&r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fmhash%2Ffiles%2Fmhash%2F0.9.9.9%2Fmhash-0.9.9.9.tar.gz%2Fdownload&use_mirror=nchc ./configure make && make install 4.安装Mcrypt wget http://iweb.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz #注意一下这步运行下,不然下面可能报错 export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH ./configure make && make install 编译mcrypt可能会报错:configure: error: *** libmcrypt was not found vi /etc/ld.so.conf 最后一行添加 /usr/local/lib/ 保存并退出::wq! 执行载入命令: ldconfig --------------------------------------------------------- checking for libmcrypt - version >= 2.5.0... no *** Could not run libmcrypt test program, checking why... *** The test program compiled, but did not run. This usually means *** that the run-time linker is not finding LIBMCRYPT or finding the wrong *** version of LIBMCRYPT. If it is not finding LIBMCRYPT, you'll need to set your *** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point *** to the installed location Also, make sure you have run ldconfig if that *** is required on your system *** *** If you have an old version installed, it is best to remove it, although *** you may also be able to get things to work by modifying LD_LIBRARY_PATH *** configure: error: *** libmcrypt was not found ---------------------------------------------------------------
完成收工!
关于如何进行centos7_Lnmp的编译安装问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注创新互联行业资讯频道了解更多相关知识。
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。