您好,登錄后才能下訂單哦!
如何進(jìn)行centos7_Lnmp的編譯安裝,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。
編譯安裝nginx+php+mysql,操作如下
環(huán)境:centos7.3
軟件:nginx-1.12.1 + mysql-5.7.19 + php-7.1.8
yum -y remove php mysql httpd ## 添加epel源:(如果是版本6的操作系統(tǒng)請(qǐng)用第二條) 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. 創(chuàng)建用戶 useradd mysql 2.下載安裝包、依賴的庫(kù): 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其實(shí)可以不用安裝的,解壓就好,到時(shí)安裝mysql時(shí)引用目錄,不過(guò)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 僅作測(cè)試,沒(méi)加任何優(yōu)化參數(shù)。 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.添加環(huán)境變量:vi /etc/profile echo -e '\n\nPATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile && source /etc/profile 7.初始化數(shù)據(jù)&更改相應(yīng)權(quán)限: /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、配置開(kāi)機(jī)啟動(dòng)項(xiàng)(centos7操作姿勢(shì)) cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld systemctl enable mysqld 9.啟動(dòng)數(shù)據(jù)庫(kù): systemctl start mysqld 10.創(chuàng)建密碼(推薦使用中等 MEDIUM 級(jí)別)、添加其它用戶(可選): 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.復(fù)制相關(guān)配置文件(僅測(cè)試用,生產(chǎn)請(qǐng)用專業(yè)的配置文件): 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.啟動(dòng)服務(wù): /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.添加環(huán)境變量: echo -e '\n\nPATH=/usr/local/nginx/sbin:$PATH' >> /etc/profile && source /etc/profile 6.啟動(dòng)Nginx /usr/local/nginx/sbin/nginx 5.詳細(xì)可以參考這里: http://www.cnblogs.com/zhang-shijie/p/5294162.html http://www.cnblogs.com/lyongde/p/4201484.html ========================================================== 訪問(wèn)驗(yàn)證: 驗(yàn)證php:建立測(cè)試頁(yè)面test1.php vi /usr/local/apache/htdocs/test1.php <?php echo phpinfo(); ?> 瀏覽器輸入: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 下載地址(下載后上傳到服務(wù)器): 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 #注意一下這步運(yùn)行下,不然下面可能報(bào)錯(cuò) export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH ./configure make && make install 編譯mcrypt可能會(huì)報(bào)錯(cuò):configure: error: *** libmcrypt was not found vi /etc/ld.so.conf 最后一行添加 /usr/local/lib/ 保存并退出::wq! 執(zhí)行載入命令: 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 ---------------------------------------------------------------
完成收工!
關(guān)于如何進(jìn)行centos7_Lnmp的編譯安裝問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開(kāi),可以關(guān)注億速云行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。