设为首页 收藏本站
查看: 937|回复: 0

Setting up a LAMP stack

[复制链接]

尚未签到

发表于 2015-11-16 08:21:20 | 显示全部楼层 |阅读模式
  原文:
http://fedorasolved.org/server-solutions/lamp-stack


  The so-called
LAMP
stack is one of the most compelling reasons toinstall Linux in the first place and probably the one primary purpose for many Fedora server-basedinstallations.
The combination of Linux/Apache/MySQL/PHP (or Perl,
or even Python)allows webmasters to build websites and run complex applications such as a webmail interface or a wiki.
  



Requirements
  


  The requirements for a server running Fedora  can rangesomewhat more widely than those recommended in the release notes,depending on the use case. A small, private server with light usecan easily handle its expected load with even lessmemory/storage/speed
than the release notes necessarily call for.On the other hand, a server designed to withstand huge amounts oftraffic can benefit from multiple processors, several gigabytes ofRAM, and large arrays of disk drives. As a server administrator,you'll need to use
your best judgment for your use case.



Hardware aside, this article assumes nothing more than a freshFedora  
installation and shell access as root (all commandslisted here assume you execute them as root). Configuring forspecific uses (setting up Virtual Hosts,installing webapplications or creating websites, or learning
PHP) are beyond thescope of this article, which only covers setup.
  For people who want to install xampp follow this howto instead of trying toinstall the xampp blob of unmanageable crap.

Doing the work
  
  The best way to install a
LAMP stack is to install each letter insequence; to spell out the wordLAMP, in effect.
  

Linux
  

If you've already got Fedora  installed, then you'veaccomplished this step. If you haven't, check outInstall Solutions  for more details on installing andconfiguring Fedora.
  

Apache


  • Installing Apache means
    installing the program which will handlerequests to your web server. For most people, Apache itself is theweb server, terminologically speaking. In your Fedorainstallation, depending on the choices you made
    during theinstallprocess, you may or may not have Apache alreadyinstalled. Just usethe following command to check:
    # rpm -q httpd
  • If it tells you a version number, then it's
    installed and we canprogress to the next step. Otherwise, we need to
    install it:
    # yum install httpd
  • After installation, the service must be configured to startautomatically.
    # /sbin/chkconfig httpd on
  • To start the server process immediately:
    # /sbin/service httpd start
  • (F10 or older) Finally, it's important to make sure that port 80 is remotelyaccessible, by configuring iptables to open the port (and to leaveit open by default from the outside). The following commands willremember the rule for you across reboots and apply
    itimmediately:
    # echo '-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT' >> /etc/sysconfig/iptables
    # /sbin/service iptables restart
    You can put in the hostname or IP address of the server in theaddress bar of a web browser (whether on the same host or elsewherein the network) to test theinstallation. You'll see a welcome pageif everything was successful.
    Otherwise, refer totroubleshooting.
  • (F11 or newer) 1. Execute the 'system-config-firewall-tui' command as root:
    # system-config-firewall-tui
    2. Use tab to navigate to "customize" and press [enter].

    3. Use the arrow keys to navigate to WWW (HTTP) and press the space bar or [enter].

    4. Use tab to navigate to 'forward' and press [enter].

    --- httpd is allowed now once we save

    --- mysql steps

    5. On the "Other Ports" screen, use tab to select 'add'.

    6. For the Port/Port-Range, enter 3306. For the protocol, enter tcp. Use tab to navigate to 'OK' and press [enter].

    7. Use tab to navigate to 'close' and press [enter].

    8. Use tab to navigate to 'OK' and press [enter].

    9. Use tab to navigate to 'Yes' and press [enter].
  

MySQL

NOTE:   This is the abbreviated process to setup MySQL.
  


  • Installing and running the database component of theLAMP stack,called MySQL, is at least as easy. The following command willinstall
    the database and the server process.
    # yum install mysql mysql-server
  • (F10 or older only) The server process must likewise be running and accessible.
    # /sbin/chkconfig  mysqld on
    # echo '-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT' >> /etc/sysconfig/iptables
    # /sbin/service iptables restart
    # /sbin/service mysqld start
  • To test that everything is working okay so far, run this commandto print out some information and check its status:
    # mysqladmin version status
  

PHP (or Perl or Python)

      PHP interprets the scripts of your favorite web site orapplication, running on top of the other parts of theLAMP stack.

  • The following command will install PHP, along with the needed stuffto glue it together with the web server and the database.
    # yum install php php-mysql
  • PHP is pretty much ready to run after that, although you may needto restart the web server to make sure it loads the PHP module.
    # /sbin/service httpd restart
    If you'd like to use another 'P' in the place of PHP (or
    installalongside), the steps are pretty similar. Both Perl and Python comewith ways to access MySQL and modules to allow them to run smoothlyand quickly inside of Apache.
  • To run Python on your web server, run the following. (Python isalready
    installed on all Fedora  installations, so it's notneeded toinstall that as well.)
    # yum install mod_python MySQL-python
  • For Perl, the following will get you started:
    # yum install perl mod_perl perl-DBD-mysql
    Don't forget to restart the web server after either (or both) ofthese commands to make sure the relevant modules will be loaded byApache.
  

Troubleshooting
  
  Definitively testing the whole thing is pretty easy. You can createa small test PHP file and try to access it.


  • Create the test script:
    # echo &quot;<?php phpinfo(); ?>&quot; > /var/www/html/index.php
    Then access the web server by putting the address in any webbrowser that can access the server. If your server's IP address is192.168.1.100, put that in the address bar. By going to thataddress, you should see a long detailed page describing PHP'sconfiguration
    and status in detail.



    You can skip down to the MySQL section by putting a jump in theaddress bar to it. (If you used http://192.168.1.100/ to access thepage, use http://192.168.1.100/#module_mysql to skip down to therelevant part.) You should see various options about MySQLenumerated.
  • If all this is successful, you should delete the script you justcreated.
    # rm -f /var/www/html/index.php
    Now it's time to install your favorite web application (phpBB,mediawiki, squirrelmail/roundcube) or learn PHP.
  

Bugs
  Since I don't personally use Perl for web development, I'm not surewhat exactly is needed to use it with a database.
  

Disclaimer
  We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #fedora on irc.freenode.net

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-139664-1-1.html 上篇帖子: LAMP配置详解 下篇帖子: centos6.6配置LNMP(linux+nginx+mysql+php)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表