Fedora 配置 Nginx + MySQL PostgreSQL Python PHP(Fast
记录一下安装配置 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发行版可能需要少许变动)
Nginx
安装
yum install nginx
添加到系统自动运行
chkconfig --levels 235 nginx on
启动
/etc/init.d/nginx start
Nginx 已经安装并启动,访问下 http://localhost/ 试一下吧
MySQL
安装
yum install mysql mysql-server
添加系统服务并启动
chkconfig --levels 235 mysqld on
启动
/etc/init.d/mysqld start
检查是否支持网络连接
netstat -tap | grep mysql
应该会看到这样的状态
netstat -tap | grep mysql tcp 0 0 *:mysql *:* LISTEN 1376/mysqld
如果不是的话,需要修改/etc/my.cnf文件来启用网络连接支持, 将文件中 “#skip-networking” 的 “#” 去掉
重启mysql
/etc/init.d/mysqld restart
MySQL默认root用户的密码为空,需要给root设置密码(* 代表密码字符)
mysqladmin -u root password *****
PostgreSQL
安装
yum install postgresql postgresql-server
然后需要初始化
Service postgresql initdb
打开/var/lib/pgsql/data/pg_hba.conf文件,将Ipv4 local connections一栏中数据改为:
host all all 0.0.0.0 trust
添加远程连接,将/var/lib/pgsql/data/postgresql.conf中的listen_sddress和port的注释删除,并改为:
listen_address = '*' port = 5432
[可选]安装postgresql管理工具pgadmin3
yum install pgadmin3
[可选]添加对python的支持
yum install python-psycopg2
Python
呃,其实 Fedora 自带的 Python 版本已经是比较新的了,只需要安装flup配置一下就ok了。
安装flup
sudo easy_install flup
更新 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; }
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
在 /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; } }
以 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
每次手动启动很麻烦,可以直接把上面内容追加到 /etc/rc.local 文件实现自动启动。
EOF
原文地址:Fedora 配置 Nginx + MySQL PostgreSQL Python PHP(Fast, 感谢原作者分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











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 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.

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.

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.

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.

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 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.

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