Table of Contents
Linux
Nginx
MySQL
PostgreSQL
Python
PHP
Home Database Mysql Tutorial Fedora 配置 Nginx + MySQL PostgreSQL Python PHP(Fast

Fedora 配置 Nginx + MySQL PostgreSQL Python PHP(Fast

Jun 07, 2016 pm 04:31 PM
fedora mysql nginx Configuration

记录一下安装配置 Linux+Nginx+MySQL+PostgreSQL+Python+PHP 的过程。就是传说中的 LNMPPP~说白了就是 OS 使用 Linux, Web server 使用 Nginx, 支持Python和PHP,数据库支持PostgreSQL和MySQL。开始吧~ Linux Fedora 13(其他Linux发行版可能需要少许变动)

记录一下安装配置 Linux+Nginx+MySQL+PostgreSQL+Python+PHP 的过程。就是传说中的 LNMPPP~说白了就是 OS 使用 Linux, Web server 使用 Nginx, 支持Python和PHP,数据库支持PostgreSQL和MySQL。开始吧~

Linux

Fedora 13(其他Linux发行版可能需要少许变动)
Copy after login

Nginx

安装

yum install nginx
Copy after login

添加到系统自动运行

chkconfig --levels 235 nginx on
Copy after login

启动

/etc/init.d/nginx start
Copy after login

Nginx 已经安装并启动,访问下 http://localhost/ 试一下吧

MySQL

安装

yum install mysql mysql-server
Copy after login

添加系统服务并启动

chkconfig --levels 235 mysqld on
Copy after login

启动

/etc/init.d/mysqld start
Copy after login

检查是否支持网络连接

netstat -tap | grep mysql
Copy after login

应该会看到这样的状态

netstat -tap | grep mysql
tcp        0      0 *:mysql       *:*              LISTEN      1376/mysqld
Copy after login

如果不是的话,需要修改/etc/my.cnf文件来启用网络连接支持, 将文件中 “#skip-networking” 的 “#” 去掉

重启mysql

/etc/init.d/mysqld restart
Copy after login

MySQL默认root用户的密码为空,需要给root设置密码(* 代表密码字符)

mysqladmin -u root password *****
Copy after login

PostgreSQL

安装

yum install postgresql postgresql-server
Copy after login

然后需要初始化

Service postgresql initdb
Copy after login

打开/var/lib/pgsql/data/pg_hba.conf文件,将Ipv4 local connections一栏中数据改为:

host    all         all         0.0.0.0           trust
Copy after login

添加远程连接,将/var/lib/pgsql/data/postgresql.conf中的listen_sddress和port的注释删除,并改为:

listen_address = '*'
port = 5432
Copy after login

[可选]安装postgresql管理工具pgadmin3

yum install pgadmin3
Copy after login

[可选]添加对python的支持

yum install python-psycopg2
Copy after login

Python

呃,其实 Fedora 自带的 Python 版本已经是比较新的了,只需要安装flup配置一下就ok了。

安装flup

sudo easy_install flup
Copy after login

更新 Nginx 配置文件 nginx.conf

server {
    listen 80;
    server_name localhost;
    # site_media - folder in uri for static files
    location /static  {
        root /var/www/static;
    }
    location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov) {
        access_log   off;
        expires      30d;
    }
    location / {
        # host and port to fastcgi server
        fastcgi_pass 127.0.0.1:8000;
        fastcgi_param PATH_INFO      $fastcgi_script_name;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param QUERY_STRING   $query_string;
        fastcgi_param CONTENT_TYPE   $content_type;
        fastcgi_param CONTENT_LENGTH $content_length;
        fastcgi_pass_header          Authorization;
        fastcgi_intercept_errors     off;
    }
   access_log /var/log/nginx/localhost.access_log main;
   error_log  /var/log/nginx/localhost.error_log;
}
Copy after login

PHP

安装 PHP

yum install php-cli php-mysql php-pgsql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mapserver php-mbstring php-mcrypt php-shout php-snmp php-soap php-tidy
Copy after login

在 /etc/php.ini 文件中追加’cgi.fix_pathinfo=1’

更新 Nginx 配置文件 nginx.conf

server {
    listen       80;
    server_name  localhost;
    #charset koi8-r;
    #access_log  logs/host.access.log  main;
    location / {
        root   /usr/share/nginx/html;
        index  index.php index.html index.htm;
    }
    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }
    error_page 500 502 503 504  /50x.html;
    location = /50x.html {
        root   /var/www;
    }
    location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www$fastcgi_script_name;
        include        fastcgi_params;
    }
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }
}
Copy after login

以 FCGI 方式在9000端口启动 PHP

/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u nginx -g nginx -f /usr/bin/php-cgi -P /var/run/fastcgi-php.pid
Copy after login

每次手动启动很麻烦,可以直接把上面内容追加到 /etc/rc.local 文件实现自动启动。

EOF

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1266
29
C# Tutorial
1239
24
Laravel Introduction Example Laravel Introduction Example Apr 18, 2025 pm 12:45 PM

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

MySQL vs. Other Programming Languages: A Comparison MySQL vs. Other Programming Languages: A Comparison Apr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Laravel framework installation method Laravel framework installation method Apr 18, 2025 pm 12:54 PM

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

Explain the purpose of foreign keys in MySQL. Explain the purpose of foreign keys in MySQL. Apr 25, 2025 am 12:17 AM

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

Compare and contrast MySQL and MariaDB. Compare and contrast MySQL and MariaDB. Apr 26, 2025 am 12:08 AM

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

SQL vs. MySQL: Clarifying the Relationship Between the Two SQL vs. MySQL: Clarifying the Relationship Between the Two Apr 24, 2025 am 12:02 AM

SQL is a standard language for managing relational databases, while MySQL is a database management system that uses SQL. SQL defines ways to interact with a database, including CRUD operations, while MySQL implements the SQL standard and provides additional features such as stored procedures and triggers.

How to safely store JavaScript objects containing functions and regular expressions to a database and restore? How to safely store JavaScript objects containing functions and regular expressions to a database and restore? Apr 19, 2025 pm 11:09 PM

Safely handle functions and regular expressions in JSON In front-end development, JavaScript is often required...

See all articles