九色国产,午夜在线视频,新黄色网址,九九色综合,天天做夜夜做久久做狠狠,天天躁夜夜躁狠狠躁2021a,久久不卡一区二区三区

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書(shū)等14項(xiàng)超值服

開(kāi)通VIP
CentOS 7 用戶(hù)怎樣安裝 LNMP(Nginx+PHP+MySQL)

關(guān)于 Nginx (發(fā)音 “engine x”)這是一款免費(fèi)、開(kāi)源、高效的 HTTP 服務(wù)器,Nginx是以穩(wěn)定著稱(chēng),豐富的功能,結(jié)構(gòu)簡(jiǎn)單,低資源消耗。本教程演示如何在CentOS 6.5服務(wù)器(適用于 CentOS 7)安裝Nginx與PHP(通過(guò)php-fpm)和MySQL(MariaDB)。

 

--------------------------------------分割線 --------------------------------------

Ubuntu 14.04 LTS 安裝 LNMP Nginx\PHP5 (PHP-FPM)\MySQL http://www.linuxidc.com/Linux/2014-05/102351.htm

Ubuntu 13.04 安裝 LAMP\Vsftpd\Webmin\phpMyAdmin 服務(wù)及設(shè)置 http://www.linuxidc.com/Linux/2013-06/86250.htm

CentOS 6.4 下的LNMP 生產(chǎn)環(huán)境搭建及安裝腳本 http://www.linuxidc.com/Linux/2013-11/92428.htm

生產(chǎn)環(huán)境實(shí)用之LNMP架構(gòu)的編譯安裝+SSL加密實(shí)現(xiàn) http://www.linuxidc.com/Linux/2013-05/85099.htm

LNMP 全功能編譯安裝 for CentOS 6.3筆記 http://www.linuxidc.com/Linux/2013-05/83788.htm

CentOS 6.3 安裝LNMP (PHP 5.4,MyySQL5.6) http://www.linuxidc.com/Linux/2013-04/82069.htm

在部署LNMP的時(shí)候遇到Nginx啟動(dòng)失敗的2個(gè)問(wèn)題 http://www.linuxidc.com/Linux/2013-03/81120.htm

Ubuntu安裝Nginx php5-fpm MySQL(LNMP環(huán)境搭建) http://www.linuxidc.com/Linux/2012-10/72458.htm

--------------------------------------分割線 --------------------------------------

1 先說(shuō)一下

本文使用的主機(jī)名稱(chēng): server1.example.com 和IP地址: 192.168.1.105。這些可能與你的計(jì)算機(jī)有所不同,注意進(jìn)行修改。

2 使用外部倉(cāng)庫(kù)

Nginx不是從官方CentOS庫(kù)安裝,我們從 nginx 項(xiàng)目安裝庫(kù)安裝,修改源:

vi /etc/yum.repos.d/nginx.repo

修改為: [nginx]     name=nginx repo     baseurl=http://nginx.org/packages/centos/$releasever/$basearch/     gpgcheck=0     enabled=1

3 安裝 MySQL

我們先安裝MariaDB。一個(gè)免費(fèi)的MySQL 分支。運(yùn)行此命令:

yum install mariadb mariadb-server net-tools

然后我們創(chuàng)建MySQL系統(tǒng)啟動(dòng)鏈接(所以MySQL的自動(dòng)啟動(dòng)時(shí),系統(tǒng)啟動(dòng))啟動(dòng)MySQL服務(wù)器:

systemctl enable mariadb.service
systemctl start mariadb.service

現(xiàn)在檢查網(wǎng)絡(luò)啟用。運(yùn)行

netstat -tap | grep mysql

它應(yīng)該顯示出這樣的內(nèi)容:

[root@example ~]# netstat -tap | grep mysql
tcp 0 0 0.0.0.0:mysql 0.0.0.0:* LISTEN 10623/mysqld

 

運(yùn)行

mysql_secure_installation

為用戶(hù)設(shè)置根口令(否則,任何人都可以訪問(wèn)你的MySQL數(shù)據(jù)庫(kù)?。?/p>

[root@example ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we’ll need the current
password for the root user. If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] <– 回車(chē)
New password: <– 輸入ROOT密碼
Re-enter new password: <– 再輸入一次ROOT密碼
Password updated successfully!
Reloading privilege tables..
… Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] <– 回車(chē)
… Success!

Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] <– 回車(chē)
… Success!

By default, MariaDB comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] <– 回車(chē)
- Dropping test database…
… Success!
- Removing privileges on test database…
… Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] <– 回車(chē)
… Success!

Cleaning up…

All done! If you’ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@example ~]#

[root@server1 ~]# mysql_secure_installation

4 安裝 Nginx

Nginx可以作為一個(gè)包從nginx.org安裝,運(yùn)行:

yum install nginx

然后我們創(chuàng)建的系統(tǒng)啟動(dòng)nginx的鏈接和啟動(dòng)它:

systemctl enable nginx.service
systemctl start nginx.service

有時(shí),你會(huì)得到一個(gè)錯(cuò)誤,如80端口已在使用中,錯(cuò)誤消息會(huì)是這樣的

[root@server1 ~]# service nginx start
Starting nginx: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[FAILED]
[root@server1 ~]#

這就意味著有時(shí)在運(yùn)行Apache服務(wù)。停止服務(wù),進(jìn)一步啟動(dòng)服務(wù)nginx如下

systemctl stop httpd.service
yum remove httpd
systemctl disable httpd.service

systemctl enable nginx.service
systemctl start nginx.service

開(kāi)放的HTTP和HTTPS防火墻中的端口

firewall-cmd –permanent –zone=public –add-service=http
firewall-cmd –permanent –zone=public –add-service=https
firewall-cmd –reload

輸出的shell結(jié)果將看起來(lái)像這樣:

[root@example ~]# firewall-cmd –permanent –zone=public –add-service=http
success
[root@example ~]# firewall-cmd –permanent –zone=public –add-service=https
success
[root@example ~]# firewall-cmd –reload
success
[root@example ~]#

在你的Web服務(wù)器的IP地址或主機(jī)名稱(chēng)輸入到瀏覽器(如HTTP:/ /192.168.1.105),你應(yīng)該看到nginx的歡迎頁(yè)面。

5 安裝 PHP5

我們可以通過(guò)PHP-FPM使nginx的PHP5工作(PHP-FPM(FastCGI進(jìn)程管理器)是一種替代PHP FastCGI執(zhí)行一些額外的功能,支持任何規(guī)模大小,尤其是繁忙的站點(diǎn)很有用)。我們可以安裝php-fpmtogether用PHP-CLI和一些PHP5的模塊,如PHP,MySQL,你需要的,如果你想使用MySQL的PHP命令如下:

yum install php-fpm php-cli php-mysql php-gd php-ldap php-odbc php-pdo php-pecl-memcache php-pear php-mbstring php-xml php-xmlrpc php-mbstring php-snmp php-soap

APC是一個(gè)自由和開(kāi)放的PHP操作碼來(lái)緩存和優(yōu)化PHP的中間代碼。它類(lèi)似于其他PHP操作碼cachers,如eAccelerator和XCache。強(qiáng)烈建議有這些安裝,以加快您的PHP頁(yè)面。

我會(huì)從PHP PECL庫(kù)中安裝的APC。 PECL要求CentOS開(kāi)發(fā)工具beinstalled編譯APC包。

yum install php-devel
yum groupinstall ‘Development Tools’

安裝 APC

pecl install apc

[root@example ~]# pecl install apc
downloading APC-3.1.13.tgz …
Starting to download APC-3.1.13.tgz (171,591 bytes)
……………..done: 171,591 bytes
55 source files, building
running: phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
Enable internal debugging in APC [no] : <– 回車(chē)
Enable per request file info about files used from the APC cache [no] : <– 回車(chē)
Enable spin locks (EXPERIMENTAL) [no] : <– 回車(chē)
Enable memory protection (EXPERIMENTAL) [no] : <– 回車(chē)
Enable pthread mutexes (default) [no] : <–回車(chē)
Enable pthread read/write locks (EXPERIMENTAL) [yes] : <– 回車(chē)
building in /var/tmp/pear-build-rootVrjsuq/APC-3.1.13
……

然后打開(kāi) /etc/php.ini 并設(shè)置 cgi.fix_pathinfo=0:

vi /etc/php.ini

[...]; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.  Setting; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A setting; of zero causes PHP to behave as before.  Default is 1.  You should fix your scripts; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.; http://www.php.net/manual/en/ini.core.php#ini.cgi.fix-pathinfocgi.fix_pathinfo=0[...]

并添加行:

[...]extension=apc.so

 /etc/php.ini 文件后面。

除此之外,為了避免這樣的時(shí)區(qū)的錯(cuò)誤:

[21-July-2014 10:07:08] PHP Warning: phpinfo(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘Europe/Berlin’ for ‘CEST/2.0/DST’ instead in /usr/share/nginx/html/info.php on line 2

… in /var/log/php-fpm/www-error.log 當(dāng)你在瀏覽器中調(diào)用一個(gè)PHP腳本,你應(yīng)該設(shè)置 date.timezone in /etc/php.ini:

[...][Date]; Defines the default timezone used by the date functions; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezonedate.timezone = "Europe/Berlin"[...]

您可以通過(guò)運(yùn)行正確的時(shí)區(qū)支持您的系統(tǒng):

cat /etc/sysconfig/clock

[root@server1 nginx]# cat /etc/sysconfig/clock
ZONE=”Europe/Berlin”
[root@server1 nginx]#

接下來(lái),創(chuàng)建系統(tǒng)啟動(dòng)鏈接的PHP-FPM并啟動(dòng)它:

systemctl enable php-fpm.service
systemctl start php-fpm.service

PHP-FPM是一個(gè)守護(hù)進(jìn)程(使用init腳本/etc/init.d/php-fpm) 運(yùn)行在端口9000的FastCGI服務(wù)器。

更多詳情見(jiàn)請(qǐng)繼續(xù)閱讀下一頁(yè)的精彩內(nèi)容http://www.linuxidc.com/Linux/2014-09/106192p2.htm

 

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶(hù)發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
RHEL / CentOS 7 安裝 Nginx, MySQL, PHP (LEMP) | Linux 技術(shù)手札
應(yīng)用系統(tǒng)分布式構(gòu)建運(yùn)維
Centos 7.3搭建LNMP環(huán)境
yum安裝CentOS7+nginx+php7.3+mysql5.7
CentOS7下部署開(kāi)源網(wǎng)絡(luò)監(jiān)控系統(tǒng)LibreNMS
CentOS 7下安裝LNMP服務(wù)器 – 戊辰人博客
更多類(lèi)似文章 >>
生活服務(wù)
熱點(diǎn)新聞
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服