日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

RedHat6.2 x86手动配置LNMP环境

發布時間:2023/12/19 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 RedHat6.2 x86手动配置LNMP环境 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

為什么80%的碼農都做不了架構師?>>> ??

因為公司要求用RedHat配,順便讓我練習一下Linux里面的操作什么的。

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

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

首先,在終端里輸入:

cd?/etc/yum.repos.d/

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

然后下一步就是添加centos的源了。新建一個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

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

下面是安裝Nginx了。我們需要執行:

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

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

在剛才創建源的yum.repos.d文件夾里面,再創建一個nginx.repo文件。輸入以下內容:

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

OK,這是單獨添加一個Nginx的源。再執行一次上面的安裝Nginx的命令就Ok了!

繼續,安裝php以及php-fpm

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

安裝PHP5.4.4模塊擴展,有些會提示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了。運行下面的命令,如果出現錯誤,說明你上面的步驟出錯了。

啟動Nginx: service?nginx?start 啟動php-fpm: service?php-fpm?start

下面是配置Nginx使用php-fpm,進入:

/etc/nginx/conf.d/

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

location?/?{??root???/usr/share/nginx/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?/usr/share/nginx/html$fastcgi_script_name;??#????????include????????fastcgi_params;??#}

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

cd?/etc/sysconfig/

打開iptables文件,輸入以下內容:

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

重啟防火墻:

service?iptables?restart

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

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

在你RedHat網頁里輸入:http://localhost/,成功出現 Welcome to nginx!則Nginx安裝成功。

然后進入你網站的根目錄:/usr/share/nginx/html

新建一個phpinfo.php文件:

<?phpphpinfo();?>

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

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

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

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

啟動mysql and 設置自啟動:

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

然后,進入/usr/bin/文件夾,運行mysql_secure_installation文件:

cd?/usr/bin/./mysql_secure_installation

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

執行上面的文件之后,會出現一些配置問題。

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

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

3、New password: ?(新密碼)

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

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

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

7、Remove test database and access to it? [Y/n] (刪除默認創建的test數據庫)

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

安全模式配置完畢!

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

cd?/etc/sysconfig/

打開iptables文件,輸入以下內容:

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

重啟防火墻:

service?iptables?restart

OK!LNMP配置完畢!

轉載于:https://my.oschina.net/mik3y/blog/291612

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。