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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

LNMP服务器安装配置(Rhel+Nginx+PHP+MySQL)

發布時間:2023/12/4 数据库 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 LNMP服务器安装配置(Rhel+Nginx+PHP+MySQL) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、關閉selinux、配置防火墻,開啟80、3306端口

[root@localhost?~]#?cp?/etc/sysconfig/iptables?/etc/sysconfig/iptablesbak [root@localhost?~]#?vim?/etc/sysconfig/iptables -A?INPUT?-i?lo?-j?ACCEPT -A?INPUT?-m?state?--state?NEW?-m?tcp?-p?tcp?--dport?22?-j?ACCEPT -A?INPUT?-m?state?--state?NEW?-m?tcp?-p?tcp?--dport?80?-j?ACCEPT -A?INPUT?-m?state?--state?NEW?-m?tcp?-p?tcp?--dport?3306?-j?ACCEPT -A?INPUT?-j?REJECT?--reject-with?icmp-host-prohibited [root@localhost?~]#?/etc/init.d/iptables?restart [root@localhost?~]#?cp?/etc/sysconfig/selinux?/etc/sysconfig/selinuxbak [root@localhost?~]#?cat?/etc/sysconfig/selinux|grep?-v?"#" SELINUX=disabled SELINUXTYPE=targeted? [root@localhost?~]#

2、安裝nginx

[root@localhost?~]#?rpm?-e?--nodeps?`rpm?-qa|egrep?-i?"httpd|php"`??#刪除系統自帶的軟件包 [root@localhost?~]#?wget???#下載、安裝第三方yum源 [root@localhost?~]#?sh?./atomic???#安裝 Do?you?agree?to?these?terms??(yes/no)?[Default:?yes]?yes Configuring?the?[atomic]?yum?archive?for?this?system? Installing?the?Atomic?GPG?keys:?OK OK Enable?repo?by?default??(yes/no)?[Default:?yes]:? The?Atomic?Rocket?Turtle?archive?has?now?been?installed?and?configured?for?your?system The?following?channels?are?available: [root@localhost?~]#?yum?check-update???#更新yum源 [root@localhost?~]#?yum?-y?install?nginx? [root@localhost?~]#?service?nginx?start Starting?nginx:????????????????????????????????????????????[??OK??] [root@localhost?~]#

3、安裝MySQL

[root@localhost?~]#?yum?install?mysql?mysql-server?-y [root@localhost?~]#?chkconfig?mysqld?on [root@localhost?~]#?/etc/init.d/mysqld?start [root@localhost?~]#?cp?/usr/share/mysql/my-medium.cnf?/etc/my.cnf? cp:?overwrite?`/etc/my.cnf'??y [root@localhost?~]#?mysql_secure_installation???#為root賬戶設置密碼 Enter?current?password?for?root?(enter?for?none):? OK,?successfully?used?password,?moving?on... Set?root?password??[Y/n]?Y New?password:? Re-enter?new?password:? Password?updated?successfully! Reloading?privilege?tables.....?Success!Remove?anonymous?users??[Y/n]?Y??...?Success!Disallow?root?login?remotely??[Y/n]?Y...?Success!Remove?test?database?and?access?to?it??[Y/n]?Y-?Dropping?test?database......?Success!-?Removing?privileges?on?test?database......?Success!Reload?privilege?tables?now??[Y/n]?Y...?Success!Thanks?for?using?MySQL![root@localhost?~]#?service?mysqld?restart

4、安裝PHP5

[root@localhost?~]#?yum?install?php?php-fpm?-y [root@localhost?~]#?yum?install?php-mysql?php-gd?libjpeg*?php-imap?php-ldap?php-odbc?php-pear?php-xml?php-xmlrpc?php-mbstring?php-mcrypt??php-bcmath?php-mhash?libmcrypt?-y??#安裝PHP組件,使?PHP5?支持?MySQL [root@localhost?~]#?chkconfig?php-fpm?on [root@localhost?~]#?/etc/init.d/php-fpm?start Starting?php-fpm:??????????????????????????????????????????[??OK??] [root@localhost?~]#

5、配置nginx支持php

[root@localhost?~]#?cp?/etc/nginx/nginx.conf?/etc/nginx/nginx.confbak [root@localhost?~]#?vim?/etc/nginx/nginx.conf user??????????????nginx?nginx;????#修改nginx運行賬號為:nginx組的nginx用戶 worker_processes??1; [root@localhost?~]#?cp?/etc/nginx/conf.d/default.conf?/etc/nginx/conf.d/default.confbak [root@localhost?~]#?vim?/etc/nginx/conf.d/default.conflocation?/?{root???/usr/share/nginx/html;index??index.php?index.html?index.htm;???#增加index.php#?example#ModSecurityEnabled?on;#ModSecurityConfig?/etc/nginx/modsecurity.conf;}location?~?\.php$?{????#取location的注釋,并將fastcgi_param行的參數,改為$document_root$fastcgi_script_name,或者使用絕對路徑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;}???[root@localhost?~]#?service?nginx?restart Stopping?nginx:????????????????????????????????????????????[??OK??] Starting?nginx:????????????????????????????????????????????[??OK??] [root@localhost?~]#

6、php配置

[root@localhost?~]#?cp?/etc/php.ini?/etc/php.inibak [root@localhost?~]#?vim?/etc/php.ini878?date.timezone?=?PRC314?disable_functions?=?passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,in?????i_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapesh?????ellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_c?????termid,posix_get_last_error,posix_getcwd,?posix_getegid,posix_geteuid,posix_getgid,?posix_getgrgid,posix_ge?????tgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,?posix_getppid,posix_getpwna?????m,posix_getpwuid,?posix_getrlimit,?posix_getsid,posix_getuid,posix_isatty,?posix_kill,posix_mkfifo,posix_se?????tegid,posix_seteuid,posix_setgid,?posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_?????ttyname,posix_uname???#PHP禁用的函數,如果某些程序需要用到這個函數,可以刪除,取消禁用。375?expose_php?=?Off????#禁止顯示php版本的信息211?short_open_tag?=?ON???#支持php短標簽308?open_basedir?=?.:/tmp/??#設置表示允許訪問當前目錄(即PHP腳本文件所在之目錄)和/tmp/目錄,可以防止php***跨站,如果改了之后安裝程序有問題(例如:nginx可能網站根目錄下的文件會提示Access?Denied),可以注銷此行,或者直接寫上程序的目錄open_basedir?=?/usr/share/nginx/html/:/tmp/[root@localhost?~]#

7、配置php-fpm

[root@localhost?~]#?cp?/etc/php-fpm.d/www.conf?/etc/php-fpm.d/www.confbak [root@localhost?~]#?vim?/etc/php-fpm.d/www.conf user?=?nginx ;?RPM:?Keep?a?group?allowed?to?write?in?log?dir. group?=?nginx [root@localhost?~]#

8、測試

[root@localhost?~]#?cd?/usr/share/nginx/html/ [root@localhost?html]#?vim?index.php <?php phpinfo(); ?> ~??? [root@localhost?html]#?service?nginx?restart Stopping?nginx:????????????????????????????????????????????[??OK??] Starting?nginx:????????????????????????????????????????????[??OK??] [root@localhost?html]#?service?php-fpm?restart Stopping?php-fpm:??????????????????????????????????????????[??OK??] Starting?php-fpm:??????????????????????????????????????????[??OK??] [root@localhost?html]#

在客戶端瀏覽器輸入服務器IP地址,可以看到相關的配置信息(無法查看可以將php.ini中expose_php設置為on、open_basedir注釋掉,或者直接寫上程序的目錄)! 說明lnmp配置成功!

轉載于:https://blog.51cto.com/ityunwei2017/1733287

總結

以上是生活随笔為你收集整理的LNMP服务器安装配置(Rhel+Nginx+PHP+MySQL)的全部內容,希望文章能夠幫你解決所遇到的問題。

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