日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

RedHat6.2 x86手动配置LNMP环境

發(fā)布時(shí)間:2023/12/19 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 RedHat6.2 x86手动配置LNMP环境 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

為什么80%的碼農(nóng)都做不了架構(gòu)師?>>> ??

因?yàn)楣疽笥肦edHat配,順便讓我練習(xí)一下Linux里面的操作什么的。

折騰來折騰去終于搞好了,其實(shí)也沒那么難嘛。但是也要記錄一下。

首先,是在服務(wù)器里面用VMware搭建的RedHat6.2 x86系統(tǒng)。在RedHat里面yum里面的源基本是收費(fèi)的。CentOS呢,是RedHat的衍生版,目的就是打破redhat的收費(fèi),所以兩者也沒啥區(qū)別。直接就用CentOS6的yum包來配置了。

首先,在終端里輸入:

cd?/etc/yum.repos.d/

這里面是放yum源的地方。默認(rèn)里面會(huì)有一個(gè)rhel-source.repo后綴的文件,咱們把他刪了或者重命名成.bak

然后下一步就是添加centos的源了。新建一個(gè)centos.base.repo文件。在里面輸入:

#?CentOS-Base.repo# #?The?mirror?system?uses?the?connecting?IP?address?of?the?client?and?the#?update?status?of?each?mirror?to?pick?mirrors?that?are?updated?to?and#?geographically?close?to?the?client.??You?should?use?this?for?CentOS?updates#?unless?you?are?manually?picking?other?mirrors.# #?If?the?mirrorlist=?does?not?work?for?you,?as?a?fall?back?you?can?try?the?#?remarked?out?baseurl=?line?instead.#?[base] name=CentOS-6?-?Base?-?mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos/6/os/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=osgpgcheck=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6? #released?updates?[updates] name=CentOS-6?-?Updates?-?mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos/6/updates/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=updatesgpgcheck=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6? #additional?packages?that?may?be?useful[extras] name=CentOS-6?-?Extras?-?mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos/6/extras/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=extrasgpgcheck=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6? #additional?packages?that?extend?functionality?of?existing?packages[centosplus] name=CentOS-6?-?Plus?-?mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos/6/centosplus/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=centosplusgpgcheck=0enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6? #contrib?-?packages?by?Centos?Users[contrib] name=CentOS-6?-?Contrib?-?mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos/6/contrib/$basearch/#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=$basearch&repo=contribgpgcheck=0enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6

保存之后,我們就有一個(gè)centos的源了。執(zhí)行一下:yum -y update ?試一下吧!

下面是安裝Nginx了。我們需要執(zhí)行:

yum?-y?--enablerepo=remi,remi-test?install?nginx

有些朋友可能會(huì)遇到:No Nginx package!,這很簡單就能解決。

在剛才創(chuàng)建源的yum.repos.d文件夾里面,再創(chuàng)建一個(gè)nginx.repo文件。輸入以下內(nèi)容:

[nginx]?? name=nginx?repo?? baseurl=http://nginx.org/packages/centos/6/$basearch/??gpgcheck=0??enabled=1

OK,這是單獨(dú)添加一個(gè)Nginx的源。再執(zhí)行一次上面的安裝Nginx的命令就Ok了!

繼續(xù),安裝php以及php-fpm

yum?-y?--enablerepo=remi,remi-test?install?php?php-fpm?php-common

安裝PHP5.4.4模塊擴(kuò)展,有些會(huì)提示No package,這些都是沒用的,不要管它!

yum?-y?--enablerepo=remi,remi-test?install?php-pecl-apc?php-cli?php-pear?php-pdo?php-mysql?php-pgsql?php-pecl-mongo?php-sqlite?php-pecl-memcache?php-pecl-memcached?php-gd?php-mbstring?php-mcrypt?php-xml

這樣就OK了。運(yùn)行下面的命令,如果出現(xiàn)錯(cuò)誤,說明你上面的步驟出錯(cuò)了。

啟動(dòng)Nginx: service?nginx?start 啟動(dòng)php-fpm: service?php-fpm?start

下面是配置Nginx使用php-fpm,進(jìn)入:

/etc/nginx/conf.d/

打開:default.conf 文件。找到:

location?/?{??root???/usr/share/nginx/html;??#這一行是網(wǎng)站的根目錄,你的網(wǎng)站文件就放在這個(gè)里面!index??index.html?index.htm;??#這一行是添加網(wǎng)站的默認(rèn)主頁的。當(dāng)然,你也可以添加一個(gè)index.php!}

再找到下面的內(nèi)容,把它們前面的#去掉:

#location?~?\.php$?{??#???????root???????????html;??#???????fastcgi_pass???127.0.0.1:9000;??#???????fastcgi_index??index.php;??#???????fastcgi_param??SCRIPT_FILENAME?/usr/share/nginx/html$fastcgi_script_name;??#????????include????????fastcgi_params;??#}

然后把redhat的防火墻文件打開,把80端口添加進(jìn)白名單:

cd?/etc/sysconfig/

打開iptables文件,輸入以下內(nèi)容:

-A?INPUT?-m?state?--state?NEW?-m?tcp?-p?tcp?--dport?80?-j?ACCEPT

重啟防火墻:

service?iptables?restart

到此為止,php與Nginx已經(jīng)搭建好了。我們來試一下。先重啟Nginx與php-fpm:

service?nginx?restart?? service?php-fpm?restart

在你RedHat網(wǎng)頁里輸入:http://localhost/,成功出現(xiàn) Welcome to nginx!則Nginx安裝成功。

然后進(jìn)入你網(wǎng)站的根目錄:/usr/share/nginx/html

新建一個(gè)phpinfo.php文件:

<?phpphpinfo();?>

然后訪問http://localhost/phpinfo.php

看是不是出現(xiàn)php配置的頁面了。如果出現(xiàn)就說明php安裝成功了。

開始安裝mysql!!!!!在終端里輸入:

yum?-y?--enablerepo=remi,remi-test?install?mysql?mysql-server

啟動(dòng)mysql and 設(shè)置自啟動(dòng):

service?mysqld?start?? chkconfig?--levels?235?mysqld?on

然后,進(jìn)入/usr/bin/文件夾,運(yùn)行mysql_secure_installation文件:

cd?/usr/bin/./mysql_secure_installation

這是配置mysql的安全模式。第一次裝mysql最好都配置一下。增加安全性!

執(zhí)行上面的文件之后,會(huì)出現(xiàn)一些配置問題。

1、Enter current password for root (enter for none): (輸入當(dāng)前的root密碼) 當(dāng)前的密碼是空,所以直接回車。

2、Set root password? [Y/n] (是否設(shè)置密碼)輸入Y 回車。

3、New password: ?(新密碼)

4、Re-enter new password: ?(再輸一次)

5、Remove anonymous users? [Y/n] ?(刪除匿名賬戶)?

6、Disallow root login remotely? [Y/n] (禁止root用戶遠(yuǎn)程登錄)

7、Remove test database and access to it? [Y/n] (刪除默認(rèn)創(chuàng)建的test數(shù)據(jù)庫)

8、Reload privilege tables now? [Y/n] (重載權(quán)限表)

安全模式配置完畢!

然后把redhat的防火墻文件打開,把3306端口添加進(jìn)白名單:

cd?/etc/sysconfig/

打開iptables文件,輸入以下內(nèi)容:

-A?INPUT?-m?state?--state?NEW?-m?tcp?-p?tcp?--dport?3306?-j?ACCEPT

重啟防火墻:

service?iptables?restart

OK!LNMP配置完畢!

轉(zhuǎn)載于:https://my.oschina.net/mik3y/blog/291612

總結(jié)

以上是生活随笔為你收集整理的RedHat6.2 x86手动配置LNMP环境的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。