CentOS 7.2 下編譯安裝PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法詳解(mini版本)
一、安裝前的準(zhǔn)備工作
1、yum update #更新系統(tǒng)
2、yum install gcc gcc-c++ autoconf automake cmake bison m4 libxml2 libxml2-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel #安裝php、MySQL、Nngix所依賴的包
3、下載以下包 #我把所有源文件都下載在root目錄,讀者可自行修改源文件存放目錄
3.1 libmcrypt-2.5.8.tar.gz
3.2 mcrypt-2.6.8.tar.gz
3.3 mhash-0.9.9.9.tar.gz
3.4 zlib-1.2.8.tar.gz
解壓并安裝如:
#tar -zvxf libmcrypt-2.5.8.tar.gz #cd libmcrypt-2.5.8 #./configure #make && make insatll
4、在安裝軟件時如果提示有什么依賴包沒有安裝的可以再執(zhí)行yum install * -y (*表示相關(guān)包)
二、編譯安裝Nginx
1、去官網(wǎng)http://nginx.org/en/download.html下載最nginx-1.10.1.tar.gz的穩(wěn)定版本
2、編譯步驟如下
1、通過winSCP上傳nginx-1.10.1.tar.gz到/root目錄下
1.1 groupadd -r nginx #新建nginx組
1.2 useradd -r -g nginx -s /bin/false nginx #新建無登錄權(quán)限的nginx用戶
1.3 id nginx #查看nginx組及用戶
2、tar -zvxf nginx-1.10.1.tar.gz
3、cd nginx-1.10.1
4、可通過./configure --help查看編譯配置參數(shù),也可參考http://nginx.org/en/docs/configure.html,下列參數(shù)要寫在一行中
./configure --prefix=/usr/local/nginx --modules-path=/usr/local/nginx/modules --with-http_ssl_module --pid-path=/usr/local/nginx/nginx.pid --user=nginx --group=nginx
5、make && make install #編譯并安裝
6、啟動nginx
6.1 cd /usr/local/nginx
6.2 sbin/nginx #啟動,可使用sbin/nginx -?查看nginx相關(guān)操作命令
7、在/usr/lib/systemd/system目錄下新建nginx.service文件,這樣就可以通過systemctl stop|start|reload nginx.service來操作nginx,也可參考https://www.nginx.com/resources/wiki/start/topics/examples/systemd/,內(nèi)容如下:
[Unit] Description=The NGINX HTTP and reverse proxy server After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/nginx/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s stop PrivateTmp=true [Install] WantedBy=multi-user.target
三、編譯安裝MySQL
1、去官網(wǎng)http://dev.mysql.com/Downloads/MySQL-5.7/mysql-boost-5.7.14.tar.gz下載帶boost的5.7.14版本
2、編譯步驟如下
1、用winSCP上傳mysql-boost-5.7.14.tar.gz到/root目錄下
2、groupadd mysql
3、useradd -r -g mysql -s /bin/false mysql
4、用cmake編譯mysql, 相關(guān)參數(shù)可以參考https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html,下列參數(shù)要寫在一行
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DSYSCONFDIR=/usr/local/mysql/etc -DSYSTEMD_PID_DIR=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_BOOST=boost -DWITH_SYSTEMD=1
5、make && make install
6、配置mysql并初始化數(shù)據(jù)庫
6.1 cd /usr/local/mysql #進入編譯目錄
6.2 chown -R mysql . #修改目錄所有者
6.3 chgrp -R mysql . #修改目錄組
6.4 cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld #配置mysqld服務(wù)
6.5 cp /usr/local/mysql/support-files/my-default.cnf /usr/local/mysql/my.cnf #配置my.cnf
6.5.1 復(fù)制以下內(nèi)容到my.cnf文件中的[mysqld]下
user = mysql basedir = /usr/local/mysql datadir = /usr/local/mysql/data port = 3306 server_id = /usr/local/mysql/mysqld.pid socket = /usr/local/mysql/mysql.sock
6.5 chkconfig mysqld on #設(shè)置mysqld開機自啟
6.6 bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data #初始化數(shù)據(jù)庫
6.7 bin/mysqld --user=mysql & #啟動mysql, 如果報Please read "Security" section of the manual to find out how to run mysqld as root!,就在my.cnf中加入user=root, 表示以root用戶啟動
7、修改root用戶登錄密碼并允許root用戶遠(yuǎn)程登錄
7.1 mysql -u root --skip-password
7.2 ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
7.3 允許root用戶遠(yuǎn)程登錄
7.3.1 use mysql;
7.3.2 update user set host='%' where user='root' and host='localhost'; #允許 (update user set host='localhost' where user='root'; #禁用)
7.3.3 flush privileges;
7.3.4 service mysqld restart
8、解決service mysqld start|stop報MySQL server PID file could not be found!或者Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe), 其實可通過閱讀此文件解決相關(guān)錯誤
8.1 chmod 777 /usr/local/mysql #因我設(shè)置mysqld.pid文件保存在/usr/local/mysql目錄,所以保證其有可寫權(quán)限
8.2 通過winSCP修改/etc/init.d/mysqld文件
8.2.1 basedir=/usr/local/mysql #手動指定
8.2.2 datadir=/usr/local/mysql/data #手動指定
8.2.3 mysqld_pid_file_path=/usr/local/mysql/mysqld.pid #手動指定
8.2.4 把此文件中所有未注釋的含有mysqld_safe的字符替換成mysqld
四、編譯安裝php
1、去官網(wǎng)http://php.net/downloads.php下載php7.0.10版本
2、編譯步驟如下
1、用winSCP上傳php-7.0.10.tar.gz到/root目錄下
2、tar -zvxf php-7.0.10.tar.gz #解壓
3、配置編譯php參數(shù), 可使用./configure --help命令查看所有編譯配置項目, 下列參數(shù)要寫在一行中
./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php --datadir=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-fpm-user=nginx --with-fpm-group=nginx --with-gd --with-iconv --enable-mbstring --enable-fpm --enable-mysqlnd
4、make && make install #編譯并安裝
5、cd /usr/local/php #進入編譯目錄
6、修改相關(guān)配置文件
6.1 cp /usr/local/php/etc/php.ini.default /usr/local/php/etc/php.ini #php.ini中相關(guān)配置依項目需要自行修改,配置nginx支持php參考http://php.net/manual/zh/install.unix.nginx.php
6.2 cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf #去掉[global]項下pid前的;
6.3 cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf #大致在23、24行修改user和group如:user = nginx,group = nginx
7、chmod 777 /usr/local/php/var/run #默認(rèn)PID文件是寫在/usr/local/php/var/run這個目錄中,所以修改目錄權(quán)限
8、sbin/php-fpm #啟動php, 可通過sbin/php-fpm -h 查看相關(guān)操作命令列表
9、在/usr/lib/systemd/system目錄下新建php-fpm.service文件,這樣就可以通過systemctl stop|start|reload php-fpm.service來操作php-fpm,內(nèi)容如下:
[Unit] Description=The PHP FastCGI Process Manager After=syslog.target network.target Before=nginx.service [Service] Type=forking PIDFile=/usr/local/php/var/run/php-fpm.pid ExecStart=/usr/local/php/sbin/php-fpm ExecStop=/bin/kill -QUIT `cat /usr/local/php/var/run/php-fpm.pid` ExecReload=/bin/kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid` PrivateTmp=true [Install] WantedBy=multi-user.target
五、至此在我的VirturBox中CentOS7.2下成功搭建了LNMP環(huán)境
以上所述是小編給大家介紹的CentOS 7.2 下編譯安裝PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法詳解(mini版本),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
- Centos 安裝 PHP7.4 和 Nginx的操作方法
- centos7利用yum安裝lnmp的教程(linux+nginx+php7.1+mysql5.7)
- 詳解如何在CentOS7中使用Nginx和PHP7-FPM安裝Nextcloud
- CentOS 7.3.1611編譯安裝Nginx1.10.3+MySQL5.7.16+PHP7.1.2
- CentOS 7.2.1511 編譯安裝Nginx1.10.1+MySQL5.7.14+PHP7.0.11
- Centos7 安裝 PHP7最新版的詳細(xì)教程
- CentOS 7下部署php7.1和開啟MySQL擴展的方法教程
- CentOS下PHP7的編譯安裝及MySQL的支持和一些常見問題的解決辦法
- centos6.6 下 安裝 php7 + nginx環(huán)境的方法
相關(guān)文章
PHP獲取遠(yuǎn)程http或ftp文件的md5值的方法
這篇文章主要介紹了PHP獲取遠(yuǎn)程http或ftp文件的md5值 ,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2019-04-04WordPress中用于更新偽靜態(tài)規(guī)則的PHP代碼實例講解
這篇文章主要介紹了WordPress中用于更新偽靜態(tài)規(guī)則的PHP代碼實例講解,圍繞flush_rewrite_rules()函數(shù)的使用展開來講,需要的朋友可以參考下2015-12-12PHP錯誤處理函數(shù)register_shutdown_function使用示例
這篇文章主要介紹了PHP錯誤處理函數(shù)register_shutdown_function使用示例,需要的朋友可以參考下2017-07-07symfony3.4中根據(jù)角色不同跳轉(zhuǎn)不同頁面功能
這篇文章主要介紹了symfony3.4中根據(jù)角色不同跳轉(zhuǎn)不同頁面,在Symfony?3.4中,可以使用安全組件來實現(xiàn)控制不同角色跳轉(zhuǎn)到不同頁面的功能,本文通過示例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2023-08-08